[antlr-interest] How to handle the tokens from two lexers?

Arnar Birgisson arnarb at oddi.is
Thu Nov 20 07:14:35 PST 2003


I do this by importing the vocabulary from lexer A into lexer B, and
then importing the vocabulary from lexer B into the parser.

This makes sure that lexer B doesn't generate token id's that are
already defined in lexer A.

Like this:

class LexerA extends Lexer;
options {
	k = 2;
	charVocabulary = '\3'..'\377';
	exportVocab = LexerATokens;
}

class LexerB extends Lexer;
ptions {
	k = 2;
	charVocabulary = '\3'..'\377';
	importVocab = LexerATokens;
	exportVocab = LexerABTokens;
}

class MyParser extends Parser;
ptions {
	k = 3;
	importVocab = LexerABTokens;
	buildAST = true;
}

Arnar

> -----Original Message-----
> From: marcschellens [mailto:m_schellens at hotmail.com] 
> Sent: 20. nóvember 2003 14:27
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] How to handle the tokens from two lexers?
> 
> 
> How Can I handle the different token sets from two
> different lexers within one parser?
> thanks,
> marc
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> 
> 


 

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




More information about the antlr-interest mailing list