【问题标题】:ANTLR3 inject an int into my treeANTLR3 将一个 int 注入到我的树中
【发布时间】:2010-01-30 20:02:58
【问题描述】:

有可能做我在这里尝试的事情吗?或者,也许我处理错了?

arrayDef
  : { int c = 0; }
    ('['']' {c++;})+
  -> ARRAY /* somehow inject c here */
  ;

【问题讨论】:

    标签: antlr3 abstract-syntax-tree


    【解决方案1】:

    为什么不使用ARRAY 树节点的ChildCount?

    arrayDef
        :   ('[' ']')+
            -> ^(ARRAY '['+)
        ;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-30
      • 2017-09-10
      • 1970-01-01
      • 1970-01-01
      • 2012-06-27
      相关资源
      最近更新 更多