[antlr-interest] A look-ahead/rewind problem
Lukasz Guminski
lguminski+antlr at gmail.com
Mon Mar 23 15:43:00 PDT 2009
2009/3/23 Jim Idle <jimi at temporal-wave.com>
> Lukasz Guminski wrote:
>
> I have just noticed the problem with alphanum.
>
> ...
>
>
> fragment CR :'\r';
> fragment LF : '\n';
> INSIGNIFICANT_CHAR:.;
>
> You still need:
>
>
> INSIGNIFICANT_CHAR:. { skip(); };
>
> I think.
>
You're right. Thank you.
BTW is it possible to solve the problem via a mixture of syntactic and
semantic predicates in the way I initially tried?
block_open
: ((BLOCK_BOUNDARY
block_name)=>{stack.size()==0||!stack.peek().equals($block_name.text)}?) =>
BLOCK_BOUNDARY block_name BLOCK_BOUNDARY
{stack.push($block_name.text);System.out.println("start of block " +
$block_name.text);};
If so, how to do it? I have a feeling that it would be a more general
solution than delegating the task to the lexer as we did.
Lucas
>
>
> Jim
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090323/f0563e76/attachment.html
More information about the antlr-interest
mailing list