[antlr-interest] Backtracking problem

Alessandro alessnet at gmail.com
Sun Jan 13 08:57:14 PST 2008


Hello,

I have a problem with semantic predicates.

Here is a part of my grammar :

instructionlist
	:	(instruction SEMI)* -> instruction*;
	
instruction

	:	wait_
	|	if_
	|	while_
	|	(assign)=>assign
	|	(call)=>call;
/*
I tried first (lhside[false] ASSIGN) => assign
*/

assign	:	lhside[false] ASSIGN rhside;

call	:	LAUNCH lhside[false] '<-' ID LP rhsidelist RP
	|	lhside[false] '<-' ID LP rhsidelist RP
	|	ID LP rhsidelist RP ;


lhside[Boolean tilde]	:	sub_local2 (DOT sub_local2)*;
sub_local2
	:	ID (CO rhside CF)+  -> ^(ID_ARR[$ID] rhside*)
	|	ID -> ^(ID);


Both rules "call" and "assign" can begin with "lhside", and this rule
is self-recursive.
So the decision in rule "instruction" isn't LL(*). I think that if the
input begin with "lhside ASSIGN" this is an "assign" for sure !
But I have a problem, and I don't know if this is a bug ...

With the input
self.touch_one := 3;
it's ok...(even with input "touch_one[3] = 3;")

But with the input
self.touch_one[3] :=3;
I have an error in "instruction" : no viable alternative at input ':='
This is very strange because neither "(call)"  nor "(assign)"
predicate are executed for this input...

In ANTLRWorks, the input "self.touch_one[3] := 3;" is correct with the
rule "assign" (and not with "call").

I forget something ?
(the complete grammar is attached to this mail)

Thanks :-)

Alessandro
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sdl.g
Type: application/octet-stream
Size: 6222 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080113/98164e6d/attachment-0001.obj 


More information about the antlr-interest mailing list