// $ANTLR 3.2 Aug 13, 2010 14:19:31 SimpleC.g 2010-08-13 14:29:19 import org.antlr.runtime.*; import java.util.Stack; import java.util.List; import java.util.ArrayList; public class SimpleCLexer extends Lexer { public static final int LT=18; public static final int T__26=26; public static final int T__25=25; public static final int T__24=24; public static final int T__23=23; public static final int T__22=22; public static final int T__21=21; public static final int CHAR=15; public static final int FOR=13; public static final int FUNC_HDR=6; public static final int INT=12; public static final int FUNC_DEF=8; public static final int INT_TYPE=14; public static final int ID=10; public static final int EOF=-1; public static final int FUNC_DECL=7; public static final int ARG_DEF=5; public static final int WS=20; public static final int BLOCK=9; public static final int PLUS=19; public static final int VOID=16; public static final int EQ=11; public static final int VAR_DEF=4; public static final int EQEQ=17; // delegates // delegators public SimpleCLexer() {;} public SimpleCLexer(CharStream input) { this(input, new RecognizerSharedState()); } public SimpleCLexer(CharStream input, RecognizerSharedState state) { super(input,state); } public String getGrammarFileName() { return "SimpleC.g"; } // $ANTLR start "T__21" public final void mT__21() throws RecognitionException { try { int _type = T__21; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:7:7: ( ';' ) // SimpleC.g:7:9: ';' { match(';'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__21" // $ANTLR start "T__22" public final void mT__22() throws RecognitionException { try { int _type = T__22; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:8:7: ( '(' ) // SimpleC.g:8:9: '(' { match('('); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__22" // $ANTLR start "T__23" public final void mT__23() throws RecognitionException { try { int _type = T__23; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:9:7: ( ',' ) // SimpleC.g:9:9: ',' { match(','); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__23" // $ANTLR start "T__24" public final void mT__24() throws RecognitionException { try { int _type = T__24; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:10:7: ( ')' ) // SimpleC.g:10:9: ')' { match(')'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__24" // $ANTLR start "T__25" public final void mT__25() throws RecognitionException { try { int _type = T__25; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:11:7: ( '{' ) // SimpleC.g:11:9: '{' { match('{'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__25" // $ANTLR start "T__26" public final void mT__26() throws RecognitionException { try { int _type = T__26; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:12:7: ( '}' ) // SimpleC.g:12:9: '}' { match('}'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "T__26" // $ANTLR start "FOR" public final void mFOR() throws RecognitionException { try { int _type = FOR; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:91:5: ( 'for' ) // SimpleC.g:91:7: 'for' { match("for"); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "FOR" // $ANTLR start "INT_TYPE" public final void mINT_TYPE() throws RecognitionException { try { int _type = INT_TYPE; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:92:10: ( 'int' ) // SimpleC.g:92:12: 'int' { match("int"); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "INT_TYPE" // $ANTLR start "CHAR" public final void mCHAR() throws RecognitionException { try { int _type = CHAR; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:93:5: ( 'char' ) // SimpleC.g:93:7: 'char' { match("char"); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "CHAR" // $ANTLR start "VOID" public final void mVOID() throws RecognitionException { try { int _type = VOID; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:94:5: ( 'void' ) // SimpleC.g:94:7: 'void' { match("void"); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "VOID" // $ANTLR start "ID" public final void mID() throws RecognitionException { try { int _type = ID; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:96:5: ( ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )* ) // SimpleC.g:96:9: ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )* { if ( (input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse;} // SimpleC.g:96:33: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' )* loop1: do { int alt1=2; int LA1_0 = input.LA(1); if ( ((LA1_0>='0' && LA1_0<='9')||(LA1_0>='A' && LA1_0<='Z')||LA1_0=='_'||(LA1_0>='a' && LA1_0<='z')) ) { alt1=1; } switch (alt1) { case 1 : // SimpleC.g: { if ( (input.LA(1)>='0' && input.LA(1)<='9')||(input.LA(1)>='A' && input.LA(1)<='Z')||input.LA(1)=='_'||(input.LA(1)>='a' && input.LA(1)<='z') ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse;} } break; default : break loop1; } } while (true); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "ID" // $ANTLR start "INT" public final void mINT() throws RecognitionException { try { int _type = INT; int _channel = DEFAULT_TOKEN_CHANNEL; CommonToken int=null; List list_int=null; // SimpleC.g:99:5: ( (int+= ( '0' .. '9' ) )+ ) // SimpleC.g:99:7: (int+= ( '0' .. '9' ) )+ { // SimpleC.g:99:10: (int+= ( '0' .. '9' ) )+ int cnt2=0; loop2: do { int alt2=2; int LA2_0 = input.LA(1); if ( ((LA2_0>='0' && LA2_0<='9')) ) { alt2=1; } switch (alt2) { case 1 : // SimpleC.g:99:10: int+= ( '0' .. '9' ) { // SimpleC.g:99:12: ( '0' .. '9' ) // SimpleC.g:99:13: '0' .. '9' { matchRange('0','9'); } } break; default : if ( cnt2 >= 1 ) break loop2; EarlyExitException eee = new EarlyExitException(2, input); throw eee; } cnt2++; } while (true); NSLog(@"%@", list_int); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "INT" // $ANTLR start "EQ" public final void mEQ() throws RecognitionException { try { int _type = EQ; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:102:6: ( '=' ) // SimpleC.g:102:8: '=' { match('='); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "EQ" // $ANTLR start "EQEQ" public final void mEQEQ() throws RecognitionException { try { int _type = EQEQ; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:103:6: ( '==' ) // SimpleC.g:103:8: '==' { match("=="); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "EQEQ" // $ANTLR start "LT" public final void mLT() throws RecognitionException { try { int _type = LT; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:104:6: ( '<' ) // SimpleC.g:104:8: '<' { match('<'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "LT" // $ANTLR start "PLUS" public final void mPLUS() throws RecognitionException { try { int _type = PLUS; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:105:6: ( '+' ) // SimpleC.g:105:8: '+' { match('+'); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "PLUS" // $ANTLR start "WS" public final void mWS() throws RecognitionException { try { int _type = WS; int _channel = DEFAULT_TOKEN_CHANNEL; // SimpleC.g:107:5: ( ( ' ' | '\\t' | '\\r' | '\\n' )+ ) // SimpleC.g:107:9: ( ' ' | '\\t' | '\\r' | '\\n' )+ { // SimpleC.g:107:9: ( ' ' | '\\t' | '\\r' | '\\n' )+ int cnt3=0; loop3: do { int alt3=2; int LA3_0 = input.LA(1); if ( ((LA3_0>='\t' && LA3_0<='\n')||LA3_0=='\r'||LA3_0==' ') ) { alt3=1; } switch (alt3) { case 1 : // SimpleC.g: { if ( (input.LA(1)>='\t' && input.LA(1)<='\n')||input.LA(1)=='\r'||input.LA(1)==' ' ) { input.consume(); } else { MismatchedSetException mse = new MismatchedSetException(null,input); recover(mse); throw mse;} } break; default : if ( cnt3 >= 1 ) break loop3; EarlyExitException eee = new EarlyExitException(3, input); throw eee; } cnt3++; } while (true); _channel=99; } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "WS" public void mTokens() throws RecognitionException { // SimpleC.g:1:8: ( T__21 | T__22 | T__23 | T__24 | T__25 | T__26 | FOR | INT_TYPE | CHAR | VOID | ID | INT | EQ | EQEQ | LT | PLUS | WS ) int alt4=17; alt4 = dfa4.predict(input); switch (alt4) { case 1 : // SimpleC.g:1:10: T__21 { mT__21(); } break; case 2 : // SimpleC.g:1:16: T__22 { mT__22(); } break; case 3 : // SimpleC.g:1:22: T__23 { mT__23(); } break; case 4 : // SimpleC.g:1:28: T__24 { mT__24(); } break; case 5 : // SimpleC.g:1:34: T__25 { mT__25(); } break; case 6 : // SimpleC.g:1:40: T__26 { mT__26(); } break; case 7 : // SimpleC.g:1:46: FOR { mFOR(); } break; case 8 : // SimpleC.g:1:50: INT_TYPE { mINT_TYPE(); } break; case 9 : // SimpleC.g:1:59: CHAR { mCHAR(); } break; case 10 : // SimpleC.g:1:64: VOID { mVOID(); } break; case 11 : // SimpleC.g:1:69: ID { mID(); } break; case 12 : // SimpleC.g:1:72: INT { mINT(); } break; case 13 : // SimpleC.g:1:76: EQ { mEQ(); } break; case 14 : // SimpleC.g:1:79: EQEQ { mEQEQ(); } break; case 15 : // SimpleC.g:1:84: LT { mLT(); } break; case 16 : // SimpleC.g:1:87: PLUS { mPLUS(); } break; case 17 : // SimpleC.g:1:92: WS { mWS(); } break; } } protected DFA4 dfa4 = new DFA4(this); static final String DFA4_eotS = "\7\uffff\4\13\2\uffff\1\26\3\uffff\4\13\2\uffff\1\33\1\34\2\13\2"+ "\uffff\1\37\1\40\2\uffff"; static final String DFA4_eofS = "\41\uffff"; static final String DFA4_minS = "\1\11\6\uffff\1\157\1\156\1\150\1\157\2\uffff\1\75\3\uffff\1\162"+ "\1\164\1\141\1\151\2\uffff\2\60\1\162\1\144\2\uffff\2\60\2\uffff"; static final String DFA4_maxS = "\1\175\6\uffff\1\157\1\156\1\150\1\157\2\uffff\1\75\3\uffff\1\162"+ "\1\164\1\141\1\151\2\uffff\2\172\1\162\1\144\2\uffff\2\172\2\uffff"; static final String DFA4_acceptS = "\1\uffff\1\1\1\2\1\3\1\4\1\5\1\6\4\uffff\1\13\1\14\1\uffff\1\17"+ "\1\20\1\21\4\uffff\1\16\1\15\4\uffff\1\7\1\10\2\uffff\1\11\1\12"; static final String DFA4_specialS = "\41\uffff}>"; static final String[] DFA4_transitionS = { "\2\20\2\uffff\1\20\22\uffff\1\20\7\uffff\1\2\1\4\1\uffff\1\17"+ "\1\3\3\uffff\12\14\1\uffff\1\1\1\16\1\15\3\uffff\32\13\4\uffff"+ "\1\13\1\uffff\2\13\1\11\2\13\1\7\2\13\1\10\14\13\1\12\4\13\1"+ "\5\1\uffff\1\6", "", "", "", "", "", "", "\1\21", "\1\22", "\1\23", "\1\24", "", "", "\1\25", "", "", "", "\1\27", "\1\30", "\1\31", "\1\32", "", "", "\12\13\7\uffff\32\13\4\uffff\1\13\1\uffff\32\13", "\12\13\7\uffff\32\13\4\uffff\1\13\1\uffff\32\13", "\1\35", "\1\36", "", "", "\12\13\7\uffff\32\13\4\uffff\1\13\1\uffff\32\13", "\12\13\7\uffff\32\13\4\uffff\1\13\1\uffff\32\13", "", "" }; static final short[] DFA4_eot = DFA.unpackEncodedString(DFA4_eotS); static final short[] DFA4_eof = DFA.unpackEncodedString(DFA4_eofS); static final char[] DFA4_min = DFA.unpackEncodedStringToUnsignedChars(DFA4_minS); static final char[] DFA4_max = DFA.unpackEncodedStringToUnsignedChars(DFA4_maxS); static final short[] DFA4_accept = DFA.unpackEncodedString(DFA4_acceptS); static final short[] DFA4_special = DFA.unpackEncodedString(DFA4_specialS); static final short[][] DFA4_transition; static { int numStates = DFA4_transitionS.length; DFA4_transition = new short[numStates][]; for (int i=0; i<numStates; i++) { DFA4_transition[i] = DFA.unpackEncodedString(DFA4_transitionS[i]); } } class DFA4 extends DFA { public DFA4(BaseRecognizer recognizer) { this.recognizer = recognizer; this.decisionNumber = 4; this.eot = DFA4_eot; this.eof = DFA4_eof; this.min = DFA4_min; this.max = DFA4_max; this.accept = DFA4_accept; this.special = DFA4_special; this.transition = DFA4_transition; } public String getDescription() { return "1:1: Tokens : ( T__21 | T__22 | T__23 | T__24 | T__25 | T__26 | FOR | INT_TYPE | CHAR | VOID | ID | INT | EQ | EQEQ | LT | PLUS | WS );"; } } }