You are trying to be too literal and imply context in the rules. Complement has 
an optional indirectObject, which is a nounPhrase, followed by an object, which 
is also a nounPhrase, don't use two rule to ask for the same token sequence and 
then make one of them an optional lead in. Use object object? And imply that 
the first is an indirect object if the second is present. However, parsing 
English isn't as easy as this of course ;-)

 

Jim

 

From: [email protected] 
[mailto:[email protected]] On Behalf Of Naveen Chawla
Sent: Thursday, October 01, 2009 3:14 AM
To: [email protected]
Subject: [antlr-interest] Left factor? Syntactic predicates? Or another 
solution?

 

I am trying to write an English grammar with ANTLR and have simplified a 
particular problem to a particular subset for your convenience. (I'm using 
ANTLRWorks 1.3)

 

grammar predicate;


  
predicate : 'verb' complement?;

 

      complement: indirectObject? object;

              

                indirectObject :  nounPhrase;
    
                object : nounPhrase;

 
                               nounPhrase : 'the' adjectivePhrase? 'noun';

 

                                            adjectivePhrase : '<Ving>' 
complement?;

 

gives

 

"error(211): predicate.g:7:14: [fatal] rule complement has non-LL(*) decision 
due to recursive rule invocations reachable from alts 1,2.  Resolve by 
left-factoring or using syntactic predicates or using backtrack=true option."

 

Is somebody easily able to left-factor this while preserving the grammar? Or 
syntactically predicating if better? Sorry if I sound daft! I should say that 
taking away the "?" from either adjectivePhrase or indirectObject does not 
produce this error, but they are necessary.

 

Many thanks!

N 




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

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

Reply via email to