Thanks so much! Yes, I tried complement: object object? coincidentally just before I read your message and it worked. Good news is that in the real grammar they ARE actually equivalent. But is there no way of making 'indirectObject' and 'object' appear as they are in the end structure if there are 2 'object's in a row (they have slightly different meanings even though syntactically the same)? Would a syntactic predicate solve this? For example, complement: (indirectObject object)=>indirectObject object | object; Is this the right one? (it doesn't seem to work on ANTLRWorks) Many many thanks, N
2009/10/1 Gavin Lambert <an...@mirality.co.nz> > At 23:13 1/10/2009, Naveen Chawla wrote: > >> 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." >> > > The problem with this is that at the left edge of complement, it needs to > evaluate whether indirectObject is present or not. To do that, it attempts > to match a nounPhrase, which will attempt to match an adjectivePhrase, which > brings it right back to the left edge of complement -- and since that's > optional too, it has to continue scanning forward into a death spiral. > > As written here, you should be able to fix it by switching the optionality > in the complement rule: > complement: object object?; > > I suspect that in your real grammar the indirectObject and object rules > aren't actually equivalent though, so this may not help much. :) > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com 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