use*_*816 5 java build antlr3 netbeans-7 ubuntu-12.04
我是 Java 和 ANTLR 的初学者。我正在尝试在 Netbeans IDE 中使用 ANTLR。我试图运行一个示例示例,并且确实遵循了所需的所有重要步骤,例如设置环境变量,包括 jar 文件和修改 built.xml。
但是当我尝试清理和构建我的应用程序时,我收到以下错误:
Error: Could not find or load main class org.antlr.Tool
Java Result: 1
Created dir: ../NetBeansProjects/AntlrTestApp/build/empty
Created dir: ../NetBeansProjects/AntlrTestApp/build/generated-sources/ap-source-output
Compiling 1 source file to ../NetBeansProjects/AntlrTestApp/build/classes
../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:24: error: cannot find symbol
grammarLexer lexer = new grammarLexer(input);
symbol: class grammarLexer
location: class AntlrTestApp
../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:24: error: cannot find symbol
grammarLexer lexer = new grammarLexer(input);
symbol: class grammarLexer
location: class AntlrTestApp
../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:26: error: cannot find symbol
grammarParser parser = new grammarParser(tokens);
symbol: class grammarParser
location: class AntlrTestApp
../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:26: error: cannot find symbol
grammarParser parser = new grammarParser(tokens);
symbol: class grammarParser
location: class AntlrTestApp
../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:29: error: cannot find symbol
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
symbol: class Main
location: class AntlrTestApp
../NetBeansProjects/AntlrTestApp/src/antlrtestapp/AntlrTestApp.java:31: error: cannot find symbol
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
symbol: class Main
location: class AntlrTestApp
6 errors
../NetBeansProjects/AntlrTestApp/nbproject/build-impl.xml:603: The following error occurred while executing this line:
../NetBeansProjects/AntlrTestApp/nbproject/build-impl.xml:244: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 1 second)
Run Code Online (Sandbox Code Playgroud)
自过去 2-3 天以来,我一直在尝试此方法,并搜索了所有可能的解决方案,但没有任何效果对我有用。
看起来您正在尝试在 Ant 构建期间从 ANTLR 3 语法自动生成解析器。以下 Ant 脚本显示了一个示例,其中包括以下功能:
.g文件,因此您不必每次添加语法时都编辑构建。https://github.com/antlr/antlr4/blob/master/build.xml