我正在使用Antlrworks2。有词法语法有词法模式'在其中定义。 我结合语法导入lexer语法。从组合语法生成代码后,它将生成两个.java文件。例如:如果我的组合语法文件名是' xyz.g4' java文件名是' xyzLexer.java',' xyzParser.java'。但是当我点击“运行TestRig'在Antlrworks2中,它将通过控制台中的以下错误。
Compiling grammar files...
warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.modules.PatchedPublicProcessor' less than -source '1.7'
warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.ServiceProviderProcessor' less than -source '1.7'
warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.NamedServiceProcessor' less than -source '1.7'
warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.NbBundleProcessor' less than -source '1.7'
C:\Users\cc91kor\AppData\Local\Temp\TestRigTask-1361256016169\CDFCombinedGrammarLexer.java:144: error: cannot find symbol
case 1: _mode = INSIDE_BRACKETS; break;
^
symbol: variable INSIDE_BRACKETS
location: class CDFCombinedGrammarLexer
C:\Users\cc91kor\AppData\Local\Temp\TestRigTask-1361256016169\CDFCombinedGrammarLexer.java:149: error: cannot find symbol
case 0: _mode = INSIDE_BRACKETS; break;
^
symbol: variable INSIDE_BRACKETS
location: class CDFCombinedGrammarLexer
2 errors
4 warnings
Arguments: [CDFCombinedGrammar, vt, -tokens, -tree, -gui, C:\Users\cc91kor\Desktop\vt.txt]
Can't load CDFCombinedGrammar as lexer or parser
正如我在CDFCombinedGrammarLexer.java中观察到的那样(在上面的例子中是xyzLexer.java),' lexical mode'不在场。我可以在java文件中找到由实际词法分析器文件生成的模式代码。
下面是我在实际词法分析器生成的java文件中可以看到的代码。
public static final int INSIDE_BRACKETS = 1;
public static String[] modeNames = {
"DEFAULT_MODE", "INSIDE_BRACKETS"
};
对此有任何帮助???我在等待!!!
提前致谢!
答案 0 :(得分:0)
ANTLR 4尚不支持导入多模词法分析器语法。以下问题将跟踪此功能的进度: