[antlr-interest] ast validation question

Scott Amort jsamort at sympatico.ca
Thu Feb 23 17:17:05 PST 2006


On Wed, 2006-02-22 at 19:50 -0800, Sohail Somani wrote:

> Couldn't you make these keywords and have them matched as in the parser?
> 
> Something like (probably doesnt compile):
> 
> class L extends  Lexer;
> KEYWORDA:"FOO";
> KEYWORDB:"BAR";
> KEYWORDC:"NO";
> SLASH:'\\';
> 
> class P extends Parser;
> options
> {
> 	importVocab=L;
> }
> {
> 	public static void main(String args[])
> 	{
> 		L l = new L(System.in);
> 		P p = new P(l);
> 		p.tagRule();
> 	}
> }
> tagRule:SLASH (KEYWORDA | KEYWORDB | KEYWORDC);
> 
> The key of course is fixed number of strings.

Thanks for the response!

Yes, I did consider going this route, but it seemed a bit cluttered to
have 50 or so identifiers that were all processed exactly the same way
by the lexer/parser.  So it seemed best to evaluate only the syntax, and
leave validation for a later step.

Best,
Scott



More information about the antlr-interest mailing list