[antlr-interest] Ambiguous parse tree generated
Juancarlo Añez
apalala at gmail.com
Tue Oct 30 04:32:12 PDT 2012
On Tue, Oct 30, 2012 at 3:28 AM, Gerald Rosenberg <gerald at certiv.net> wrote:
> style : ( Dot Identifier ( Hash Identifier )? )* ;
>
> I still get the same single lists of Dot, Hash, and Identifier. Only way
> to determine the Dot vs Hash associated Identifier's is by inspection of
> the token stream? Adding labels did not change the generated code.
>
I'm not using v4, but in v3.4, the tree for a rule will be a flat list with
the tokens unless you add tree construction indicators. As Jim says, you
can get away by factoring in some more rules:
style : dot_id* -> ^(STYLE dot_id*);
dot_id: Dot Identifier hash_id?;
hash_id: Hash Identifier;
--
Juancarlo *Añez*
More information about the antlr-interest
mailing list