SimpleDeclarativeParser.java
No OneTemporary

File Metadata

Created
Sun, Apr 19, 5:07 AM

SimpleDeclarativeParser.java

// $ANTLR 3.3 Nov 30, 2010 12:45:30 /prg/code/xreate/antlr/SimpleDeclarative.g 2011-06-28 19:34:29
import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import org.antlr.runtime.debug.*;
import java.io.IOException;
public class SimpleDeclarativeParser extends DebugParser {
public static final String[] tokenNames = new String[] {
"<invalid>", "<EOR>", "<DOWN>", "<UP>", "BRACESTART", "BRACEEND", "COMMA", "COLON", "OR", "LET", "WHERE", "EQUAL", "WORD", "NUMBER", "SEMICOLON", "DIGIT", "LETTER", "WHITESPACE"
};
public static final int EOF=-1;
public static final int BRACESTART=4;
public static final int BRACEEND=5;
public static final int COMMA=6;
public static final int COLON=7;
public static final int OR=8;
public static final int LET=9;
public static final int WHERE=10;
public static final int EQUAL=11;
public static final int WORD=12;
public static final int NUMBER=13;
public static final int SEMICOLON=14;
public static final int DIGIT=15;
public static final int LETTER=16;
public static final int WHITESPACE=17;
// delegates
// delegators
public static final String[] ruleNames = new String[] {
"invalidRule", "expression", "equation", "set_member", "set", "synpred2_SimpleDeclarative",
"atom", "synpred1_SimpleDeclarative"
};
public static final boolean[] decisionCanBacktrack = new boolean[] {
false, // invalid decision
false, false, false, true, false, false, false
};
public int ruleLevel = 0;
public int getRuleLevel() { return ruleLevel; }
public void incRuleLevel() { ruleLevel++; }
public void decRuleLevel() { ruleLevel--; }
public SimpleDeclarativeParser(TokenStream input) {
this(input, DebugEventSocketProxy.DEFAULT_DEBUGGER_PORT, new RecognizerSharedState());
}
public SimpleDeclarativeParser(TokenStream input, int port, RecognizerSharedState state) {
super(input, state);
DebugEventSocketProxy proxy =
new DebugEventSocketProxy(this, port, null);
setDebugListener(proxy);
try {
proxy.handshake();
}
catch (IOException ioe) {
reportError(ioe);
}
}
public SimpleDeclarativeParser(TokenStream input, DebugEventListener dbg) {
super(input, dbg, new RecognizerSharedState());
}
protected boolean evalPredicate(boolean result, String predicate) {
dbg.semanticPredicate(result, predicate);
return result;
}
public String[] getTokenNames() { return SimpleDeclarativeParser.tokenNames; }
public String getGrammarFileName() { return "/prg/code/xreate/antlr/SimpleDeclarative.g"; }
// $ANTLR start "set"
// /prg/code/xreate/antlr/SimpleDeclarative.g:4:1: set : ( BRACESTART BRACEEND | '{' set_member ( COMMA set_member )* BRACEEND );
public final void set() throws RecognitionException {
try { dbg.enterRule(getGrammarFileName(), "set");
if ( getRuleLevel()==0 ) {dbg.commence();}
incRuleLevel();
dbg.location(4, 1);
try {
// /prg/code/xreate/antlr/SimpleDeclarative.g:4:6: ( BRACESTART BRACEEND | '{' set_member ( COMMA set_member )* BRACEEND )
int alt2=2;
try { dbg.enterDecision(2, decisionCanBacktrack[2]);
int LA2_0 = input.LA(1);
if ( (LA2_0==BRACESTART) ) {
int LA2_1 = input.LA(2);
if ( (LA2_1==BRACEEND) ) {
alt2=1;
}
else if ( (LA2_1==BRACESTART||LA2_1==LET||(LA2_1>=WORD && LA2_1<=NUMBER)) ) {
alt2=2;
}
else {
if (state.backtracking>0) {state.failed=true; return ;}
NoViableAltException nvae =
new NoViableAltException("", 2, 1, input);
dbg.recognitionException(nvae);
throw nvae;
}
}
else {
if (state.backtracking>0) {state.failed=true; return ;}
NoViableAltException nvae =
new NoViableAltException("", 2, 0, input);
dbg.recognitionException(nvae);
throw nvae;
}
} finally {dbg.exitDecision(2);}
switch (alt2) {
case 1 :
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:4:8: BRACESTART BRACEEND
{
dbg.location(4,8);
match(input,BRACESTART,FOLLOW_BRACESTART_in_set12); if (state.failed) return ;
dbg.location(4,19);
match(input,BRACEEND,FOLLOW_BRACEEND_in_set14); if (state.failed) return ;
}
break;
case 2 :
dbg.enterAlt(2);
// /prg/code/xreate/antlr/SimpleDeclarative.g:4:30: '{' set_member ( COMMA set_member )* BRACEEND
{
dbg.location(4,30);
match(input,BRACESTART,FOLLOW_BRACESTART_in_set18); if (state.failed) return ;
dbg.location(4,34);
pushFollow(FOLLOW_set_member_in_set20);
set_member();
state._fsp--;
if (state.failed) return ;
dbg.location(4,45);
// /prg/code/xreate/antlr/SimpleDeclarative.g:4:45: ( COMMA set_member )*
try { dbg.enterSubRule(1);
loop1:
do {
int alt1=2;
try { dbg.enterDecision(1, decisionCanBacktrack[1]);
int LA1_0 = input.LA(1);
if ( (LA1_0==COMMA) ) {
alt1=1;
}
} finally {dbg.exitDecision(1);}
switch (alt1) {
case 1 :
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:4:46: COMMA set_member
{
dbg.location(4,46);
match(input,COMMA,FOLLOW_COMMA_in_set23); if (state.failed) return ;
dbg.location(4,53);
pushFollow(FOLLOW_set_member_in_set26);
set_member();
state._fsp--;
if (state.failed) return ;
}
break;
default :
break loop1;
}
} while (true);
} finally {dbg.exitSubRule(1);}
dbg.location(4,66);
match(input,BRACEEND,FOLLOW_BRACEEND_in_set30); if (state.failed) return ;
}
break;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
}
dbg.location(4, 74);
}
finally {
dbg.exitRule(getGrammarFileName(), "set");
decRuleLevel();
if ( getRuleLevel()==0 ) {dbg.terminate();}
}
return ;
}
// $ANTLR end "set"
// $ANTLR start "set_member"
// /prg/code/xreate/antlr/SimpleDeclarative.g:5:1: set_member : ( ( atom COLON )=> atom COLON expression ( OR expression )* | ( expression EQUAL )=> equation | expression );
public final void set_member() throws RecognitionException {
try { dbg.enterRule(getGrammarFileName(), "set_member");
if ( getRuleLevel()==0 ) {dbg.commence();}
incRuleLevel();
dbg.location(5, 1);
try {
// /prg/code/xreate/antlr/SimpleDeclarative.g:5:11: ( ( atom COLON )=> atom COLON expression ( OR expression )* | ( expression EQUAL )=> equation | expression )
int alt4=3;
try { dbg.enterDecision(4, decisionCanBacktrack[4]);
switch ( input.LA(1) ) {
case WORD:
case NUMBER:
{
int LA4_1 = input.LA(2);
if ( (synpred1_SimpleDeclarative()) ) {
alt4=1;
}
else if ( (synpred2_SimpleDeclarative()) ) {
alt4=2;
}
else if ( (true) ) {
alt4=3;
}
else {
if (state.backtracking>0) {state.failed=true; return ;}
NoViableAltException nvae =
new NoViableAltException("", 4, 1, input);
dbg.recognitionException(nvae);
throw nvae;
}
}
break;
case LET:
{
int LA4_2 = input.LA(2);
if ( (synpred2_SimpleDeclarative()) ) {
alt4=2;
}
else if ( (true) ) {
alt4=3;
}
else {
if (state.backtracking>0) {state.failed=true; return ;}
NoViableAltException nvae =
new NoViableAltException("", 4, 2, input);
dbg.recognitionException(nvae);
throw nvae;
}
}
break;
case BRACESTART:
{
int LA4_3 = input.LA(2);
if ( (synpred2_SimpleDeclarative()) ) {
alt4=2;
}
else if ( (true) ) {
alt4=3;
}
else {
if (state.backtracking>0) {state.failed=true; return ;}
NoViableAltException nvae =
new NoViableAltException("", 4, 3, input);
dbg.recognitionException(nvae);
throw nvae;
}
}
break;
default:
if (state.backtracking>0) {state.failed=true; return ;}
NoViableAltException nvae =
new NoViableAltException("", 4, 0, input);
dbg.recognitionException(nvae);
throw nvae;
}
} finally {dbg.exitDecision(4);}
switch (alt4) {
case 1 :
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:5:13: ( atom COLON )=> atom COLON expression ( OR expression )*
{
dbg.location(5,28);
pushFollow(FOLLOW_atom_in_set_member43);
atom();
state._fsp--;
if (state.failed) return ;
dbg.location(5,33);
match(input,COLON,FOLLOW_COLON_in_set_member45); if (state.failed) return ;
dbg.location(5,39);
pushFollow(FOLLOW_expression_in_set_member47);
expression();
state._fsp--;
if (state.failed) return ;
dbg.location(5,50);
// /prg/code/xreate/antlr/SimpleDeclarative.g:5:50: ( OR expression )*
try { dbg.enterSubRule(3);
loop3:
do {
int alt3=2;
try { dbg.enterDecision(3, decisionCanBacktrack[3]);
int LA3_0 = input.LA(1);
if ( (LA3_0==OR) ) {
alt3=1;
}
} finally {dbg.exitDecision(3);}
switch (alt3) {
case 1 :
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:5:51: OR expression
{
dbg.location(5,51);
match(input,OR,FOLLOW_OR_in_set_member50); if (state.failed) return ;
dbg.location(5,54);
pushFollow(FOLLOW_expression_in_set_member52);
expression();
state._fsp--;
if (state.failed) return ;
}
break;
default :
break loop3;
}
} while (true);
} finally {dbg.exitSubRule(3);}
}
break;
case 2 :
dbg.enterAlt(2);
// /prg/code/xreate/antlr/SimpleDeclarative.g:5:69: ( expression EQUAL )=> equation
{
dbg.location(5,90);
pushFollow(FOLLOW_equation_in_set_member65);
equation();
state._fsp--;
if (state.failed) return ;
}
break;
case 3 :
dbg.enterAlt(3);
// /prg/code/xreate/antlr/SimpleDeclarative.g:5:101: expression
{
dbg.location(5,101);
pushFollow(FOLLOW_expression_in_set_member69);
expression();
state._fsp--;
if (state.failed) return ;
}
break;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
}
dbg.location(5, 111);
}
finally {
dbg.exitRule(getGrammarFileName(), "set_member");
decRuleLevel();
if ( getRuleLevel()==0 ) {dbg.terminate();}
}
return ;
}
// $ANTLR end "set_member"
// $ANTLR start "expression"
// /prg/code/xreate/antlr/SimpleDeclarative.g:8:1: expression : ( LET set )? ( atom | set ) ( WHERE set )? ;
public final void expression() throws RecognitionException {
try { dbg.enterRule(getGrammarFileName(), "expression");
if ( getRuleLevel()==0 ) {dbg.commence();}
incRuleLevel();
dbg.location(8, 1);
try {
// /prg/code/xreate/antlr/SimpleDeclarative.g:9:2: ( ( LET set )? ( atom | set ) ( WHERE set )? )
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:9:4: ( LET set )? ( atom | set ) ( WHERE set )?
{
dbg.location(9,4);
// /prg/code/xreate/antlr/SimpleDeclarative.g:9:4: ( LET set )?
int alt5=2;
try { dbg.enterSubRule(5);
try { dbg.enterDecision(5, decisionCanBacktrack[5]);
int LA5_0 = input.LA(1);
if ( (LA5_0==LET) ) {
alt5=1;
}
} finally {dbg.exitDecision(5);}
switch (alt5) {
case 1 :
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:9:5: LET set
{
dbg.location(9,5);
match(input,LET,FOLLOW_LET_in_expression80); if (state.failed) return ;
dbg.location(9,9);
pushFollow(FOLLOW_set_in_expression82);
set();
state._fsp--;
if (state.failed) return ;
}
break;
}
} finally {dbg.exitSubRule(5);}
dbg.location(9,15);
// /prg/code/xreate/antlr/SimpleDeclarative.g:9:15: ( atom | set )
int alt6=2;
try { dbg.enterSubRule(6);
try { dbg.enterDecision(6, decisionCanBacktrack[6]);
int LA6_0 = input.LA(1);
if ( ((LA6_0>=WORD && LA6_0<=NUMBER)) ) {
alt6=1;
}
else if ( (LA6_0==BRACESTART) ) {
alt6=2;
}
else {
if (state.backtracking>0) {state.failed=true; return ;}
NoViableAltException nvae =
new NoViableAltException("", 6, 0, input);
dbg.recognitionException(nvae);
throw nvae;
}
} finally {dbg.exitDecision(6);}
switch (alt6) {
case 1 :
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:9:16: atom
{
dbg.location(9,16);
pushFollow(FOLLOW_atom_in_expression87);
atom();
state._fsp--;
if (state.failed) return ;
}
break;
case 2 :
dbg.enterAlt(2);
// /prg/code/xreate/antlr/SimpleDeclarative.g:9:23: set
{
dbg.location(9,23);
pushFollow(FOLLOW_set_in_expression91);
set();
state._fsp--;
if (state.failed) return ;
}
break;
}
} finally {dbg.exitSubRule(6);}
dbg.location(9,28);
// /prg/code/xreate/antlr/SimpleDeclarative.g:9:28: ( WHERE set )?
int alt7=2;
try { dbg.enterSubRule(7);
try { dbg.enterDecision(7, decisionCanBacktrack[7]);
int LA7_0 = input.LA(1);
if ( (LA7_0==WHERE) ) {
alt7=1;
}
} finally {dbg.exitDecision(7);}
switch (alt7) {
case 1 :
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:9:29: WHERE set
{
dbg.location(9,29);
match(input,WHERE,FOLLOW_WHERE_in_expression95); if (state.failed) return ;
dbg.location(9,35);
pushFollow(FOLLOW_set_in_expression97);
set();
state._fsp--;
if (state.failed) return ;
}
break;
}
} finally {dbg.exitSubRule(7);}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
}
dbg.location(9, 40);
}
finally {
dbg.exitRule(getGrammarFileName(), "expression");
decRuleLevel();
if ( getRuleLevel()==0 ) {dbg.terminate();}
}
return ;
}
// $ANTLR end "expression"
// $ANTLR start "equation"
// /prg/code/xreate/antlr/SimpleDeclarative.g:11:1: equation : expression EQUAL expression ;
public final void equation() throws RecognitionException {
try { dbg.enterRule(getGrammarFileName(), "equation");
if ( getRuleLevel()==0 ) {dbg.commence();}
incRuleLevel();
dbg.location(11, 1);
try {
// /prg/code/xreate/antlr/SimpleDeclarative.g:11:10: ( expression EQUAL expression )
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:11:12: expression EQUAL expression
{
dbg.location(11,12);
pushFollow(FOLLOW_expression_in_equation108);
expression();
state._fsp--;
if (state.failed) return ;
dbg.location(11,23);
match(input,EQUAL,FOLLOW_EQUAL_in_equation110); if (state.failed) return ;
dbg.location(11,29);
pushFollow(FOLLOW_expression_in_equation112);
expression();
state._fsp--;
if (state.failed) return ;
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
}
dbg.location(11, 39);
}
finally {
dbg.exitRule(getGrammarFileName(), "equation");
decRuleLevel();
if ( getRuleLevel()==0 ) {dbg.terminate();}
}
return ;
}
// $ANTLR end "equation"
// $ANTLR start "atom"
// /prg/code/xreate/antlr/SimpleDeclarative.g:13:1: atom : ( WORD | NUMBER );
public final void atom() throws RecognitionException {
try { dbg.enterRule(getGrammarFileName(), "atom");
if ( getRuleLevel()==0 ) {dbg.commence();}
incRuleLevel();
dbg.location(13, 1);
try {
// /prg/code/xreate/antlr/SimpleDeclarative.g:13:6: ( WORD | NUMBER )
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:
{
dbg.location(13,6);
if ( (input.LA(1)>=WORD && input.LA(1)<=NUMBER) ) {
input.consume();
state.errorRecovery=false;state.failed=false;
}
else {
if (state.backtracking>0) {state.failed=true; return ;}
MismatchedSetException mse = new MismatchedSetException(null,input);
dbg.recognitionException(mse);
throw mse;
}
}
}
catch (RecognitionException re) {
reportError(re);
recover(input,re);
}
finally {
}
dbg.location(13, 21);
}
finally {
dbg.exitRule(getGrammarFileName(), "atom");
decRuleLevel();
if ( getRuleLevel()==0 ) {dbg.terminate();}
}
return ;
}
// $ANTLR end "atom"
// $ANTLR start synpred1_SimpleDeclarative
public final void synpred1_SimpleDeclarative_fragment() throws RecognitionException {
// /prg/code/xreate/antlr/SimpleDeclarative.g:5:13: ( atom COLON )
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:5:14: atom COLON
{
dbg.location(5,14);
pushFollow(FOLLOW_atom_in_synpred1_SimpleDeclarative37);
atom();
state._fsp--;
if (state.failed) return ;
dbg.location(5,19);
match(input,COLON,FOLLOW_COLON_in_synpred1_SimpleDeclarative39); if (state.failed) return ;
}
}
// $ANTLR end synpred1_SimpleDeclarative
// $ANTLR start synpred2_SimpleDeclarative
public final void synpred2_SimpleDeclarative_fragment() throws RecognitionException {
// /prg/code/xreate/antlr/SimpleDeclarative.g:5:69: ( expression EQUAL )
dbg.enterAlt(1);
// /prg/code/xreate/antlr/SimpleDeclarative.g:5:70: expression EQUAL
{
dbg.location(5,70);
pushFollow(FOLLOW_expression_in_synpred2_SimpleDeclarative59);
expression();
state._fsp--;
if (state.failed) return ;
dbg.location(5,81);
match(input,EQUAL,FOLLOW_EQUAL_in_synpred2_SimpleDeclarative61); if (state.failed) return ;
}
}
// $ANTLR end synpred2_SimpleDeclarative
// Delegated rules
public final boolean synpred2_SimpleDeclarative() {
state.backtracking++;
dbg.beginBacktrack(state.backtracking);
int start = input.mark();
try {
synpred2_SimpleDeclarative_fragment(); // can never throw exception
} catch (RecognitionException re) {
System.err.println("impossible: "+re);
}
boolean success = !state.failed;
input.rewind(start);
dbg.endBacktrack(state.backtracking, success);
state.backtracking--;
state.failed=false;
return success;
}
public final boolean synpred1_SimpleDeclarative() {
state.backtracking++;
dbg.beginBacktrack(state.backtracking);
int start = input.mark();
try {
synpred1_SimpleDeclarative_fragment(); // can never throw exception
} catch (RecognitionException re) {
System.err.println("impossible: "+re);
}
boolean success = !state.failed;
input.rewind(start);
dbg.endBacktrack(state.backtracking, success);
state.backtracking--;
state.failed=false;
return success;
}
public static final BitSet FOLLOW_BRACESTART_in_set12 = new BitSet(new long[]{0x0000000000000020L});
public static final BitSet FOLLOW_BRACEEND_in_set14 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_BRACESTART_in_set18 = new BitSet(new long[]{0x0000000000003210L});
public static final BitSet FOLLOW_set_member_in_set20 = new BitSet(new long[]{0x0000000000000060L});
public static final BitSet FOLLOW_COMMA_in_set23 = new BitSet(new long[]{0x0000000000003210L});
public static final BitSet FOLLOW_set_member_in_set26 = new BitSet(new long[]{0x0000000000000060L});
public static final BitSet FOLLOW_BRACEEND_in_set30 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_atom_in_set_member43 = new BitSet(new long[]{0x0000000000000080L});
public static final BitSet FOLLOW_COLON_in_set_member45 = new BitSet(new long[]{0x0000000000003210L});
public static final BitSet FOLLOW_expression_in_set_member47 = new BitSet(new long[]{0x0000000000000102L});
public static final BitSet FOLLOW_OR_in_set_member50 = new BitSet(new long[]{0x0000000000003210L});
public static final BitSet FOLLOW_expression_in_set_member52 = new BitSet(new long[]{0x0000000000000102L});
public static final BitSet FOLLOW_equation_in_set_member65 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_expression_in_set_member69 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_LET_in_expression80 = new BitSet(new long[]{0x0000000000003210L});
public static final BitSet FOLLOW_set_in_expression82 = new BitSet(new long[]{0x0000000000003210L});
public static final BitSet FOLLOW_atom_in_expression87 = new BitSet(new long[]{0x0000000000000402L});
public static final BitSet FOLLOW_set_in_expression91 = new BitSet(new long[]{0x0000000000000402L});
public static final BitSet FOLLOW_WHERE_in_expression95 = new BitSet(new long[]{0x0000000000003210L});
public static final BitSet FOLLOW_set_in_expression97 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_expression_in_equation108 = new BitSet(new long[]{0x0000000000000800L});
public static final BitSet FOLLOW_EQUAL_in_equation110 = new BitSet(new long[]{0x0000000000003210L});
public static final BitSet FOLLOW_expression_in_equation112 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_set_in_atom0 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_atom_in_synpred1_SimpleDeclarative37 = new BitSet(new long[]{0x0000000000000080L});
public static final BitSet FOLLOW_COLON_in_synpred1_SimpleDeclarative39 = new BitSet(new long[]{0x0000000000000002L});
public static final BitSet FOLLOW_expression_in_synpred2_SimpleDeclarative59 = new BitSet(new long[]{0x0000000000000800L});
public static final BitSet FOLLOW_EQUAL_in_synpred2_SimpleDeclarative61 = new BitSet(new long[]{0x0000000000000002L});
}

Event Timeline