我試圖創建一個開始的行令牌「‘getCharPositionInLine’的名稱在當前環境中不存在」發出錯誤如何檢測線的開頭,或:</p> <pre><code>lexer grammar ScriptLexer; BOL : {getCharPositionInLine() == 0;}; // Beginning Of Line token </code></pre> <p>但上面的:
The name 'getCharPositionInLine' does not exist in the current context
因爲它創建這樣的代碼:
private void BOL_action(RuleContext _localctx, int actionIndex) {
switch (actionIndex) {
case 0: getCharPositionInLine() == 0; break;
}
}
凡getCharPositionInLine()
方法d不存在...
也許嘗試'GetCharPositionInLine()'(PascalCase按照各種C#代碼指南推薦) – knittl
@knittl,試過了。沒有方法的名稱甚至類似於... – Tar
查看詞法分類:https://github.com/antlr/antlr4-csharp/blob/master/runtime/CSharp/Antlr4.Runtime/Lexer .cs裏面有一個'charPositionInLine',但我不太熟悉C#發佈一個答案(因此這個評論)。 –