opendap/src/main/java/opendap/servers/parsers/Celex.java
public int
    yylex()
        throws ParseException
    {
        int token;
        int c;
        token = 0;
        yytext.setLength(0);
        /* invariant: p always points to current char */

        try {
            token = -1;
            while(token < 0) {
                if((c = read()) <= 0) break;
                if(c == '\n') {
                } else if(c <= ' ' || c == '\177') {
                    /* whitespace: ignore */
                } else if(worddelims.indexOf(c) >= 0) {
                    /* don't put in yytext to avoid memory leak */
                    token = c;
                } else if(c == '"') {
                    boolean more = true;
                    /* We have a string token; will be reported as SCAN_STRINGCONST */
                    while(more && (c = read()) > 0) {
                        if(c == '"')
                            more = false;
                        else if(c == '\\') {
                            c = read();
                            if(c < 0) more = false;
                        }
                        if(more) yytext.append((char) c);
                    }
                    token = SCAN_STRINGCONST;
                } else if(false && numchars1.indexOf(c) >= 0) {
                    // we might have a SCAN_NUMBERCONST
                    boolean isnumber = false;
                    yytext.append((char) c);
                    while((c = read()) > 0) {
                        if(numcharsn.indexOf(c) < 0) {
                            pushback(c);
                            break;
                        }
                        yytext.append((char) c);
                    }
                    removetrailingblanks();
                    //See if this is a number
                    try {
                        Double number = new Double(yytext.toString());
                        isnumber = true;
                    } catch (NumberFormatException nfe) {
                        isnumber = false;
                    }
                    //A number followed by an id char is assumed to just be a funny id
                    if(isnumber) {
                        c = read();
                        if(wordcharsn.indexOf(c) >= 0) { // this is apparently just a funny id
                            token = SCAN_WORD;
                        } else {  // its really a number
                            token = SCAN_NUMBERCONST;
                            if(c != '\0') pushback(c);
                        }
                    } else {// !isNumber
                        /* Now, if the funny word has a "." in it,
                           we have to back up to that dot */
                        int dotpoint = yytext.toString().indexOf('.');
                        if(dotpoint >= 0) {
                            for(int i = 0;i < dotpoint;i++) {
                                pushback(yytext.charAt(i));
                            }
                            yytext.setLength(dotpoint);
                        }
                        token = SCAN_WORD;
                    }
                } else if(wordornumberchars1.indexOf(c) >= 0) {
                    boolean isnumber = false;
                    /* we have a WORD or a number*/
                    yytext.append((char) c);
                    while((c = read()) > 0) {
                        if(wordornumbercharsn.indexOf(c) < 0) {
                            pushback(c);
                            break;
                        }
                        yytext.append((char) c);
                    }
                    removetrailingblanks();
                    /* If this looks like a number, then treat it as such.*/
                    try {
                        new Double(yytext.toString());
                        isnumber = true;
                    } catch (NumberFormatException nfe) {
                        isnumber = false;
                    }
                    if(isnumber)
                        token = SCAN_NUMBERCONST;
                    else {
                        token = SCAN_WORD;
                        /* If this is a mistaken number, then we need to
                           backup to the last occurrence of a dot '.'
                           because all other number characters are legitmate
                           identifier characters. Special case occurs when
                           we are left with a single dot.
                         */
                        int dotpoint = yytext.toString().indexOf('.');
                        if(dotpoint >= 0) {
                            // pushback the whole of yytext (in reverse order)
                            for(int i = yytext.length() - 1;i >= 0;i--)
                                pushback(yytext.charAt(i));
                            yytext.setLength(0);
                            if(dotpoint == 0) {// single character delimiter
                                token = '.';
                                yytext.append((char) (c = read()));
                            } else {
                                // Recollect up to but not including the first dot.
                                for(int i = 0;i < dotpoint;i++)
                                    yytext.append((char) (c = read()));
                            }
                        }
                    }
                } else {
                    /* we have a single char token */
                    token = c;
                }
            }
            if(token < 0) {
                token = 0;
                lval = null;
            } else {
                // We have to apply DAP2 %xx escaping if this is a SCAN_WORD
                String text = yytext.toString();
                if(token == SCAN_WORD)
                    text = EscapeStrings.unescapeDAPIdentifier(text);
                lval = (text.length() == 0 ? (String) null : text);
            }
            if(parsestate.getDebugLevel() > 0) dumptoken(token, (String) lval);
            return token;       /* Return the type of the token.  */

        } catch (IOException ioe) {
            throw new ParseException(ioe);
        }
    }
public int
    yylex()
        throws ParseException
    {
        int token;
        int c;
        token = 0;
        yytext.setLength(0);
        /* invariant: p always points to current char */

        try {
            token = -1;
            while(token < 0) {
                if((c = read()) <= 0) break;
                if(c == '\n') {
                } else if(c <= ' ' || c == '\177') {
                    /* whitespace: ignore */
                } else if(worddelims.indexOf(c) >= 0) {
                    /* don't put in yytext to avoid memory leak */
                    token = c;
                } else if(c == '"') {
                    boolean more = true;
                    /* We have a string token; will be reported as SCAN_STRINGCONST */
                    while(more && (c = read()) > 0) {
                        if(c == '"')
                            more = false;
                        else if(c == '\\') {
                            c = read();
                            if(c < 0) more = false;
                        }
                        if(more) yytext.append((char) c);
                    }
                    token = SCAN_STRINGCONST;
                } else if(false && numchars1.indexOf(c) >= 0) {
                    // we might have a SCAN_NUMBERCONST
                    boolean isnumber = false;
                    yytext.append((char) c);
                    while((c = read()) > 0) {
                        if(numcharsn.indexOf(c) < 0) {
                            pushback(c);
                            break;
                        }
                        yytext.append((char) c);
                    }
                    removetrailingblanks();
                    //See if this is a number
                    try {
                        Double number = new Double(yytext.toString());
                        isnumber = true;
                    } catch (NumberFormatException nfe) {
                        isnumber = false;
                    }
                    //A number followed by an id char is assumed to just be a funny id
                    if(isnumber) {
                        c = read();
                        if(wordcharsn.indexOf(c) >= 0) { // this is apparently just a funny id
                            token = SCAN_WORD;
                        } else {  // its really a number
                            token = SCAN_NUMBERCONST;
                            if(c != '\0') pushback(c);
                        }
                    } else {// !isNumber
                        /* Now, if the funny word has a "." in it,
                           we have to back up to that dot */
                        int dotpoint = yytext.toString().indexOf('.');
                        if(dotpoint >= 0) {
                            for(int i = 0;i < dotpoint;i++) {
                                pushback(yytext.charAt(i));
                            }
                            yytext.setLength(dotpoint);
                        }
                        token = SCAN_WORD;
                    }
                } else if(wordornumberchars1.indexOf(c) >= 0) {
                    boolean isnumber = false;
                    /* we have a WORD or a number*/
                    yytext.append((char) c);
                    while((c = read()) > 0) {
                        if(wordornumbercharsn.indexOf(c) < 0) {
                            pushback(c);
                            break;
                        }
                        yytext.append((char) c);
                    }
                    removetrailingblanks();
                    /* If this looks like a number, then treat it as such.*/
                    try {
                        new Double(yytext.toString());
                        isnumber = true;
                    } catch (NumberFormatException nfe) {
                        isnumber = false;
                    }
                    if(isnumber)
                        token = SCAN_NUMBERCONST;
                    else {
                        token = SCAN_WORD;
                        /* If this is a mistaken number, then we need to
                           backup to the last occurrence of a dot '.'
                           because all other number characters are legitmate
                           identifier characters. Special case occurs when
                           we are left with a single dot.
                         */
                        int dotpoint = yytext.toString().indexOf('.');
                        if(dotpoint >= 0) {
                            // pushback the whole of yytext (in reverse order)
                            for(int i = yytext.length() - 1;i >= 0;i--)
                                pushback(yytext.charAt(i));
                            yytext.setLength(0);
                            if(dotpoint == 0) {// single character delimiter
                                token = '.';
                                yytext.append((char) (c = read()));
                            } else {
                                // Recollect up to but not including the first dot.
                                for(int i = 0;i < dotpoint;i++)
                                    yytext.append((char) (c = read()));
                            }
                        }
                    }
                } else {
                    /* we have a single char token */
                    token = c;
                }
            }
            if(token < 0) {
                token = 0;
                lval = null;
            } else {
                // We have to apply DAP2 %xx escaping if this is a SCAN_WORD
                String text = yytext.toString();
                if(token == SCAN_WORD)
                    text = EscapeStrings.unescapeDAPIdentifier(text);
                lval = (text.length() == 0 ? (String) null : text);
            }
            if(parsestate.getDebugLevel() > 0) dumptoken(token, (String) lval);
            return token;       /* Return the type of the token.  */

        } catch (IOException ioe) {
            throw new ParseException(ioe);
        }
    }
/* This is part of the Lexer interface