理由を知りたい
expr:
a=(.*) 'ing' { System.out.println($a.text};
動作しません。
For one, you're missing );
in your embedded code. It's not:
{ System.out.println($a.text}
but:
{ System.out.println($a.text); }
You're also not really clear as to what "does not work" means, but I can make an educated guess. You're probably seeing null
printed to the console. This is because you cannot assign a label to .*
(a=(.*)
is invalid). What you can do is move what a
is supposed to point to, to a sub-rule:
expr
: a=sub_rule 'ing' { System.out.println($a.text); }
;
sub_rule
: /* ... something other than '.*' ... */
;
You should not be using .*
inside parser rules, unless you know exactly what you're doing.