2012-11-26 42 views
2

我試圖通過下列方式運行ANTLR 3.4 :如何在命令行中運行ANTLR 3.4?

java -classpath "d:\extracted\antlrworks1.4.3" org.antlr.Tool %p%\parser.g -o %p%\output 
or 
java -classpath "%p%lib\antlrworks-1.4.3.jar" org.antlr.Tool %p%\parser.g -o %p%\output 
or 
java -classpath "%p%lib\antlr-3.4.jar;%p%lib\antlr-runtime-3.4.jar;%p%lib\ST4-4.0.4.jar" org.antlr.Tool %p%\parser.g -o %p%\output 

Each of them resulted in the same error message; 

Message ILLEGAL_OPTION_VALUE in locale en_US not found 
Message ALL_OPS_NEED_SAME_ASSOC in locale en_US not found 
ANTLR installation corrupted; English messages file en.stg incomplete 
Exception in thread "main" java.lang.Error: ANTLR ErrorManager panic 
    at org.antlr.tool.ErrorManager.panic(ErrorManager.java:918) 
    at org.antlr.tool.ErrorManager.setLocale(ErrorManager.java:427) 
    at org.antlr.tool.ErrorManager.<clinit>(ErrorManager.java:390) 
    at org.antlr.tool.CompositeGrammar.createNFAs(CompositeGrammar.java:379) 
    at org.antlr.Tool.process(Tool.java:466) 
    at org.antlr.Tool.main(Tool.java:93) 

任何想法如何解決這一問題?

+0

消息說「ANTLR安裝已損壞」 - 您是否嘗試過再次下載它? – user1201210

回答

3

我不再使用v3,除了回答一些問題。我用

$ export CLASSPATH=.:/usr/local/lib/antlr-3.4-complete-no-antlrv2.jar 

一勞永逸,和 「編譯」 與

$ java org.antlr.Tool Question.g 

語法然後編譯

$ javac Question*.java Test.java 

然後執行

$ java Test 

精密:文件測試.java包含:

import org.antlr.runtime.*; 

public class Test { 
    public static void main(String[] args) throws Exception { 
     ANTLRInputStream input = new ANTLRInputStream(System.in); 
     QuestionLexer lexer = new QuestionLexer(input); 
     CommonTokenStream tokens = new CommonTokenStream(lexer); 
     QuestionParser parser = new QuestionParser(tokens); 
     parser.question(); 
    } 
} 
+0

謝謝,你幫了忙。 – Aftershock

+0

你知道v4更簡單更強大嗎?首先,請在ANTLR4書籍的討論標籤中查看_Antlr 3和4_ http://pragprog.com/book/tpantlr2/the-definitive-antlr-4-reference – BernardK

0

我想出了。 當前目錄必須與罐子的位置相同。