[antlr-interest] Way to "cut" parsing?

Jim Idle jimi at temporal-wave.com
Mon Oct 15 18:50:31 PDT 2012


Please see the FAQ:

http://www.antlr.org/wiki/display/ANTLR3/Custom+Syntax+Error+Recovery

Also be aware of: http://antlr.markmail.org which will allow you to search
the archives of the list and will usually give you an answer quicker than
the list itself will :) Almost everything that could be asked about ANTLR
3.4 has been asked and answered by now ;)

Cheers,

Jim

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Juancarlo Añez
Sent: Tuesday, October 16, 2012 9:24 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Way to "cut" parsing?

I've written a grammar for a programming language. An annoyance I've
encountered is that ANTLRv3.4.1 will report failure against the enclosing
structured statement (like WHILE) instead of against the particular
statement/phrase it failed to parse. It probably does so because the many
lookaheads and the backtracking they induce.

Is there a way to implement a "cut" meta-instruction with ANTLR, so the
parser does not backtrack after having parsed a given token?

Something like:

add: 'ADD' {cut()} .... ;

so the parser will ether finish parsing the ADD statement, or fail on
*that* rule.

TIA,

--
Juancarlo *Añez*

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list