生成ANTLR语法文件时内存泄漏和崩溃

时间:2013-01-15 19:44:39

标签: antlr antlr3

我正在尝试使用Antlr 3编译this grammar file(对于Creole wiki标记),但只是使用Antlr工具(C#版本)获取内存泄漏,并且Java版本用尽堆空间:< / p>

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Unknown Source)
        at java.util.Arrays.copyOf(Unknown Source)
        at java.util.ArrayList.grow(Unknown Source)
        at java.util.ArrayList.ensureCapacityInternal(Unknown Source)
        at java.util.ArrayList.add(Unknown Source)
        at org.antlr.misc.OrderedHashSet.add(OrderedHashSet.java:67)
        at org.antlr.analysis.DFAState.addNFAConfiguration(DFAState.java:229)
        at org.antlr.analysis.NFAToDFAConverter.closure(NFAToDFAConverter.java:632)
        at org.antlr.analysis.NFAToDFAConverter.closure(NFAToDFAConverter.java:708)
        at org.antlr.analysis.NFAToDFAConverter.closure(NFAToDFAConverter.java:477)
        at org.antlr.analysis.NFAToDFAConverter.findNewDFAStatesAndAddDFATransitions(NFAToDFAConverter.java:296)
        at org.antlr.analysis.NFAToDFAConverter.convert(NFAToDFAConverter.java:110)
        at org.antlr.analysis.DFA.<init>(DFA.java:237)
        at org.antlr.tool.Grammar.createLookaheadDFA(Grammar.java:1355)
        at org.antlr.tool.Grammar.createLookaheadDFAs(Grammar.java:1119)
        at org.antlr.tool.Grammar.createLookaheadDFAs(Grammar.java:1069)
        at org.antlr.codegen.Target.performGrammarAnalysis(Target.java:118)
        at org.antlr.codegen.JavaTarget.performGrammarAnalysis(JavaTarget.java:54)
        at org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:286)
        at org.antlr.Tool.generateRecognizer(Tool.java:696)
        at org.antlr.Tool.process(Tool.java:509)
        at org.antlr.Tool.main(Tool.java:98)

有没有办法让语法编译?

1 个答案:

答案 0 :(得分:1)

ANTLR v3.2能够从该语法生成​​词法分析器和解析器。虽然有很多警告,但它确实生成了文件。