[antlr-interest] Braces
Gokulakannan Somasundaram
gokul007 at gmail.com
Wed Jul 27 21:36:01 PDT 2011
Have a context level variable and update it through the action part in
SEP_LBRACE.
Gokul.
On Thu, Jul 28, 2011 at 6:30 AM, Alex Pojarsky <divine.raven at gmail.com>wrote:
> Greetings everyone.
>
> Ive got the following Parser rule in my grammar file:
>
> codeBlock
> : SEP_LBRACE {input.mark();} code? SEP_RBRACE
> ;
>
> And it correctly generates MismatchedTokenException when encounters
> EOF instead of SEP_RBRACE. The problem is it gives line 0 and
> charPosition -1, which is illegal in the place I'm trying to use it. I
> want these things to be set to the position of the last instance of
> SEP_LBRACE. I.e. when parser encounters EOF while parsing this
> codeBlock rule - it should return Line and charPosition of the nearest
> SEP_LBRACE.
>
> Could you please explain how do I do this? I'm still newbie, even
> though I've developed a simple grammar for the programming language,
> so please, keep things simple as long as it is possible.
>
> Thanks a lot in advance.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
More information about the antlr-interest
mailing list