[antlr-interest] How to handle? Synthetic token?
denstar
valliantster at gmail.com
Mon Dec 20 22:04:40 PST 2010
On Mon, Dec 20, 2010 at 10:56 PM, James Ladd wrote:
>
> Maybe I have answered my own question:
>
> temporaries
> : '||'
> | '|' temporaryVariables '|'
> | '|' temporaryVariables errorYouMissedClosingPipe
> ;
>
> <snip>
>
> errorYouMissedClosingPipe
> : ~('|' | NAME)
> ;
>
> When I use the NOT token I get the correct parsing.
> For example, this is not correct: | foo bar [
>
> *note: the things that are not '|' or NAME need to be matched as well.
> So in the example I gave '[' has to be a matched token.
>
> My question not is: Is this an ok approach / thing to do?
I'm far from an expert on ANTLR, but I believe this is sorta taken
care of for you.
See: http://www.antlr.org/wiki/display/ANTLR3/FAQ+-+Error+handling
For some examples of ways to handle this that aren't as fragile.
:Den
--
He who speaks evil only differs from his who does evil in that he
lacks opportunity.
Marcus Fabius Quintilian
More information about the antlr-interest
mailing list