[antlr-interest] Re: pls help with Non-determinism error!
William Lam
xeenman at yahoo.com
Tue Mar 25 19:57:02 PST 2003
Change
productions : (production)+; //line 78
to
productions : production
--- In antlr-interest at yahoogroups.com, Sharon Li <hushlee83 at y...>
wrote:
>
> Hi can someone pls help me with this non-determinism error coz Im
really stuck! :P Thanks!
>
> class LParser extends Parser;
>
> options { k=2; }
>
> number returns [String num=""]
> : (MINUS {num = "-";})? ((n:NUMERIC {num += n.getText();})
> | (d:DIGIT {num += d.getText();}))
> ;
>
> word returns [String word=""]
> : ((name:NAME {word = name.getText();})
> | (a:ALPHA {word = a.getText();}))
> ;
>
> digit_or_alpha returns [String result="";]
> : (d:DIGIT {result = d.getText();}) | (a:ALPHA {result=a.getText
();})
> ;
>
> symbol returns [String sym] {sym = null;}
> : ((sym = digit_or_alpha)
> | (DOT {sym=".";}) | (COMMA {sym=",";})| (SEMI {sym=";";}) |
(PLUS {sym="+";}) | (MINUS{sym="-";})
> | (NOT{sym="!";}) | (DIVIDE{sym="/";}) | (POW{sym="^";}) | (MOD
{sym="%";})
> | (AND{sym="&";}) | (DRAW {sym="@";}) | (HEX {sym="#";}) |
(QUESTION{sym="?";})
> | (UNDERSCORE{sym="_";}) | (ASSIGN{sym="=";}) | (OR{sym="|";}) |
(NEG{sym="~";})
> | (LBRACK{sym="[";}) | (RBRACK{sym="]";})
> | (LBRACE{sym="{";}) | (RBRACE{sym="}";})
> | (DOLLAR{sym="$";}))
> ;
>
> formalModule returns [FormalModule fm = null] {String fsymbol="";
ArrayList paramList = null;}
> : (fsymbol = symbol) (LPAREN (paramList=formalParameters)
RPAREN)?
> ;
>
> formalModules returns [ArrayList fmList = new ArrayList()]
{FormalModule fm = null;}
> : (fm = formalModule {fmList.add(fm);})+ //line 67
> ;
>
> formalParameter returns [String formalParam=""]
> : formalParam = word
> ;
>
> formalParameters returns [ArrayList params=new ArrayList()] {String
fp=""; String temp="";}
> : (fp = formalParameter {params.add(fp);}) ((COMMA) ((temp =
formalParameter){params.add(temp);}))*
> ;
>
> productions : (production)+; //line 78
>
> production : strictPred ;
>
> strictPred {ArrayList fms = null;}
> : fms = formalModules ;
>
>
>
> class LLexer extends Lexer;
>
> options{
> charVocabulary='\0'..'\377';
> k = 2;
> }
>
> ALPHA : ( 'a'..'z' | 'A'..'Z' );
>
> DIGIT : ('0'..'9')
> ;
>
> NUMERIC : ((DIGIT)+ ('.'|'e'|'E'))=> (DIGIT)+ ('.' (DIGIT)*
(EXPONENT)? | EXPONENT)
> | (DIGIT) (DIGIT)+
> | '.' ((DIGIT)+ (EXPONENT)?)
> ;
>
> NAME : (ALPHA) (ALPHA|DIGIT|UNDERSCORE)+ ;
>
> protected EXPONENT : ('e'|'E') ('+'|'-')? (DIGIT)+ ;
>
> STRING_LITERAL : '"'! ('"' '"'! | ~('"'))* '"'!
> ;
>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list