[antlr-interest] importVocab exportVocab problem
hawkwall
hawkwall at yahoo.com
Sat Jan 3 05:47:28 PST 2004
Hello,
I am having trouble defining a vocabulary in one file and the
importing it into my Parser. I have read the documentation and
everything I can find in the newgroup, plus have gone through the
TinyBasic example and I am still getting errors. Sorry, this seems
like it should be easy.
I started by defining a lexer and parser in the same file. When I did
this, my example ran. I then created another grammar file, moved my
lexer to this file, added an exportVocab option. In the original
file, I deleted the lexer and added an importVocab option to the
parser. Compiling the lexer first and then the parser, I see the
tokens are generated in the ParserTokensTypes.txt, but I get the
following error:
line 1:1: expecting "MIKE.START", found 'MIKE.START'
Here is the Lexer:
class mikeLexer extends Lexer;
options {
testLiterals=true;
exportVocab=mike;
}
protected
DIGIT : ('0'..'9') ;
protected
DOT : '.' ;
protected
INTEGER : (DIGIT)+ ;
protected
DECIMAL : (DIGIT)* DOT (DIGIT)+ ;
NUMBER : ((DIGIT)* DOT)=> (DIGIT)* DOT (DIGIT)+
{$setType(DECIMAL);}
| (DIGIT)+
{$setType(INTEGER);}
;
protected
LETTER : 'A'..'Z';
TAG : (LETTER | DOT)+ ;
WS : ( ' '
| '\t'
| '\f'
| ( options {generateAmbigWarnings=false;}
: "\r\n" // DOS
| '\r' // Macintosh
| '\n' // Unix
)
{newline();}
)+
// now the overall whitespace action -- skip it!
{ $setType(Token.SKIP); }
;
Here is the parser:
class P extends Parser;
options {
k=2;
importVocab=mike;
}
startRule : "MIKE.START"
INTEGER
"END.MIKE"
;
Here is the input file:
MIKE.START
100
END.MIKE
My goal is be able to share this Vocabulary with multiple Parsers, at
times extending the tokens. What am I missing? Thanks for your time.
Mike Wall
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list