[antlr-interest] can antlr handle some ambiguity, specifically this one...

david shepherd davidshepherd at rocketmail.com
Thu Aug 9 12:35:10 PDT 2007


 I have really enjoyed using ANTLR and ANTLRWorks, but have run into  
 problems because of the LL parsing technology.  I thought that  
 antlr should be able to parse:

 ES -> CE | PE | E
 CE -> PE E
 PE -> n | PE n
 E  -> e

 because it can lookahead k tokens and decide to reduce ES -> CE or ES -> PE.
 In practice, I can't get anltr to handle the ambiguity in ES -> CE | PE | E .

It wants to always reduce to CE, even when PE is necessary.  I thought
that the LL(*), or the * lookahead would allow it to parse 'n n e n',
but it cannot parse this.

 Am I doing something wrong, or is this a consequence of LL grammars?

 Thanks,
 David Shepherd
 Postdoctoral Fellow at UBC

PS-I
have gotten an LR parser to parse this example, but the antlr and
antlrworks environment is much preferred, if it can handle this issue.





More information about the antlr-interest mailing list