At 13:45 13/08/2009, Tim Williams wrote:
 >For the scopedClause rule below, I'm getting this error(132):
 >"$scopedClause is ambiguous; rule scopedClause is enclosing rule 

 >and referenced in the production (assuming enclosing rule)"
[...]
 >scopedClause: 
 >      LPAREN (scopedClause->scopedClause) ((OR_TOKEN s2=scopedClause) 

 >->
 >^(OR $scopedClause $s2))+ RPAREN
 >    | LPAREN (scopedClause->scopedClause) ((AND_TOKEN
 >s2=scopedClause)
 >-> ^(AND $scopedClause $s2))+ RPAREN
 >    | LPAREN (scopedClause->scopedClause) ((NOT_TOKEN
 >s2=scopedClause)
 >-> ^(NOT $scopedClause $s2))+ RPAREN
 >      | searchClause
 >              -> searchClause
 >      ;

I think the warning will go away if you explicitly label the first 
path -- ie. replace all of your (scopedClause->scopedClause) 
fragments with (s1=scopedClause->$s1).  (Using $scopedClause in 
the second rewrite is correct though, and should be left like 
that.)

You could, however, improve performance by first left factoring 
it:

scopedClause
   :  LPAREN (s1=scopedClause -> $s1)
      (  OR_TOKEN s2=scopedClause -> ^(OR $scopedClause $s2)
      |  AND_TOKEN s2=scopedClause -> ^(AND $scopedClause $s2)
      |  NOT_TOKEN s2=scopedClause -> ^(NOT $scopedClause $s2)
      )+ RPAREN
   |  searchClause -> searchClause
   ;

(Although that begs the question: is NOT really a binary operator 
in your language?  And is 'LPAREN searchClause RPAREN' supposed to 
be illegal?  Because as it stands, both are the case.)


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to