[antlr-interest] Actions in predicates
Marcin Rzeźnicki
marcin.rzeznicki at gmail.com
Mon Feb 22 14:53:27 PST 2010
2010/2/22 Daniels, Troy (US SSA) <troy.daniels at baesystems.com>
> So
>
> Super; [TYPE] method
>
> Should resolve as (1) followed by 3, but
>
> Super [TYPE] method
>
> Should resolve as (2)?
>
Exactly
>
> I think you probably want to include the semicolons in your default token
> stream. You would then have rules like
>
> type_method : TYPE METHOD SEMI? ;
>
> super : SUPER ( SEMI | type_method | /* nothing */ ) ;
>
> You could even rewrite super in the standard style for this grammar:
>
> super : SUPER type_method_base? SEMI? ;
>
> type_method : type_method_base SEMI? ;
>
> type_method_base : TYPE METHOD ;
>
>
Well, yes, I am starting reconsidering my approach and probably I will
include these in my grammar. Only that this whole SEMI? clutter everywhere
makes me sick, but overall effect is probably better. I did not think of all
implications before, I am afraid, because now I see that ignoring semicolons
in the lexer, as I did, causes that they may appear in places where they are
not allowed, and my parser clearly had no chance to spot this error.
>
> It seems that would also be a more straightforward representation of the
> grammar. Even if you can get the channel switching to work, will you
> remember why you are doing it six months from now? Will you still
> understand the corner cases? Even if you do, what about the guy who works
> on this after you? What I outlined fairly clearly says "semi colons are
> optional" and makes it clear that "super ; [TYPE] ..." is two statements.
>
>
Yes, and it probably will make my syntactic predicates work as expected.
Probably that is the right way. Thanks
--
Greetings
Marcin Rzeźnicki
More information about the antlr-interest
mailing list