2015-06-27 30 views
1

我正在尝试将Python 3语法的嵌入式java部分(https://github.com/antlr/grammars-v4/blob/master/python3/Python3.g4)实现到C#。有几个属性是我在java中使用的,我无法在ANTLR4的C#运行时实现中找到它。在Python语法中将ANTLR4嵌入式java转换为C#

有人可以请我指出以下什么是等效的C#属性?

行100:

private CommonToken commonToken(int type, String text) { 
    int stop = this.getCharIndex() - 1; 
    int start = text.isEmpty() ? stop : stop - text.length() + 1; 
    return new CommonToken(this._tokenFactorySourcePair, type, DEFAULT_TOKEN_CHANNEL, start, stop); 
    } 

在这里,我无法找到_tokenFactorySourcePair属性

行132:

boolean atStartOfInput() { 
    return super.getCharPositionInLine() == 0 && super.getLine() == 1; 
    } 

在这里,我无法找到getCharPositionInLine()属性

回答

0

我从Gi获得Antlr4汇编源代码thub并将其添加到我的项目中。这些属性存在但是是私有的。我只是改变了这一点,并解决了这个问题。

0

看来_tokenFactorySourcePair已经在Lexer上制作为protected在目前的Antlr4版本中应该自行解决。

getCharPositionInLine()的财产等同物为Lexer.Column