[antlr-interest] semantic predicate affects nothing

Markus Kuhla bace.spam at gmx.net
Sun Jun 17 22:52:56 PDT 2007


Oh yes, I tried this too, but does not changes the behavior. The block is still recognized as an inline element and throw the exception at the newline after '((('.
I didn't understand the meaning of the '|' so I omitted it ;)

Best regards!
Markus

> 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


-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger


More information about the antlr-interest mailing list