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;}
  ;
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论