// $ANTLR : "program.g" -> "programLexer.java"$ import edu.neu.ccs.demeter.*; import java.io.InputStream; import antlr.TokenStreamException; import antlr.TokenStreamIOException; import antlr.TokenStreamRecognitionException; import antlr.CharStreamException; import antlr.CharStreamIOException; import antlr.ANTLRException; import java.io.Reader; import java.util.Hashtable; import antlr.CharScanner; import antlr.InputBuffer; import antlr.ByteBuffer; import antlr.CharBuffer; import antlr.Token; import antlr.CommonToken; import antlr.RecognitionException; import antlr.NoViableAltForCharException; import antlr.MismatchedCharException; import antlr.TokenStream; import antlr.ANTLRHashString; import antlr.LexerSharedInputState; import antlr.collections.impl.BitSet; import antlr.SemanticException; public class programLexer extends antlr.CharScanner implements programParserTokenTypes, TokenStream { public programLexer(InputStream in) { this(new ByteBuffer(in)); } public programLexer(Reader in) { this(new CharBuffer(in)); } public programLexer(InputBuffer ib) { this(new LexerSharedInputState(ib)); } public programLexer(LexerSharedInputState state) { super(state); caseSensitiveLiterals = true; setCaseSensitive(true); literals = new Hashtable(); literals.put(new ANTLRHashString("", this), new Integer(14)); literals.put(new ANTLRHashString("", this), new Integer(6)); literals.put(new ANTLRHashString(">", this), new Integer(5)); literals.put(new ANTLRHashString("true", this), new Integer(19)); literals.put(new ANTLRHashString("", this), new Integer(10)); literals.put(new ANTLRHashString("/>", this), new Integer(17)); literals.put(new ANTLRHashString("", this), new Integer(8)); literals.put(new ANTLRHashString("false", this), new Integer(20)); literals.put(new ANTLRHashString("atomRefs2=", this), new Integer(18)); literals.put(new ANTLRHashString("elementType=", this), new Integer(12)); literals.put(new ANTLRHashString("", this), new Integer(15)); literals.put(new ANTLRHashString("hydrogenCount=", this), new Integer(13)); literals.put(new ANTLRHashString("id=", this), new Integer(11)); literals.put(new ANTLRHashString("", this), new Integer(7)); } public Token nextToken() throws TokenStreamException { Token theRetToken=null; tryAgain: for (;;) { Token _token = null; int _ttype = Token.INVALID_TYPE; resetText(); try { // for char stream error handling try { // for lexical error handling switch ( LA(1)) { case '\t': case '\n': case '\u000c': case '\r': case ' ': { mWS(true); theRetToken=_returnToken; break; } case '\'': { mCHAR_LITERAL(true); theRetToken=_returnToken; break; } case '"': { mSTRING_LITERAL(true); theRetToken=_returnToken; break; } case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { mNUM_INT(true); theRetToken=_returnToken; break; } default: if ((LA(1)=='/') && (LA(2)=='/')) { mSL_COMMENT(true); theRetToken=_returnToken; } else if ((LA(1)=='/') && (LA(2)=='*')) { mML_COMMENT(true); theRetToken=_returnToken; } else if ((_tokenSet_0.member(LA(1))) && (true)) { mIDENT(true); theRetToken=_returnToken; } else { if (LA(1)==EOF_CHAR) {uponEOF(); _returnToken = makeToken(Token.EOF_TYPE);} else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } if ( _returnToken==null ) continue tryAgain; // found SKIP token _ttype = _returnToken.getType(); _returnToken.setType(_ttype); return _returnToken; } catch (RecognitionException e) { throw new TokenStreamRecognitionException(e); } } catch (CharStreamException cse) { if ( cse instanceof CharStreamIOException ) { throw new TokenStreamIOException(((CharStreamIOException)cse).io); } else { throw new TokenStreamException(cse.getMessage()); } } } } public final void mIDENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = IDENT; int _saveIndex; switch ( LA(1)) { case '>': { match(">"); break; } case '/': { match("/>"); break; } default: boolean synPredMatched38 = false; if (((LA(1)=='<') && (LA(2)=='m'))) { int _m38 = mark(); synPredMatched38 = true; inputState.guessing++; try { { match(""); } } catch (RecognitionException pe) { synPredMatched42 = false; } rewind(_m42); inputState.guessing--; } if ( synPredMatched42 ) { match(""); } else { boolean synPredMatched44 = false; if (((LA(1)=='<') && (LA(2)=='a'))) { int _m44 = mark(); synPredMatched44 = true; inputState.guessing++; try { { match(""); } } catch (RecognitionException pe) { synPredMatched44 = false; } rewind(_m44); inputState.guessing--; } if ( synPredMatched44 ) { match(""); } else { boolean synPredMatched46 = false; if (((LA(1)=='<') && (LA(2)=='/'))) { int _m46 = mark(); synPredMatched46 = true; inputState.guessing++; try { { match(""); } } catch (RecognitionException pe) { synPredMatched46 = false; } rewind(_m46); inputState.guessing--; } if ( synPredMatched46 ) { match(""); } else { boolean synPredMatched48 = false; if (((LA(1)=='<') && (LA(2)=='a'))) { int _m48 = mark(); synPredMatched48 = true; inputState.guessing++; try { { match(""); } } catch (RecognitionException pe) { synPredMatched50 = false; } rewind(_m50); inputState.guessing--; } if ( synPredMatched50 ) { match(""); } else { boolean synPredMatched52 = false; if (((LA(1)=='i') && (LA(2)=='d'))) { int _m52 = mark(); synPredMatched52 = true; inputState.guessing++; try { { match("id="); } } catch (RecognitionException pe) { synPredMatched52 = false; } rewind(_m52); inputState.guessing--; } if ( synPredMatched52 ) { match("id="); } else { boolean synPredMatched54 = false; if (((LA(1)=='e') && (LA(2)=='l'))) { int _m54 = mark(); synPredMatched54 = true; inputState.guessing++; try { { match("elementType="); } } catch (RecognitionException pe) { synPredMatched54 = false; } rewind(_m54); inputState.guessing--; } if ( synPredMatched54 ) { match("elementType="); } else { boolean synPredMatched56 = false; if (((LA(1)=='h') && (LA(2)=='y'))) { int _m56 = mark(); synPredMatched56 = true; inputState.guessing++; try { { match("hydrogenCount="); } } catch (RecognitionException pe) { synPredMatched56 = false; } rewind(_m56); inputState.guessing--; } if ( synPredMatched56 ) { match("hydrogenCount="); } else { boolean synPredMatched58 = false; if (((LA(1)=='<') && (LA(2)=='b'))) { int _m58 = mark(); synPredMatched58 = true; inputState.guessing++; try { { match(""); } } catch (RecognitionException pe) { synPredMatched58 = false; } rewind(_m58); inputState.guessing--; } if ( synPredMatched58 ) { match(""); } else { boolean synPredMatched60 = false; if (((LA(1)=='<') && (LA(2)=='/'))) { int _m60 = mark(); synPredMatched60 = true; inputState.guessing++; try { { match(""); } } catch (RecognitionException pe) { synPredMatched60 = false; } rewind(_m60); inputState.guessing--; } if ( synPredMatched60 ) { match(""); } else { boolean synPredMatched62 = false; if (((LA(1)=='<') && (LA(2)=='b'))) { int _m62 = mark(); synPredMatched62 = true; inputState.guessing++; try { { match("=1 ) { break _loop73; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } } _cnt73++; } while (true); } if ( inputState.guessing==0 ) { _ttype = Token.SKIP; } if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } public final void mSL_COMMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = SL_COMMENT; int _saveIndex; match("//"); { _loop77: do { if ((_tokenSet_2.member(LA(1)))) { { match(_tokenSet_2); } } else { break _loop77; } } while (true); } { switch ( LA(1)) { case '\n': { match('\n'); break; } case '\r': { match('\r'); { if ((LA(1)=='\n')) { match('\n'); } else { } } break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } if ( inputState.guessing==0 ) { _ttype = Token.SKIP; newline(); } if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } public final void mML_COMMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = ML_COMMENT; int _saveIndex; match("/*"); { _loop83: do { if (((LA(1)=='*') && ((LA(2) >= '\u0003' && LA(2) <= '\uffff')))&&( LA(2)!='/' )) { match('*'); } else if ((LA(1)=='\r') && (LA(2)=='\n')) { match('\r'); match('\n'); if ( inputState.guessing==0 ) { newline(); } } else if ((LA(1)=='\r') && ((LA(2) >= '\u0003' && LA(2) <= '\uffff'))) { match('\r'); if ( inputState.guessing==0 ) { newline(); } } else if ((LA(1)=='\n')) { match('\n'); if ( inputState.guessing==0 ) { newline(); } } else if ((_tokenSet_3.member(LA(1)))) { { match(_tokenSet_3); } } else { break _loop83; } } while (true); } match("*/"); if ( inputState.guessing==0 ) { _ttype = Token.SKIP; } if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } public final void mCHAR_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = CHAR_LITERAL; int _saveIndex; match('\''); { if ((LA(1)=='\\')) { mESC(false); } else if ((_tokenSet_4.member(LA(1)))) { matchNot('\''); } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } match('\''); if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } protected final void mESC(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = ESC; int _saveIndex; match('\\'); { switch ( LA(1)) { case 'n': { match('n'); break; } case 'r': { match('r'); break; } case 't': { match('t'); break; } case 'b': { match('b'); break; } case 'f': { match('f'); break; } case '"': { match('"'); break; } case '\'': { match('\''); break; } case '\\': { match('\\'); break; } case 'u': { { int _cnt93=0; _loop93: do { if ((LA(1)=='u')) { match('u'); } else { if ( _cnt93>=1 ) { break _loop93; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } _cnt93++; } while (true); } mHEX_DIGIT(false); mHEX_DIGIT(false); mHEX_DIGIT(false); mHEX_DIGIT(false); break; } case '0': case '1': case '2': case '3': { matchRange('0','3'); { if (((LA(1) >= '0' && LA(1) <= '7')) && ((LA(2) >= '\u0003' && LA(2) <= '\uffff'))) { matchRange('0','7'); { if (((LA(1) >= '0' && LA(1) <= '7')) && ((LA(2) >= '\u0003' && LA(2) <= '\uffff'))) { matchRange('0','7'); } else if (((LA(1) >= '\u0003' && LA(1) <= '\uffff')) && (true)) { } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } else if (((LA(1) >= '\u0003' && LA(1) <= '\uffff')) && (true)) { } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } break; } case '4': case '5': case '6': case '7': { matchRange('4','7'); { if (((LA(1) >= '0' && LA(1) <= '7')) && ((LA(2) >= '\u0003' && LA(2) <= '\uffff'))) { matchRange('0','7'); } else if (((LA(1) >= '\u0003' && LA(1) <= '\uffff')) && (true)) { } else { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } public final void mSTRING_LITERAL(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = STRING_LITERAL; int _saveIndex; match('"'); { _loop89: do { if ((LA(1)=='\\')) { mESC(false); } else if ((_tokenSet_5.member(LA(1)))) { { match(_tokenSet_5); } } else { break _loop89; } } while (true); } match('"'); if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } protected final void mHEX_DIGIT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = HEX_DIGIT; int _saveIndex; { switch ( LA(1)) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { matchRange('0','9'); break; } case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': { matchRange('A','F'); break; } case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': { matchRange('a','f'); break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } protected final void mVOCAB(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = VOCAB; int _saveIndex; matchRange('\3','\377'); if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } public final void mNUM_INT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = NUM_INT; int _saveIndex; Token f1=null; Token f2=null; Token f3=null; Token f4=null; boolean isDecimal=false; Token t=null; switch ( LA(1)) { case '.': { match('.'); if ( inputState.guessing==0 ) { _ttype = DOT; } { if (((LA(1) >= '0' && LA(1) <= '9'))) { { int _cnt103=0; _loop103: do { if (((LA(1) >= '0' && LA(1) <= '9'))) { matchRange('0','9'); } else { if ( _cnt103>=1 ) { break _loop103; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } _cnt103++; } while (true); } { if ((LA(1)=='E'||LA(1)=='e')) { mEXPONENT(false); } else { } } { if ((LA(1)=='D'||LA(1)=='F'||LA(1)=='d'||LA(1)=='f')) { mFLOAT_SUFFIX(true); f1=_returnToken; if ( inputState.guessing==0 ) { t=f1; } } else { } } if ( inputState.guessing==0 ) { if (t != null && t.getText().toUpperCase().indexOf('F')>=0) { _ttype = NUM_FLOAT; } else { _ttype = NUM_DOUBLE; // assume double } } } else { } } break; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { { switch ( LA(1)) { case '0': { match('0'); if ( inputState.guessing==0 ) { isDecimal = true; } { switch ( LA(1)) { case 'X': case 'x': { { switch ( LA(1)) { case 'x': { match('x'); break; } case 'X': { match('X'); break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } { int _cnt110=0; _loop110: do { if ((_tokenSet_6.member(LA(1))) && (true)) { mHEX_DIGIT(false); } else { if ( _cnt110>=1 ) { break _loop110; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } _cnt110++; } while (true); } break; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': { { int _cnt112=0; _loop112: do { if (((LA(1) >= '0' && LA(1) <= '7'))) { matchRange('0','7'); } else { if ( _cnt112>=1 ) { break _loop112; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } _cnt112++; } while (true); } break; } default: { } } } break; } case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { { matchRange('1','9'); } { _loop115: do { if (((LA(1) >= '0' && LA(1) <= '9'))) { matchRange('0','9'); } else { break _loop115; } } while (true); } if ( inputState.guessing==0 ) { isDecimal=true; } break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } { if ((LA(1)=='L'||LA(1)=='l')) { { switch ( LA(1)) { case 'l': { match('l'); break; } case 'L': { match('L'); break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } if ( inputState.guessing==0 ) { _ttype = NUM_LONG; } } else if (((LA(1)=='.'||LA(1)=='D'||LA(1)=='E'||LA(1)=='F'||LA(1)=='d'||LA(1)=='e'||LA(1)=='f'))&&(isDecimal)) { { switch ( LA(1)) { case '.': { match('.'); { _loop120: do { if (((LA(1) >= '0' && LA(1) <= '9'))) { matchRange('0','9'); } else { break _loop120; } } while (true); } { if ((LA(1)=='E'||LA(1)=='e')) { mEXPONENT(false); } else { } } { if ((LA(1)=='D'||LA(1)=='F'||LA(1)=='d'||LA(1)=='f')) { mFLOAT_SUFFIX(true); f2=_returnToken; if ( inputState.guessing==0 ) { t=f2; } } else { } } break; } case 'E': case 'e': { mEXPONENT(false); { if ((LA(1)=='D'||LA(1)=='F'||LA(1)=='d'||LA(1)=='f')) { mFLOAT_SUFFIX(true); f3=_returnToken; if ( inputState.guessing==0 ) { t=f3; } } else { } } break; } case 'D': case 'F': case 'd': case 'f': { mFLOAT_SUFFIX(true); f4=_returnToken; if ( inputState.guessing==0 ) { t=f4; } break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } if ( inputState.guessing==0 ) { if (t != null && t.getText().toUpperCase() .indexOf('F') >= 0) { _ttype = NUM_FLOAT; } else { _ttype = NUM_DOUBLE; // assume double } } } else { } } break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } protected final void mEXPONENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = EXPONENT; int _saveIndex; { switch ( LA(1)) { case 'e': { match('e'); break; } case 'E': { match('E'); break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } { switch ( LA(1)) { case '+': { match('+'); break; } case '-': { match('-'); break; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } } { int _cnt128=0; _loop128: do { if (((LA(1) >= '0' && LA(1) <= '9'))) { matchRange('0','9'); } else { if ( _cnt128>=1 ) { break _loop128; } else {throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn());} } _cnt128++; } while (true); } if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } protected final void mFLOAT_SUFFIX(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = FLOAT_SUFFIX; int _saveIndex; switch ( LA(1)) { case 'f': { match('f'); break; } case 'F': { match('F'); break; } case 'd': { match('d'); break; } case 'D': { match('D'); break; } default: { throw new NoViableAltForCharException((char)LA(1), getFilename(), getLine(), getColumn()); } } if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; } private static final long[] mk_tokenSet_0() { long[] data = new long[1025]; data[0]=5764748329242066944L; data[1]=576460745995190270L; return data; } public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); private static final long[] mk_tokenSet_1() { long[] data = new long[1025]; data[0]=68719476736L; data[1]=576460745995190270L; return data; } public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1()); private static final long[] mk_tokenSet_2() { long[] data = new long[2048]; data[0]=-9224L; for (int i = 1; i<=1023; i++) { data[i]=-1L; } return data; } public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2()); private static final long[] mk_tokenSet_3() { long[] data = new long[2048]; data[0]=-4398046520328L; for (int i = 1; i<=1023; i++) { data[i]=-1L; } return data; } public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3()); private static final long[] mk_tokenSet_4() { long[] data = new long[2048]; data[0]=-549755813896L; data[1]=-268435457L; for (int i = 2; i<=1023; i++) { data[i]=-1L; } return data; } public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4()); private static final long[] mk_tokenSet_5() { long[] data = new long[2048]; data[0]=-17179869192L; data[1]=-268435457L; for (int i = 2; i<=1023; i++) { data[i]=-1L; } return data; } public static final BitSet _tokenSet_5 = new BitSet(mk_tokenSet_5()); private static final long[] mk_tokenSet_6() { long[] data = new long[1025]; data[0]=287948901175001088L; data[1]=541165879422L; return data; } public static final BitSet _tokenSet_6 = new BitSet(mk_tokenSet_6()); }