[antlr-interest] Help with non determinism and syntactic, semantic predicates

Joan Pujol joanpujol at gmail.com
Tue Aug 3 14:41:51 PDT 2004


Hi,

My language have a multiple assigment instruction:

<ident1,ident2,...> := <expr1,expr2,...>

And I have conflicts with the '>' of the final of multiple assigment,
because it conflicts with the '>' of greater than.

I have tried this:

exp1:	exp2 (
		{insidemultipleassigment}? (OPGREATER (NEWLINE|SEMICOLON))=> //nothing
		|((OPGREATER^|OPMINOR^...) exp2)*;

and the multiple assigment ends with:
multipleassigment: ..... expresionlist;
expresionlist: expresion moreexpresions;
moreexpresions: OPGREATER! 
		| COLON! expresion moreexpresions; 


and antlr give me a nondeterminism with alternative 1 of exp1 and exit block.

Any ideas?


I have used the diagnostic option an I see:

Rule 1:
....
Rule Reference: exp2
	Start of alternative block.
	Warning: This alternative block is non-deterministic
	Start of an alternative block.
	The lookahead set for this block is:
	{"falgorisme", "fconst", "fvar", "llavors", "altrament", 
	"fsi", "fcas", "fmentre", "fins", "fper", "fer", 
	"pas", OPMESPETITIGUAL, OPMESPETIT, OPIGUAL, NL, IDENTIFICADOR, 
	OPPT, OPDIFERENT, OPGREATER, OPMESGRANIGUAL, SEPARADORCAS,   SEMICOLON,COLON }
	This block has multiple alternatives:
					
	Alternate(1) will be taken IF:
	The lookahead set: {	"falgorisme", "fconst", "fvar", "llavors", "altrament", 
	"fsi", "fcas", "fmentre", "fins", "fper", "fer","pas", NL, IDENTIFICADOR,
        OPPT, OPGREATER, SEPARADORCAS, 	SEMICOLON, COLON
	 }
	is matched, AND the semantic predicate:
	  insidemultipleassigment	is true, AND the syntactic predicate:
		Start of alternative block.
		Start of an alternative block.													The lookahead set for
this block is:														{ OPGREATER }


Why ANTLR computes a very large lookahead if the syntactic predicate
have only one symbol?

Cheers,

-- 
Joan Jesús Pujol Espinar


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list