[antlr-interest] Syntactic anti-predicates
Steve Bennett
stevagewp at gmail.com
Mon Feb 11 21:19:30 PST 2008
On 2/12/08, Gerald B. Rosenberg <gbr at newtechlaw.com> wrote:
>
> Won't this do the trick?
>
> table:
> LEFT_BRACE PIPE ws? table_format? NL
> ( ( ws? PIPE RIGHT_BRACE )=> ws? PIPE RIGHT_BRACE | table_line )+
> ;
It's close, but matches too much input on data like:
{|
|foo
|}
|blah
That last row (|blah) should not be matched by the table rule. Sort of
comes back to the need for the anti-predicate: the only way to
terminate a loop is for everything in it to fail, and it can be a bit
awkward arranging for that to take place.
Steve
More information about the antlr-interest
mailing list