[antlr-interest] literals.

Ric Klaren klaren at cs.utwente.nl
Wed Dec 10 03:24:36 PST 2003


On Wed, Dec 10, 2003 at 04:02:54PM +0530, aravind srinivasan wrote:
> can try using syntactic predicate. I am not sure if that would be the
> correct way of doing it as i have just started using antlr.
>   
> ...| ("instanceof") => "instanceof" { rel_op = JSToken.InstanceOf; }  
> 	| "in" { rel_op = JSToken.In; }   
>         ;

This is actually something that's better to left factor using a predicate
is expensive.

| "in" { rel_op = JSToken.In; } ("stanceof" { rel_op = JSToken.InstanceOf; } )?

This fixes things partially but "in" and "instanceof" will always be
ambiguous with the IDENTIFIER rule from a lexer point of view. It will
depend on context and the language wether it can be disambiguated at al.
Testing "in" and "instanceof" via the literals table in the IDENTIFIER rule
might give unwanted results too (is in/instanceof a valid identifier in
this language?).

Oliver might be right that this is one warning to live with (after
veryfying that antlr does the right thing)

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  Wo das Chaos auf die Ordnung trifft, gewinnt meist das Chaos, weil es
  besser organisiert ist. --- Friedrich Nietzsche


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list