[antlr-interest] Token classes

John Green greenj at ix.netcom.com
Fri Oct 12 22:37:40 PDT 2001


The problem: a parser rule, which is nothing but a giant list of 100+
keywords (don't ask), generates a function so huge that C++ can't compile
it.

The current workaround: post-antlr-code-generation, re-write the function by
hand so that instead of 100+ chunks of generated code within the CASE
statement, there's 100+ options in the case statement but they all fall
through to the same, single chunk of code:

	<snip>
	case XCODE:
	case XREF:
	case Y:
	case YOF:
	case YEAR:
	case YES:
	case YESNO:
	case YESNOCANCEL:
	{
		antlr::RefAST tmp1522_AST = antlr::nullAST;
		if (inputState->guessing==0) {
			tmp1522_AST = astFactory.create(LT(1));
			astFactory.addASTChild(currentAST, tmp1522_AST);
		}
		matchNot(antlr::Token::EOF_TYPE);
		keyword_AST = currentAST.root;
		break;
	}
	<snip>

In the Antlr docs, there's mention of "Token Classes", but I'm pretty sure
those are not implemented.

I want a valid rule, in the Antlr grammar file, so that lookaheads work.

Any suggestions?

Thanks,
John


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list