[antlr-interest] Simlpe grammar: Won't run at all.

Gary Bennett gbennett at requisoft.co.uk
Wed May 18 06:38:19 PDT 2005


Hello,

I'm just starting out with this.

I have this simple grammar (This is the simplest grammar showing the
error that is).

It generates antlr files but they won't run because:

	static public void initializeASTFactory( ASTFactory factory )
	{
		factory.setMaxNodeType(5); <<-- ArgumentException.
	}

Can anyone explain what I am doing wrong.

Many thanks.

// Basic Grammar 

options {
	language = "CSharp";
}

class TestParser extends Parser ;

options {
	buildAST = true;	// uses CommonAST by default
}

name: NAME ;

class TestLexer extends Lexer;

WS	:	(' '
	|	'\t'
	|	'\n'
	|	'\r')
	{ $setType(Token.SKIP);}
	;

NAME: 'a'
	;

class TestWalker extends TreeParser ;

name: nm:NAME
		{ 
			Console.WriteLine(" Name: {0}", nm.getText() ); 
		} 
	;

--------------------------------------------
Regards

Gary Bennett
Software Developer
Requisoft plc 
--------------------------------------------


More information about the antlr-interest mailing list