[antlr-interest] semantic predicate affects nothing

Markus Kuhla bace.spam at gmx.net
Sun Jun 17 17:31:42 PDT 2007


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