[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:


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 ;)



-----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.


Juancarlo *Añez*

List: http://www.antlr.org/mailman/listinfo/antlr-interest

More information about the antlr-interest mailing list