0

I have created a simple grammar that parses a set of IF/THEN statements. I can get the various recognition exceptions (MissingTokenException, NoViableAltException, etc).

Now I need to go a step beyond and make my processing a bit more fine-grained.

For example, the following rule is missing a THEN:

IF CODE="1"
    DATE < TODAY
ELSE
    DATE >= TODAY
ENDIF

Here's another one (missing a left paren):

IF CODE="1" OR CODE="2") THEN
    DATE < TODAY
ENDIF

Another (missing quotes around a String):

IF CODE=1" THEN
    DATE < TODAY
ENDIF

Can anyone make any suggestions? The only idea I have is a regex-based post processor where if the statement isn't properly parsed, it's compared to a series of regular expressions to determine what went wrong.

Jason

Jason
  • 3,943
  • 12
  • 64
  • 104
  • There's a good deal of information about a parsing error available to you at the point the error took place, some of which is described [here](http://stackoverflow.com/questions/13624624/antlr-handling-exceptions). "Missing token X at line N" and "Unexpected token Y at line N, col M" messages are pretty easy to produce. Is that the level of granularity you're looking for? – user1201210 Dec 06 '12 at 17:40
  • I've decided to go a slightly different direction (i.e. brute force) and will likely be posting a different question. However, if you can put this in an answer, I'll accept it. – Jason Dec 07 '12 at 12:53
  • No sweat, I'll wait for your next question. – user1201210 Dec 07 '12 at 18:01
  • what is the question?? – john k Feb 14 '18 at 19:42

0 Answers0