[antlr-interest] How to handle? Synthetic token?
James Ladd
james_ladd at hotmail.com
Mon Dec 20 21:56:48 PST 2010
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?
Rgs, James.
From: james_ladd at hotmail.com
To: antlr-interest at antlr.org
Subject: How to handle? Synthetic token?
Date: Tue, 21 Dec 2010 16:15:11 +1100
Hi All,
I'm wondering if it is possible to add a rule or token to help trap errors?
I have the following:
temporaries
: '||'
| '|' temporaryVariables '|'
;
Which is fine and the allowed cases, however, I'd like to the following:
temporaries
: '||'
| '|' temporaryVariables '|'
| '|' temporaryVariables errorYouMissedClosingPipe
;
Possibly by defining errorYouMissedClosingPipe as a rule or token that matches anything but the '|'.
Is this possible and could someone provide an example or a link to a page that describes this?
Rgs, James.
More information about the antlr-interest
mailing list