[antlr-interest] my grammar was wrong, but my error rose a syntactic predicate problem in tree parsers

Anthony Brenelière abreneliere at telys.com
Thu Feb 20 07:32:49 PST 2003



I did a mistake, i replaced:

( modif 1 )
set
	:	#( R_ENT setComponentList )
;

to 

set
	:	#( R_SEC setComponentList )
;

( modif 2 )
In the syntactic predicate, i did not need to check the entire rule.
I also  replaced..

entOrSet
	:	( entity )=> entity
	|	( set )=> set
;

by.. 

entOrSet
	:	( R_ENT )=> entity
	|	( R_SET )=> set
;

and now everything works.

BUT the rule..
entOrSet
	:	( entity )=> entity
;
..did work because the sintactic predicate was supressed (because it is
obsolete)

and HOWEVER..
entOrSet
	:	( entity )=> entity
	:	( set )=> set
;
..should work.

The syntactic predicate ( entity )=>  returns false whereas it should
return true. When there is no syntactic predicate, the rule is matched.

Important : Before ( modif 1 ), the syntax could have been validated by
both syntactic predicates ( entity )=>, ( set )=>, in that case, the
alternative 1 is chosen, because it is the first alternative. In the
parser i have rules that can be matched by more than one syntactic
predicate, in which case the first matched alternative is selected.

My conclusion is:
"When the syntax is OK, The syntactic predicate does not 'allways'
validate the rule, in tree parsers."

I join the C++ tree parser generated file, that contains the wrong
syntactic predicate (the on that rise the problem).

Here is a sample of my tree parser with mistakes (that rise the
syntactic predicate problem)...

entOrSet
	:	( entity )=> entity	// replaced by ( R_ENT )=>
entity
	|	( set )=> set		// replaced by ( R_SET )=> set; 

entity
	:	#( R_ENT entityComponentList )
;

set
	:	#( R_ENT setComponentList ) 	// replaced by #( R_SET
setComponentList )
;

entityComponentList
	:	( entityComponent )+
;

setComponentList
	:	( entityComponent | setComponent )+
;

entityComponent
	:	#( R_ENC component )
;

setComponent
	:	#( R_SEC component )  // Ric Klaren : Here is the
difference that would premit
                                  // the syntactic predicate of the rule
entOrSet 
;

component
	:	i:IDENTIFIER ("WHERE" entAttSetList)?
	{ cout << i->getText() << endl; }
; 

CHEERS,
Anthony

 

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: CIAOWalker.zip
Type: application/x-zip-compressed
Size: 9599 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20030220/5e991908/CIAOWalker.bin


More information about the antlr-interest mailing list