[antlr-interest] newbie question about nondeterminism warning
Stefan Schmidt
schmidtitc at gmail.com
Tue Apr 4 18:38:01 PDT 2006
Hi folks,
I have posted this message to the jGuru forum last week but noone answered
so I'll try it here :-)
I am VERY new to antlr. Part of my current work is to extend an existing
antlr file by some additional functionality.
Ok, here is what I would like to do:
integrate a function like this: (a*x) + (b*y) - z
where x,y,z are REAL numbers (could be negative) and a,b are variables.
Basically a linear function. The (a*x) or (b*y) or z can be repeated *
times.
Here is the code (extract) I am trying:
line 193: ts_function : ts_function_items | (PLUS^|MINUS^)
(PLUS^|MINUS^)?REAL SEMICOLON!;
line 194: ts_function_items : ts_function_item ((PLUS^|MINUS^)
ts_function_item)* ;
line 195: ts_function_item : LEFT_PARENTHESIS! ID (MUL^|DIV^)
(PLUS|MINUS)?REAL RIGHT_PARENTHESIS!;
When I compile this I get the following warning:
ANTLR Parser Generator Version 2.7.5 (20050128) 1989-2005 jGuru.com
fcl/fcl.g:194: warning:nondeterminism upon
fcl/fcl.g:194: k==1:MINUS,PLUS
fcl/fcl.g:194: between alt 1 and exit branch of block
When I replace the 'offending' (PLUS^|MINUS^) with (MUL^|DIV^) it compiles,
but that's obviously not what I want.
I have taken this example from the Expression Evaluation Example at
http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/antlr/antlr.html
Can anyone help me out here?
Thanks!
Regards,
Stefan Schmidt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060405/1c6a8da5/attachment.html
More information about the antlr-interest
mailing list