I'm trying to create a BNF Grammar in Antlr for propositional logic but I keep getting the error:
java.lang.NoSuchFieldError: offendingToken
As there is no line number displayed, I don't know where the error is. The build is successful, but when I type in an example input, the tree stops at sentence, the first item defined in the BNF.
Here is my BNF:
grammar Grammar;
options {
language = Java;
output = AST;
ASTLabelType=CommonTree;
}
@header {
package antlr;
}
@members {
}
@lexer::header { //lexer
package antlr;
}
@lexer::members {
}
sentence: atomicsentence | complexsentence;
atomicsentence: 'T' | 'F' | symbol;
complexsentence: unop sentence | sentence binop sentence | (sentence);
unop: 'NOT';
binop: 'AND' | 'OR' | 'IMPLIES' | 'EQUIVALENT';
symbol: (LEXRULE)+;
LEXRULE: ('a'..'z')|('A'..'Z');
If you comment out complexsentence in sentence, the atomicsentence part works, until it terminates because there is no EOF. I'm unsure as to where this should go as adding it to sentence does not work.