Posted By:
Christopher_Stephens
Posted On:
Tuesday, October 23, 2001 12:36 PM
I'm having a lot of trouble matching parser defined string literals when my grammar is separated into two files. I'd like to take advantage of ANTLR's vocabulary inheritance, but I need this to work. Can anybody tell me why ".accept" matches using this set of import/export rules: class TestingParser extends Parser; options { exportVocab=TestingParser; } command : ".accept" { cout < < "matched accept" < < endl; } ; class TestingLexer extends Lexer; options { charVocabulary='3'..'377'; exportVocab=TestingParser; caseSensitive=false; } ID : ( 'a' .. 'z' | '0' .. '9' | '.' )+ ;
More>>
I'm having a lot of trouble matching parser defined string literals when my grammar is separated into two files. I'd like to take advantage of ANTLR's vocabulary inheritance, but I need this to work.
Can anybody tell me why ".accept" matches using this set of import/export rules:
class TestingParser extends Parser;
options {
exportVocab=TestingParser;
}
command : ".accept" { cout
<
< "matched accept"
<
< endl; } ;
class TestingLexer extends Lexer;
options {
charVocabulary='3'..'377';
exportVocab=TestingParser;
caseSensitive=false;
}
ID : ( 'a' .. 'z' | '0' .. '9' | '.' )+ ;
WS : ( ' ' | ' ' | '
' { newline(); } | '
' | ' ' )+ { $setType(Token::SKIP); } ;
but ".accept" does not match using this set of import/export rules (regardless of whether or not the parser and lexer definitions are in the same file):
class TestingParser extends Parser;
options {
importVocab=TestingLexer;
exportVocab=TestingParser;
}
...
class TestingLexer extends Lexer;
options {
...
exportVocab=TestingLexer;
...
}
Any help would be great...
<<Less