// $ANTLR 3.1.1 test/Simple.g 2009-03-04 11:04:18 package test; import org.antlr.runtime.*; import java.util.Stack; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.util.HashMap; public class Simple extends Lexer { public static final int WORD=10; public static final int DOT_PRINT=6; public static final int DOT_SPP=8; public static final int DOT_ADD=7; public static final int DOT_SL=5; public static final int DOT_PROG=4; public static final int DOT=9; public static final int EOF=-1; // delegates // delegators public Simple() {;} public Simple(CharStream input) { this(input, new RecognizerSharedState()); } public Simple(CharStream input, RecognizerSharedState state) { super(input,state); } public String getGrammarFileName() { return "test/Simple.g"; } // $ANTLR start "DOT_PROG" public final void mDOT_PROG() throws RecognitionException { try { // test/Simple.g:13:18: () // test/Simple.g:13:20: { } } finally { } } // $ANTLR end "DOT_PROG" // $ANTLR start "DOT_SL" public final void mDOT_SL() throws RecognitionException { try { // test/Simple.g:14:16: () // test/Simple.g:14:18: { } } finally { } } // $ANTLR end "DOT_SL" // $ANTLR start "DOT_PRINT" public final void mDOT_PRINT() throws RecognitionException { try { // test/Simple.g:15:19: () // test/Simple.g:15:21: { } } finally { } } // $ANTLR end "DOT_PRINT" // $ANTLR start "DOT_ADD" public final void mDOT_ADD() throws RecognitionException { try { // test/Simple.g:16:17: () // test/Simple.g:16:19: { } } finally { } } // $ANTLR end "DOT_ADD" // $ANTLR start "DOT_SPP" public final void mDOT_SPP() throws RecognitionException { try { // test/Simple.g:17:17: () // test/Simple.g:17:19: { } } finally { } } // $ANTLR end "DOT_SPP" // $ANTLR start "DOT" public final void mDOT() throws RecognitionException { try { int _type = DOT; int _channel = DEFAULT_TOKEN_CHANNEL; // test/Simple.g:19:4: ( '.' ( ( 'PROG' )=> 'PROG' | ( 'SL' )=> 'SL' | ( 'PRT' )=> 'PRT' | ( 'SPP' )=> 'SPP' )? ) // test/Simple.g:19:6: '.' ( ( 'PROG' )=> 'PROG' | ( 'SL' )=> 'SL' | ( 'PRT' )=> 'PRT' | ( 'SPP' )=> 'SPP' )? { match('.'); if (state.failed) return ; // test/Simple.g:20:3: ( ( 'PROG' )=> 'PROG' | ( 'SL' )=> 'SL' | ( 'PRT' )=> 'PRT' | ( 'SPP' )=> 'SPP' )? int alt1=5; int LA1_0 = input.LA(1); if ( (LA1_0=='P') ) { int LA1_1 = input.LA(2); if ( (LA1_1=='R') ) { int LA1_4 = input.LA(3); if ( (LA1_4=='O') && (synpred1_Simple())) { alt1=1; } else if ( (LA1_4=='T') && (synpred3_Simple())) { alt1=3; } } } else if ( (LA1_0=='S') ) { int LA1_2 = input.LA(2); if ( (LA1_2=='L') && (synpred2_Simple())) { alt1=2; } else if ( (LA1_2=='P') && (synpred4_Simple())) { alt1=4; } } switch (alt1) { case 1 : // test/Simple.g:21:3: ( 'PROG' )=> 'PROG' { match("PROG"); if (state.failed) return ; if ( state.backtracking==0 ) { _type=DOT_PROG; } } break; case 2 : // test/Simple.g:22:4: ( 'SL' )=> 'SL' { match("SL"); if (state.failed) return ; if ( state.backtracking==0 ) { _type=DOT_SL; } } break; case 3 : // test/Simple.g:23:4: ( 'PRT' )=> 'PRT' { match("PRT"); if (state.failed) return ; if ( state.backtracking==0 ) { _type=DOT_PRINT; } } break; case 4 : // test/Simple.g:25:4: ( 'SPP' )=> 'SPP' { match("SPP"); if (state.failed) return ; if ( state.backtracking==0 ) { _type=DOT_SPP; } } break; } } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "DOT" // $ANTLR start "WORD" public final void mWORD() throws RecognitionException { try { int _type = WORD; int _channel = DEFAULT_TOKEN_CHANNEL; // test/Simple.g:29:5: ( ( 'A' .. 'Z' )+ ) // test/Simple.g:29:7: ( 'A' .. 'Z' )+ { // test/Simple.g:29:7: ( 'A' .. 'Z' )+ int cnt2=0; loop2: do { int alt2=2; int LA2_0 = input.LA(1); if ( ((LA2_0>='A' && LA2_0<='Z')) ) { alt2=1; } switch (alt2) { case 1 : // test/Simple.g:29:8: 'A' .. 'Z' { matchRange('A','Z'); if (state.failed) return ; } break; default : if ( cnt2 >= 1 ) break loop2; if (state.backtracking>0) {state.failed=true; return ;} EarlyExitException eee = new EarlyExitException(2, input); throw eee; } cnt2++; } while (true); } state.type = _type; state.channel = _channel; } finally { } } // $ANTLR end "WORD" public void mTokens() throws RecognitionException { // test/Simple.g:1:8: ( DOT | WORD ) int alt3=2; int LA3_0 = input.LA(1); if ( (LA3_0=='.') ) { alt3=1; } else if ( ((LA3_0>='A' && LA3_0<='Z')) ) { alt3=2; } else { if (state.backtracking>0) {state.failed=true; return ;} NoViableAltException nvae = new NoViableAltException("", 3, 0, input); throw nvae; } switch (alt3) { case 1 : // test/Simple.g:1:10: DOT { mDOT(); if (state.failed) return ; } break; case 2 : // test/Simple.g:1:14: WORD { mWORD(); if (state.failed) return ; } break; } } // $ANTLR start synpred1_Simple public final void synpred1_Simple_fragment() throws RecognitionException { // test/Simple.g:21:3: ( 'PROG' ) // test/Simple.g:21:4: 'PROG' { match("PROG"); if (state.failed) return ; } } // $ANTLR end synpred1_Simple // $ANTLR start synpred2_Simple public final void synpred2_Simple_fragment() throws RecognitionException { // test/Simple.g:22:4: ( 'SL' ) // test/Simple.g:22:5: 'SL' { match("SL"); if (state.failed) return ; } } // $ANTLR end synpred2_Simple // $ANTLR start synpred3_Simple public final void synpred3_Simple_fragment() throws RecognitionException { // test/Simple.g:23:4: ( 'PRT' ) // test/Simple.g:23:5: 'PRT' { match("PRT"); if (state.failed) return ; } } // $ANTLR end synpred3_Simple // $ANTLR start synpred4_Simple public final void synpred4_Simple_fragment() throws RecognitionException { // test/Simple.g:25:4: ( 'SPP' ) // test/Simple.g:25:5: 'SPP' { match("SPP"); if (state.failed) return ; } } // $ANTLR end synpred4_Simple public final boolean synpred4_Simple() { state.backtracking++; int start = input.mark(); try { synpred4_Simple_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } boolean success = !state.failed; input.rewind(start); state.backtracking--; state.failed=false; return success; } public final boolean synpred2_Simple() { state.backtracking++; int start = input.mark(); try { synpred2_Simple_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } boolean success = !state.failed; input.rewind(start); state.backtracking--; state.failed=false; return success; } public final boolean synpred1_Simple() { state.backtracking++; int start = input.mark(); try { synpred1_Simple_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } boolean success = !state.failed; input.rewind(start); state.backtracking--; state.failed=false; return success; } public final boolean synpred3_Simple() { state.backtracking++; int start = input.mark(); try { synpred3_Simple_fragment(); // can never throw exception } catch (RecognitionException re) { System.err.println("impossible: "+re); } boolean success = !state.failed; input.rewind(start); state.backtracking--; state.failed=false; return success; } }