Thanks! 2009/10/1 Gavin Lambert <an...@mirality.co.nz>
> At 01:24 2/10/2009, Naveen Chawla wrote: > >> 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 >> > > Which rules it passes through shouldn't have any bearing on the semantic > meaning; the rules should just be concerned with matching logical units of > tokens. > > You can assign different meanings to the objects via altering the output > AST, eg: > > complement > : (o1=object -> ^(DIRECT $o1)) > (o2=object -> ^(INDIRECT_DIRECT $o1 $o2))? > ; > (There are lots of other possible tree layouts, of course.) > > If you're carrying out some action directly rather than outputting an AST, > you can still use a similar technique (putting some of the code inside the > optional block) to get different behaviour if the second object is actually > present. > > --~--~---------~--~----~------------~-------~--~----~ 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