[antlr-interest] Copying return value of a rule
Christian
chwchw at gmx.de
Tue Jan 31 12:52:03 PST 2012
Hi @all,
as one might know from common programming languages, a field declaration
looks like the following (here C#)
[attribute] public String name, text;
My corresponding rule looks as follows:
variable_declarators
: variable_declarator ( COMMA variable_declarator )*
-> ^(VARIABLE_DECLARATOR {$class_member_declaration::attrs}
{$class_member_declaration::members}
{$typed_member_declaration::type} variable_declarator)+
;
The first problem: Attributes and modifiers are optional, so I get an
EmptyStackException if one of the following action is not declared in
the corresponding upper rule. Can I somehow check whether the attrs and
members are defined?
The second problem: I do not know a good alternative. Passing e.g. type
through 3 or more rule levels is not maintainable. Furthermore, copying
the return value of the type rule for each field (here: name and text)
does not work. Any solution for that?
Regards,
Christian
More information about the antlr-interest
mailing list