[antlr-interest] Re: exact matching verses sufficient matches plz help

lgcraymer lgc at mail1.jpl.nasa.gov
Tue Nov 23 00:35:08 PST 2004



This seems odd.  In this form, the synpreds within the rules aren't
very useful (there are no alternatives to disambiguate).  You should
be able to delete the synpreds and define check_rule as

check_rule
     :
     ( #( AND OR ) )=> and_implies
     |  check1
     ;

Try that and see what happens; also, take a look at the generated code
and see if it makes sense.  What is your target language?  This could
be a problem with the code generator's handling of synpreds.

--Loring

--- In antlr-interest at yahoogroups.com, Muhammad Masoom Alam
<doublemalam at y...> wrote:
> 
> Dear Michael
> 
> The problem is that i got no error
> 
> but wrong traversing of the tree is done by ANTLR e.g.
> 
> startrule
>         : (check_rule)+
>         ;
> check_rule
>           : and_implies
>           | check1 
>           ;
> and_implies
>           : 
>           ( #(AND #(OR and_implies) #(IMPLIES 
> implies_tree))) => #(AND #(OR and_implies) #(IMPLIES
> implies_tree))
> 
> ;
>  check1 
>        :
> 
> ( #(AND check)) => #(AND check #(IMPLIES
> implies_tree))
> 
> ;
> 
> 
> Problem
> 
> The problem is that always after matching the first
> node and that is the root node and AND it executes the
> first rule i.e and_implies and not check at all. even
> if the 2nd rule is applicable
> 
> This solution i have taken from ANTLR documentation
> which says some thing about the exact matching and
> sufficient matching.
> and even i remove the => sign and write the rule in
> original form , i cant parse the exact matching .
> 
> Error which comes
> <AST>:0:0: expecting "or", found 'And'
> 
> why i am saying that it performs sufficient matches,
> becaz if u remove the rule and_implies , it directly
> matches the check rule.
> 
> with Best regards.
> Muhammad.
> 
> 
> 
> 	
> 	
> 		
> ___________________________________________________________ 
> ALL-NEW Yahoo! Messenger - all new features - even more fun!
http://uk.messenger.yahoo.com





 
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