[antlr-interest] pushed antlr build with tree rewriting and composite grammars (java)

David Holroyd dave at badgers-in-foil.co.uk
Sun Jan 13 12:19:56 PST 2008


On Sun, Jan 13, 2008 at 01:49:35AM +0000, David Holroyd wrote:
> e.g., here's the definition of 'identifier',
> 
>   identifier 
>     :   (   qualifiedIdent -> qualifiedIdent
>         )
>         (   options{greedy=true;}
>         :   poi=propOrIdent[root_0, retval.start] -> $poi
>         )*
>         -> ^(IDENTIFIER $identifier)
>     ;
> 
> With the input snippet "testpkg" I invoke the generated identifier()
> method directly, and I see
> 
>   NoViableAltException(-1!=[()* loopback of 676:3: ( options {greedy=true;} : poi= propOrIdent[root_0, retval.start] -> $poi)*])

If I explicitly add an optional EOF to the rule, all is well again,


  identifier 
    :   (   qualifiedIdent -> qualifiedIdent
        )
        (   options{greedy=true;}
        :   poi=propOrIdent[root_0, retval.start] -> $poi
        )*
        EOF?
        -> ^(IDENTIFIER $identifier)
        ;


-- 
http://david.holroyd.me.uk/


More information about the antlr-interest mailing list