[antlr-interest] Actions in predicates

Marcin Rzeźnicki marcin.rzeznicki at gmail.com
Mon Feb 22 09:57:22 PST 2010


On Mon, Feb 22, 2010 at 6:16 PM, Jim Idle <jimi at temporal-wave.com> wrote:

> You might deal with this the way I do for the JavaFX parser:
>
>
Thanks for the example. I cannot understand how you check whether semicolon
is required or not?


> Then do not put your ';' in a different channel. The checkForSemi() method
> encapsulates the code for deciding if the semi colon is allowed to be
> missing or not - languages really should not make such things optional, it
> makes it very difficult to generate decent error messages - and issues an
> error message if it is required, otherwise just returns silently.
>

Unfortunately it is optional, standard says so:
"In writing specimens of any construct defined by a Repetition production
specifying the semicolon
";" as separator, it is permitted, without any effect on the syntax
structure, validity and semantics
of the software, to omit any of the semicolons, or to add a semicolon after
the last element.".



>
> You can get the JavaFX compiler source code from Kenai:
> http://kenai.com/projects/openjfx-compiler
>
> Actions that are specified as:
>
> {{ }}
>
> Will be executed within predicate lookahead as well as normal mode and you
> can then check the backtracking flag to see if you are in predicate mode.
> However, I suggest that you will find that difficult to maintain.
>


Great, thanks, didn't know about this syntax.




-- 
Greetings
Marcin Rzeźnicki


More information about the antlr-interest mailing list