开发者

Get lexeme of a composite rule in ANTLR3

Let's say I've something like:

rule:  (rule2 | rule3) {;}; //How can i get at this point rule2 or rule3 text?
rule2: HELLO+;
rule3: WORLD*;

I want to get the rule2 or rule3 text but all i get is a type_return that only gi开发者_运维问答ves me a start and a stop.

Any ideas?


Try:

rule
  :  r=(rule2 | rule3) {String txt = $r.text;}
  ;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜