[antlr-interest] Re: Semantic predicates that aren't & hoisting

David Jung jungdl at ornl.gov
Sat Mar 12 12:52:20 PST 2005


John D. Mitchell said:
>>>>>> "David" == David Jung <jungdl at ornl.gov> writes:
> [...]
> Here's a relatively proper language that deals with statements and
> expressions with the nesting that you seem to want.

John,

Nice try (& thanks for taking the effort) - but no prize.
The grammar you've given has gone back to making the restrictive
distinction between statements & expressions (ala Java/C++).
That, of course, makes my no-semi-following-blocks requirement
trivial to solve (using the same form as the Java grammar).

>
> Here's a sample input: {if (a() < 0) then {b; c(); {;} dd();} e; f();}
> g();
>

Notice how you've corrupted my input "{if {a>0;} then {f();g();} x();}"
so that you only accept an expression, but not a statement as the
if conditional.
More importantly, statements are not primary in your grammar.
Having the primaryExpr rule include statement would make it closer.

If you can modify your grammar some-how to parse this, then we'd
have a solution:

"{if ({a();}++ < 0) then {b; c(); {;}+1 dd();} e; f();}*2"

(& I might just consider paying for an hour of your time)

or better yet, to include my other issue with ';'s after the last
expr in a block, to parse this:

"{if ({a()}++ < 0) then {b; c(); {}+1 dd()} e; f()}*2"

which is really what I want.

Cheers,
-David.



More information about the antlr-interest mailing list