Ok, so I found out that if you want it bound to the latest thing, that is the "greedy" option, fortunately that is the way ANTLR automatically resolves such ambiguities by default. According to p.276 ch.11 "The Definitive ANTLR Reference": "ANTLR generates a warning, but you can safely ignore it".
Thanks. 2009/10/3 Naveen Chawla <naveen.c...@googlemail.com> > To be clear, I want prepPhr to always belong to the last occuring 'Ving' > (nounPhrase) before it (i.e. drinking-while-driving) > > 2009/10/2 Naveen Chawla <naveen.c...@googlemail.com> > > Hi, >> >> I'm a little bit stumped. You might find this easy. I'm trying to develop >> an English parser and have come across a real ambiguity in English, on >> which, for the time being, I just want to enforce simple right >> associativity: >> >> e.g. Recommending drinking while driving is dangerous. >> >> (Is it referring to the person driving while they are recommending >> drinking, or the person recommending drinking-during-driving?) >> >> This is not a problem. Since they are both equally valid in English, for >> the time being I just want to enforce right associativity (maybe later give >> a user option to change the tree), but I cannot figure out how!! Here is the >> grammar I want to make right-associative (simplified for your convenience): >> >> grammar prep; >> sentence: nounPhrase 'verb'; >> >> nounPhrase: 'Ving' complement? prepPhr?; >> >> complement : nounPhrase 'noun'? ; >> >> prepPhr: 'preposition' nounPhrase; >> >> >> Ambiguous sentence example: "Ving Ving preposition Ving verb" >> Ambiguity: "preposition" can be a prepPhr belonging to the first "Ving" >> (nounPhrase) OR the second "Ving" (nounPhrase). I want prepPhr to always >> belong to the last occurring 'Ving' (nounPhrase). So I want to >> enforce, using the example sentence (right associativity): >> >> sentence{ >> nounPhrase{ >> 'Ving' >> complement{ >> nounPhrase{ >> 'Ving' >> prepPhr{ >> 'preposition' >> nounPhrase{ >> >> >> 'Ving' >> } >> } >> } >> } >> } >> 'verb' >> } >> >> instead of >> >> sentence{ >> nounPhrase{ >> 'Ving' >> complement{ >> nounPhrase{ >> 'Ving' >> } >> } >> prepPhr{ >> 'preposition' >> nounPhrase{ >> 'Ving' >> } >> } >> } >> 'verb' >> } >> >> while preserving the grammar. >> Anybody have as easy idea how? Sorry if I sound newbie, I'm stumped. >> >> Regards, >> 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 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