[antlr-interest] Decision can match input such as "DOT ID" using multiple alternatives

Micheal J open.zone at virgin.net
Sat Jul 14 18:05:37 PDT 2007


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/710f1331/attachment.html 


More information about the antlr-interest mailing list