[antlr-interest] Syntactic anti-predicates

Jim Idle jimi at temporal-wave.com
Mon Feb 11 16:46:20 PST 2008



> -----Original Message-----
> From: Mark Wright [mailto:markwright at internode.on.net]
> 
> > I could left factor table_line:
> 
> > table_line:
> >   (
> >   (ws? PIPE PLUS) => ws? table_caption
> >   | (ws? PIPE HYPHEN) => ws? table_row_separator
> >   | (ws? EXCLAMATION) => ws? table_header_cells
> >   | (ws? PIPE) => ws? table_data_cells
> >   );
> >
> > But that's inelegant.
> 
> Looks elagant and like it might work to me.

If you move the ws and PIPE out more then you probably won't need the 
predicates at all:

ws?  // Do you really need this, can't you just use $channel=2 or 
$channel=HIDDEN?

	(
		PIPE // Take this out of the following rules

			( table_caption
			  | table_data_cells ....

		| table_header_cells
 ....

Or as this looks like wiki, just use global backtracking and 
memorization and let the runtime decide :-)

Jim



More information about the antlr-interest mailing list