[antlr-interest] Syntactic anti-predicates

Steve Bennett stevagewp at gmail.com
Wed Feb 13 00:26:36 PST 2008


On 2/12/08, Gerald B. Rosenberg <gbr at newtechlaw.com> wrote:
> table
>    @init{ boolean done = false; } :
>       LEFT_BRACE PIPE ws? table_format? NL
>            ( ( ws? PIPE RIGHT_BRACE )=> ws? PIPE RIGHT_BRACE {
> done=true; } | { !done }? table_line )+
> ;

Ah yes. Didn't think of that.


> Perhaps the cleaner solution would be to disambiguate the PIPE
> combinations in the lexer:

Possible, but probably more complex than the rules you give. I don't
really want to be matching |+ as a table token everywhere. And {| is
only a table start at the beginning of a line, for instance. I've
become a bit wary of using any lexer tokens at all for this stuff -
otherwise you end up having to right special rules whenever they're to
be treated as literal.

Steve


More information about the antlr-interest mailing list