[antlr-interest] Decision can match input such as "DOT ID"using multiple alternatives
Lloyd Dupont
ld at galador.net
Sun Jul 15 04:08:38 PDT 2007
MessageI think I didn't understand predicate very well at the time of the writing.
now it's much better and I manage to remove all ambiguity!!
----- Original Message -----
From: Micheal J
To: antlr-interest at antlr.org
Sent: Sunday, July 15, 2007 11:05 AM
Subject: Re: [antlr-interest] Decision can match input such as "DOT ID"using multiple alternatives
Have identifier built the ID (DOT ID)* [sub-]tree. Basically make it into a qualifiedIdentifier or dottedIdentifier sort of rule. Call that from you primary rule. You can check that it has exactly one qualifier using actions in the parser or treeparser.
Micheal
-----------------------
The best way to contact me is via the list/forum. My time is very limited.
-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Lloyd Dupont
Sent: 13 July 2007 15:27
To: antlr-interest at antlr.org
Subject: [antlr-interest] Decision can match input such as "DOT ID" usingmultiple alternative
The compilers tell me. My problem is it's obvious but it *shouldn't be a problem", how can I make ANTLR be happy?
I have a grammar like that
primary:
(atom -> atom)
(
(LPAREN expressionList RPAREN -> ^(LPAREN $primary expressionList)) // method call
// read object DOT property name
| (DOT ID -> ^(DOT $primary ID))
)*
;
atom:
INT -> ^(CONSTANT INT)
| STRING -> ^(CONSTANT STRING)
identifier -> identifier
;
identifier:
// read identifier or class name
(id0=ID->$id0)
(DOT id1=ID->$(DOT $identifier $id1)) *
((LT identifier GT) => LT id2=identifier GT -> $(GENERIC $identifier $id2))?
now it says there are multiple way to access the tokens ID, and that's true.
howver I assume identifier consume all that it can, and primary will consume only those ID that haven't been consumed by identifier.
(on top of that I generate the same AST in both case...)
Anyway, could some help me to solve this problem?
I need to be able to use ID DOT ID in the 'identifer' property as I need to call this rule in 'LT identifier GT'.
yet I need it in the primary, as I need to access the property of any object....
how can I solve that?!?!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070715/d24d394b/attachment.html
More information about the antlr-interest
mailing list