[antlr-interest] ANTLR or ANTLR Eclipse plugin bug

Martin Olsson mnemo at minimum.se
Tue Aug 9 04:51:05 PDT 2005


> Looks like you do have the latest plugin.
> Is there any way you can create a dummy sample that reproduces the error?
>
> I doubt it's something specific to the antlr-eclipse plugin; could you
> test
> against the 2.7.5 antlr from antlr.org as well to see if it has the
> problem.


Ok here's what I did. First, I went through my entire grammar and remove
all actions, rule parameters and so on. then I started to remove half the
parser rules, then another half and so on. Same with lexer rules. The
error persists and now I'm down to this simple snippet:

http://www.rafb.net/paste/results/J3zpEg47.html
(another copy of the .g file below, incase the paste site expires)

And I can reproduce the problem using the ANTLR command line tool too
(2.7.5 version 20050201). Maybe this is a problem in my .g syntax, but it
seems odd that ANTLR generates broken code without warning.. :/


Sincerly,
Martin Olsson

---
Copy of the .g file below
-------------------------------

// -- Header options --
header

// -- Global options --
{
}

// **** LEXER
******************************************************************

class MyLexer extends Lexer;

// -- Lexer options --
options
{
	exportVocab = Dup;		// Name of exported vocabulary
	k = 4;				// The lookahead depth
	charVocabulary = '\3'..'\377';  // Valid set of characters
	testLiterals = false;		// Do not automatically test for literals
	defaultErrorHandler = true;     // HACK. See recover() dummy method for
more info.
}

LEFTPARENTHESIS					options { paraphrase="'('"; }			:	'(';









// **** PARSER
*****************************************************************

class MyParser extends Parser;

// -- Parser options --
options
{
	exportVocab = Dup;		// Name of exported vocabulary
	k = 4;				// The lookahead depth
}

{

	public final void reportError(RecognitionException ex) {

		// propagate error to other parts of app here
		System.out.println("PARSER EX: " + ex);

	}

	public final void grammar() {
		try {
			start();
		} catch (RecognitionException e) {
			// also propagate error to other parts of app here too (not sure this
is ever needed though)
		} catch (TokenStreamException e) {
			// also propagate error to other parts of app here too (not sure this
is ever needed though)
		}
	}

}

bool_value
	:		"TRUE"
		|	"FALSE"
	;

start
	:
		top
	;

top
	:
		(
			bool_value
		)*
		EOF!
;







More information about the antlr-interest mailing list