我想用Antlr 3編譯下來this grammar file(用於克里奧爾語wiki標記),但只是用Antlr工具(C#版本)和Java版本運行時發生內存泄漏堆空間:生成一個ANTLR語法文件時內存泄漏和崩潰
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)
是否有某種方法可以讓語法編譯?
您是否嘗試過增加Java堆和堆棧空間? – Apalala
@apalala它也是這樣做的。 Nett工具,但吃了5gb的ram –
@ChrisS。我在練習中面臨同樣的問題。這可以通過簡化語法來解決,而不會降低其功能。 (至於我,我可以嘗試重構它只爲一些賞金,對不起:)) – Andremoniy