开发者

Get lexeme of a composite rule in ANTLR3

开发者 https://www.devze.com 2023-01-28 15:42 出处:网络
Let\'s say I\'ve something like: rule:(rule2 | rule3) {;}; //How can i get at this point rule2 or rule3 text?

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

精彩评论

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

关注公众号