[antlr-interest] Why I'm getting syntax errors while I'm cheking for semantic errors?

Marwan Ajraoui marwan.alephn at gmail.com
Thu Aug 13 17:18:44 PDT 2009


Hi comunity;

When I'm runing the tree grammar I defined I'm getting errors like

Error: mismatched input '[]' expecting FN_ID

So the it seems that it doesn't recognize ([])*. I 've already checked
the entry sintactically, so why antlr get confused?

What could be the problem, here is a part of my tree gramar:

type_return: 'void' | 'integer' ('[]')* | 'float'('[]')* |
'double'('[]')* | 'char'('[]')* | 'string'('[]')* | 'boolean'('[]')*;

decl_funcion

scope {
    String ambito;
}

: ^(DECL_FUN type_return FN_ID LISTA_PARAMS lista_instrucciones (t2=inst_return{

	if(!types_checker.areTypesEqual($type_return.text,$t2.type))
         	  emitErrorMessage("Funcion '"+ $FN_ID.text + "' en la linea
" + $FN_ID.line  +" : " + " devuelve un tipo de dato  incoherente con
el definido.");
 	
})?{if($type_return.text.equals("void") && ($t2.type!= null || $t2.type!=""))
		      emitErrorMessage("Funcion '"+ $FN_ID.text + "' en la linea " +
$FN_ID.line  +" : " + " devuelve void, no hay que devolver nada ó
cambia su tipo de retorno.");
	
	$decl_funcion::ambito = $FN_ID.text;	
}
);

Thx in advance for any help;
-- 
Marouane


More information about the antlr-interest mailing list