[antlr-interest] semantic predicate affects nothing

Robin Davies rerdavies at rogers.com
Sun Jun 17 22:00:03 PDT 2007


You're missing an '|' after the {false}? . That syntactic predict is always 
going to fail without it.

text_paragr : (OPEN ((NEWLINE)=>{false}?  |)) => text_line+;



----- Original Message ----- 
From: "Markus Kuhla" <bace.spam at gmx.net>
To: <antlr-interest at antlr.org>
Sent: Sunday, June 17, 2007 8:31 PM
Subject: [antlr-interest] semantic predicate affects nothing


> Hi guys,
>
> I try to use the semantic predicate "match alpha if not followed by beta" 
> from http://www.antlr.org/blog/antlr3/lookahead.tml (section May 11, 
> 2006).
>
> I want to distinguish between an inline element in a text paragraph and 
> block (an extra paragraph). The block is indicated by '(((\n', in inline 
> is no newline allowed. Before a block begins, the text paragraph has to 
> end (out of the +loop).
>
> The problem is, that the parser does not change its behavior, it always 
> matches the block as an inline element and throws an exception at the 
> newline.
>
> I wrote the v3 grammar as short as possible to show this:
>
> page : paragraph *;
> paragraph : text_parag  |  block;
> text_paragr : (OPEN ((NEWLINE)=>{false}? )) => text_line+;
> text_line : (TEXT | inline)+  NEWLINE;
> inline : OPEN  text  CLOSE;
> block : OPEN  NEWLINE  TEXT*  NEWLINE  CLOSE  NEWLINE;
> text : ANY *;
>
> OPEN : '(((';
> CLOSE : ')))';
> NEWLINE : '\r\n';
> ANY : .;
>
>
> Thanks for any assistance!
> Best,
> Markus
> -- 
> GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
> Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail 



More information about the antlr-interest mailing list