Your "combined" grammar Lexer
only has lexer rules, while when you only define grammar
, ANTLR expects at least 1 parser rule.
There are 3 different types of grammars
- combined grammar:
grammar Foo
, generates:class FooParser extends Parser
andclass FooLexer extends Lexer
- parser grammar:
parser grammar Bar
, generates:class Bar extends Parser
- lexer grammar:
lexer grammar Baz
, generates:class Baz extends Lexer
So, in your case, change grammar Lexer;
into lexer grammar ScriptLexer;
(don't name your lexer grammar Lexer
since it is the base lexer class in ANTLR!) and import this lexer in your parser grammar:
parser grammar ScriptParser;
import ScriptLexer;
options {
language=C;
output=AST;
ASTLabelType=pANTLR3_BASE_TREE;
}
// ...
Related: