Graham, I have a similar problem and scopes are working for me, but to do it I have to build the trees with code and don't have the trees building correctly, but do expect it to work.
My problem is that I have field definitions with names and also allow alias names for my field definitions. So I have to duplicate the field defintion less the name or alias names, then for each name or alias name build a new field defintion with either the name or the alias name. This is early development code, but hopefully this will give you some help. If you can do it without creating the trees in code you will be better off. fieldGroup scope { CommonTree info; CommonTree name; CommonTree alias; } @init { $fieldGroup::info = null; $fieldGroup::name = null; $fieldGroup::alias = null; } //@after { Console.WriteLine("fieldGroup: " + CommonTreeSuccour.ToStringTree((BaseTree)retval.Tree)); } : ^(FieldGroup fieldInfo fieldName generateFieldByName (fieldAlias generateFieldByAlias)*) -> generateFieldByName generateFieldByAlias* ; fieldInfo @after { $fieldGroup::info = (CommonTree)retval.Tree; } : ^(FieldInfo fieldInfoItems*) ; fieldName @after { $fieldGroup::name = (CommonTree)retval.Tree; } : ^(FieldName Id) ; generateFieldByName scope { CommonTree info; } @after { retval.Tree = $generateFieldByName::info; //Console.WriteLine("generateFieldByName: " + CommonTreeSuccour.ToStringTree((BaseTree)retval.Tree)); } : { $generateFieldByName::info = (CommonTree)adaptor.DupTree($fieldGroup::info); $generateFieldByName::info.Children.Add($fieldGroup::name); } ; fieldAlias @after { $fieldGroup::alias = (CommonTree)retval.Tree; } : ^(Alias qid) { $structDef::useLayoutOffset = true; } ; generateFieldByAlias scope { CommonTree info; } @after { retval.Tree = $generateFieldByAlias::info; //Console.WriteLine("generateFieldByAlias: " + CommonTreeSuccour.ToStringTree((BaseTree)retval.Tree)); } : { $generateFieldByAlias::info = (CommonTree)adaptor.DupTree($fieldGroup::info); $generateFieldByAlias::info.Children.Add($fieldGroup::alias); } ; Eric List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address -- 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-inter...@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.