opendap/src/main/java/opendap/dap/parsers/Dap2Lex.java
public int
yylex()
        throws ParseException
{
    int token;
    int c;
    token = 0;
    yytext.setLength(0);
    text.mark();

    try {

        token = -1;
        while (token < 0 && (c = text.read()) > 0) {
            if (c == '\n') {
                lineno++;
            } else if (c <= ' ' || c == '\177') {
                /* whitespace: ignore */
            } else if (c == '#') {
                /* single line comment */
                for (; ;) {
                    c = text.read();
                    if (c == '\n' || c == '\0') break;
                }
            } else if (worddelims.indexOf(c) >= 0) {
                token = c;
            } else if (c == '"') {
                boolean more = true;
                /* We have a string token; will be reported as SCAN_WORD */
                while (more && (c = text.read()) > 0) {
                    if (DAP2STRING) {/* Implement DAP2 standard */
                        switch  (c) {
                        case '"':
                            more = false;
                            break;
                        case '\\':
                            c = text.read();
                            if (c < 0) more = false;
                            break;
                        case '(':
                        default: break;
                        }
                    } else {// not used : Implement a more java/c like alternative for string encoding
                        switch (c) {
                        case '"':
                            more = false;
                            break;
                        case '\\':
                            c = text.read();
                            switch (c) {
                            case 'r':
                                c = '\r';
                                break;
                            case 'n':
                                c = '\n';
                                break;
                            case 'f':
                                c = '\f';
                                break;
                            case 't':
                                c = '\t';
                                break;
                            case 'x': {
                                int d1, d2;
                                c = text.read();
                                d1 = tohex(c);
                                if (d1 < 0) {
                                    throw new ParseException("Illegal \\xDD in TOKEN_STRING");
                                } else {
                                    c = text.read();
                                    d2 = tohex(c);
                                    if (d2 < 0) {
                                        throw new ParseException("Illegal \\xDD in TOKEN_STRING");
                                    } else {
                                        c = ((d1) << 4) | d2;
                                    }
                                }
                            }
                            break;
                            default:
                                break;
                            }
                            break;
                        default:
                            break;
                        }
                    }
                    if (more) yytext.append((char) c);
                }
                token = WORD_STRING;

            } else if (wordchars1.indexOf(c) >= 0) {
                yytext.append((char) c);
                /* we have a SCAN_WORD (== identifier | number) */
                while ((c = text.read()) > 0) {
                    if (wordcharsn.indexOf(c) < 0) {
                        text.backup();
                        break;
                    }
                    yytext.append((char) c);
                }
                token = WORD_WORD; /* assume */
                /* check for keyword */
                String tmp = yytext.toString();
                for (int i = 0; ; i++) {
                    if (keywords[i] == null) break;
                    if (keywords[i].equalsIgnoreCase(tmp)) {
                        token = keytokens[i];
                        break;
                    }
                }
            } else { /* illegal */
                String msg = String.format("Illegal Character: '%c'", c);
                yytext.append((char)c);
                lexerror(msg);
                throw new ParseException(msg);
            }
        }

        // do eof check
        if (token <= 0) {
            token = 0;
            lval = null;
        } else {
            lval = (yytext.length() == 0 ? (String) null : yytext.toString());
        }
        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);
    text.mark();

    try {

        token = -1;
        while (token < 0 && (c = text.read()) > 0) {
            if (c == '\n') {
                lineno++;
            } else if (c <= ' ' || c == '\177') {
                /* whitespace: ignore */
            } else if (c == '#') {
                /* single line comment */
                for (; ;) {
                    c = text.read();
                    if (c == '\n' || c == '\0') break;
                }
            } else if (worddelims.indexOf(c) >= 0) {
                token = c;
            } else if (c == '"') {
                boolean more = true;
                /* We have a string token; will be reported as SCAN_WORD */
                while (more && (c = text.read()) > 0) {
                    if (DAP2STRING) {/* Implement DAP2 standard */
                        switch  (c) {
                        case '"':
                            more = false;
                            break;
                        case '\\':
                            c = text.read();
                            if (c < 0) more = false;
                            break;
                        case '(':
                        default: break;
                        }
                    } else {// not used : Implement a more java/c like alternative for string encoding
                        switch (c) {
                        case '"':
                            more = false;
                            break;
                        case '\\':
                            c = text.read();
                            switch (c) {
                            case 'r':
                                c = '\r';
                                break;
                            case 'n':
                                c = '\n';
                                break;
                            case 'f':
                                c = '\f';
                                break;
                            case 't':
                                c = '\t';
                                break;
                            case 'x': {
                                int d1, d2;
                                c = text.read();
                                d1 = tohex(c);
                                if (d1 < 0) {
                                    throw new ParseException("Illegal \\xDD in TOKEN_STRING");
                                } else {
                                    c = text.read();
                                    d2 = tohex(c);
                                    if (d2 < 0) {
                                        throw new ParseException("Illegal \\xDD in TOKEN_STRING");
                                    } else {
                                        c = ((d1) << 4) | d2;
                                    }
                                }
                            }
                            break;
                            default:
                                break;
                            }
                            break;
                        default:
                            break;
                        }
                    }
                    if (more) yytext.append((char) c);
                }
                token = WORD_STRING;

            } else if (wordchars1.indexOf(c) >= 0) {
                yytext.append((char) c);
                /* we have a SCAN_WORD (== identifier | number) */
                while ((c = text.read()) > 0) {
                    if (wordcharsn.indexOf(c) < 0) {
                        text.backup();
                        break;
                    }
                    yytext.append((char) c);
                }
                token = WORD_WORD; /* assume */
                /* check for keyword */
                String tmp = yytext.toString();
                for (int i = 0; ; i++) {
                    if (keywords[i] == null) break;
                    if (keywords[i].equalsIgnoreCase(tmp)) {
                        token = keytokens[i];
                        break;
                    }
                }
            } else { /* illegal */
                String msg = String.format("Illegal Character: '%c'", c);
                yytext.append((char)c);
                lexerror(msg);
                throw new ParseException(msg);
            }
        }

        // do eof check
        if (token <= 0) {
            token = 0;
            lval = null;
        } else {
            lval = (yytext.length() == 0 ? (String) null : yytext.toString());
        }
        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 ) ; text . mark ( ) ; try { token = - 1 ; while ( token < 0 && ( c = text . read ( ) ) > 0 ) { if ( c == ' ' ) { lineno ++ ; } else if ( c <= ' ' || c == ' ' ) { /* whitespace: ignore */ } else if ( c == ' ' ) { /* single line comment */ for ( ; ; ) { c = text . read ( ) ; if ( c == ' ' || c == ' ' ) break ; } } else if ( worddelims . indexOf ( c ) >= 0 ) { token = c ; } else if ( c == ' ' ) { boolean more = true ; /* We have a string token; will be reported as SCAN_WORD */ while ( more && ( c = text . read ( ) ) > 0 ) { if ( DAP2STRING ) { /* Implement DAP2 standard */ switch ( c ) { case ' ' : more = false ; break ; case ' ' : c = text . read ( ) ; if ( c < 0 ) more = false ; break ; case ' ' : default : break ; } } else { // not used : Implement a more java/c like alternative for string encoding switch ( c ) { case ' ' : more = false ; break ; case ' ' : c = text . read ( ) ; switch ( c ) { case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : c = ' ' ; break ; case ' ' : { int d1 , d2 ; c = text . read ( ) ; d1 = tohex ( c ) ; if ( d1 < 0 ) { throw new ParseException ( "Illegal \\xDD in TOKEN_STRING" ) ; } else { c = text . read ( ) ; d2 = tohex ( c ) ; if ( d2 < 0 ) { throw new ParseException ( "Illegal \\xDD in TOKEN_STRING" ) ; } else { c = ( ( d1 ) << 4 ) | d2 ; } } } break ; default : break ; } break ; default : break ; } } if ( more ) yytext . append ( ( char ) c ) ; } token = WORD_STRING ; } else if ( wordchars1 . indexOf ( c ) >= 0 ) { yytext . append ( ( char ) c ) ; /* we have a SCAN_WORD (== identifier | number) */ while ( ( c = text . read ( ) ) > 0 ) { if ( wordcharsn . indexOf ( c ) < 0 ) { text . backup ( ) ; break ; } yytext . append ( ( char ) c ) ; } token = WORD_WORD ; /* assume */ /* check for keyword */ String tmp = yytext . toString ( ) ; for ( int i = 0 ; ; i ++ ) { if ( keywords [ i ] == null ) break ; if ( keywords [ i ] . equalsIgnoreCase ( tmp ) ) { token = keytokens [ i ] ; break ; } } } else { /* illegal */ String msg = String . format ( "Illegal Character: '%c'" , c ) ; yytext . append ( ( char ) c ) ; lexerror ( msg ) ; throw new ParseException ( msg ) ; } } // do eof check if ( token <= 0 ) { token = 0 ; lval = null ; } else { lval = ( yytext . length ( ) == 0 ? ( String ) null : yytext . toString ( ) ) ; } if ( parsestate . getDebugLevel ( ) > 0 ) dumptoken ( token , ( String ) lval ) ; return token ; /* Return the type of the token.  */ } catch ( IOException ioe ) { throw new ParseException ( ioe ) ; } }
Entry point for the scanner.      Returns the token identifier corresponding
to the next token and prepares to return the semantic value
of the token.
@return the token identifier corresponding to the next token.
This is part of the Lexer interface
Entry point for the scanner . Returns the token identifier corresponding to the next token and prepares to return the semantic value of the token .