[antlr-interest] Token generation problem

SAGAR BIYANI sagarbiyani at yahoo.com
Tue Mar 12 20:16:58 PST 2002


Hi ,
    I have two grammar files. One file containing the
Base grammar and other containing Derived grammar. My
base grammar file import Common Vocab. DerivedLexer
import the BaseParser vocab and export it as 
"DerivedParser" Vocab. In this case token generated in
DerivedParserTokenTypes.txt are incorrect. It doesn't
contain the derived
lexer tokens. But in derived Lexer if I export the
vocab by name other then "DerivedParser" then it
generates  token correctly. I couldn't understand why
it is not working in other case.

Is it a bug ? 
Any help on this will be appreciated.

Thanks,
Sagar

Here the two grammar files code:

Content of Base.g file.

class BaseParser extends Parser;
options {
   importVocab = Common;
}
tokens {
   HINT = "hint";
}

start:
HINT
;

class BaseLexer extends Lexer;
SEMICOLON:';'
;

Content of Derived.g file.

options{
	language="Java";
}

class DerivedParser extends BaseParser;
abcd: HINT
;


class DerivedLexer extends BaseLexer;

options{
   importVocab = BaseParser;	
   exportVocab = DerivedParser;//does't generate token
correctly. MY_TOKEN doesn't come in the generated
token.
   //exportVocab = DerivedParser1;//Generate tokens
correctly.
}

MY_TOKEN:
"mytoken"
;

Common file content :
Common    // output token vocab name
PLSQL_OPEN=4
PLSQL_CLOSE=5
SQL_STATEMENT_START=6
SEMICOLON=7


__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
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