代码之家  ›  专栏  ›  技术社区  ›  kitsune

有人能帮我把这个antlr 2.0语法文件转换成antlr 3.0语法吗?

  •  1
  • kitsune  · 技术社区  · 16 年前

    我已经转换了“简单”部分(片段、@header和@member 但因为我刚到安特尔,所以我很难 转换树语句等的时间。

    我用下面的 migration guide .

    The grammar file can be found here.

    下面你可以找到一些我遇到问题的例子:

    例如,我有以下问题:

    n3Directive0!:
                    d:AT_PREFIX ns:nsprefix u:uriref
                    {directive(#d, #ns, #u);}
                    ;
    

    propertyList![AST subj]
            : NAME_OP! anonnode[subj] propertyList[subj]
            | propValue[subj] (SEMI propertyList[subj])?
            |               // void : allows for [ :a :b ] and empty list "; .".
            ;
    
    propValue [AST subj]
            :  v1:verb objectList[subj, #v1]
                    // Reverse the subject and object
            |  v2:verbReverse subjectList[subj, #v2]
            ;
    
    subjectList![AST oldSub, AST prop]
            : obj:item { emitQuad(#obj, prop, oldSub) ; }
                    (COMMA subjectList[oldSub, prop])? ;
    
    objectList! [AST subj, AST prop]
            : obj:item { emitQuad(subj,prop,#obj) ; }
                    (COMMA objectList[subj, prop])?
        | // Allows for empty list ", ."
        ; 
    
    1 回复  |  直到 16 年前
        1
  •  1
  •   Bruno Ranschaert    16 年前
    n3Directive0!:
                    d=AT_PREFIX ns=nsprefix u=uriref
                    {directive($d, $ns, $u);}
                    ;
    
    • 您必须使用“=”进行分配。
    • 然后,标记可以用作“$tokenname.getText()”,…
    • 然后可以在代码中使用规则结果作为“rulename.result”
    • 如果有规则声明了结果名称,则必须使用这些名称iso。
      “结果”。