[antlr-interest] Cannot find symbol UP?

Stephan Opfer stephan.opfer at gmx.net
Thu May 10 07:39:53 PDT 2012


Hi,

today I tried to add implication and biimplication to my first order
logic grammar. The code can be generated, but when I press "Debug",
ANTLRWorks throws and error:

Test3Parser.java:1218: cannot find symbol
symbol  : variable UP
location: class Test3Parser
                else if ( (LA6_1==EOF||(LA6_1 >= UP && LA6_1 <=
BIIMPLY)||LA6_1==IMPLY||LA6_1==OR||LA6_1==RPAREN) ) {

Do you have any Idea how to solve this problem? As far as I understand,
it must have something to do with my parser rule "formula":

formula	:	f1=( ^(NOT atomic)
	|	atomic
	|	^(NOT LPAREN f3=formula RPAREN) -> ^(NOT $f3)
	|	LPAREN f3=formula RPAREN  -> $f3
	|	disjunction
	| 	^(FORALL VARIABLE formula)
	|	^(EXISTS VARIABLE formula)
	)	((IMPLY f2=formula -> ^(OR  ^(NOT $f1) $f2)) |	(BIIMPLY f2=formula ->
^(AND ^(OR  ^(NOT $f1) $f2) ^(OR  ^(NOT $f2) $f1))))?;

Please find the complete grammar attached.

Best Regards,
  Stephan
-------------- next part --------------
grammar Test3;

options{
	language=Java;
	output=AST;
	ASTLabelType = CommonTree;
}

tokens{
	PREDICATE;
	FUNCTION;
}

/*------------------------------------------------------------------
 * PARSER RULES
 *------------------------------------------------------------------*/

condition: formula EOF!;

formula	:	f1=( ^(NOT atomic)
	|	atomic
	|	^(NOT LPAREN f3=formula RPAREN) -> ^(NOT $f3)
	|	LPAREN f3=formula RPAREN  -> $f3
	|	disjunction
	| 	^(FORALL VARIABLE formula)
	|	^(EXISTS VARIABLE formula)
	)	((IMPLY f2=formula -> ^(OR  ^(NOT $f1) $f2)) |	(BIIMPLY f2=formula -> ^(AND ^(OR  ^(NOT $f1) $f2) ^(OR  ^(NOT $f2) $f1))))?;

atomic 	:	TRUE | FALSE | predicate ; 


disjunction
	:	conjunction (OR^ conjunction)+ ;

conjunction
	:	atomic (AND^ atomic)+ ;

predicate 
	:	PROPOSITION predicateTuple -> ^(PREDICATE PROPOSITION predicateTuple)
	| 	PROPOSITION ;

predicateTuple
	:	LPAREN! term (','! term)* RPAREN! ;

term	:	function | VARIABLE ;

function:	CONSTANT functionTuple -> ^(FUNCTION CONSTANT functionTuple)
	|	CONSTANT;

functionTuple
	:	LPAREN! (CONSTANT | VARIABLE) (','! (CONSTANT | VARIABLE) )* RPAREN!;

/*------------------------------------------------------------------
 * LEXER RULES
 *------------------------------------------------------------------*/

TRUE : 'True';
FALSE : 'False';	
LPAREN : '(' ;
RPAREN :  ')' ;
AND :  '&' ;
OR :  '|' ;
NOT :  '!' ;
FORALL :  'Forall' ;
EXISTS :  'Exists' ;
IMPLY : '->';
BIIMPLY : '<->';

VARIABLE: '?' (('a'..'z') | ('0'..'9')) CHARACTER* ;

CONSTANT: (('a'..'z') | ('0'..'9')) CHARACTER* ;

PROPOSITION: ('A'..'Z') CHARACTER* ;

fragment CHARACTER: ('0'..'9' | 'a'..'z' | 'A'..'Z' | '_') ;

WS : (' ' | '\t' | '\r' | '\n')+ {$channel = HIDDEN ;} ;


More information about the antlr-interest mailing list