[antlr-interest] help with ANTLRWorks and grammar error....

Lloyd Dupont ld at galador.net
Sat May 31 06:43:19 PDT 2008


Hi all, after a long break, I tried to do some ANTLR again.
I decided to add a new, original, expression type in my expression interpreter.
I named it the IFS expression and it goes like that 
'ifs' LPAREN (condExpr COMMA valExpr COMMA)+ defExpr RPAREN

where condExpr, valExpr, defExpr are just expression, but I give them a nice name to make them more meaningful.
condExp is a condition expression
valExpr is the value expression to return if the condition is true
defExpr is default value expression to return if all condition where false



Part 1.]
----------
anyway I added this rule in my parser and I got one of those mysterious error
==========
22:45:48] warning(200): ExpressionGrammar.g:188:72: Decision can match input such as "LPAREN" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
==========

I don't really see it can have multiple way of getting to this LPAREN, when there is a 'ifs' first it's always a IFS rule!!!, if there is no 'ifs' it's not an IFS rule! 
where is the ambiguity in that?

I even added a predicate:
( 'ifs' LPAREN )=> 'ifs' LPAREN ( expression COMMA expression COMMA )+ assign RPAREN -> ^( IFS ^(LIST expression + ))

but ANTLR keep stubbornly fail, any clue?




Part 2.]
-----------
Then I decided to look at the "Syntax Diagram" in ANTLR Works (the attached image).
Well I realised, quite frustratingly, that I had no clue whatsoever about the meaning of the green line and red line. Can anyone enlighten me as to what the green line and the red line means please?
In what way is it supposed to help me understand my problem/"ambiguity"?
(plus the ifs expression doesn't seems to be the source of the ambiguity according to the diagram)


(below is the diagram with only what look like problematic part)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080531/e2fe4639/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 22255 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080531/e2fe4639/attachment-0001.png 


More information about the antlr-interest mailing list