2013-01-15 48 views
1

我想用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) 

是否有某種方法可以讓語法編譯?

+0

您是否嘗試過增加Java堆和堆棧空間? – Apalala

+0

@apalala它也是這樣做的。 Nett工具,但吃了5gb的ram –

+0

@ChrisS。我在練習中面臨同樣的問題。這可以通過簡化語法來解決,而不會降低其功能。 (至於我,我可以嘗試重構它只爲一些賞金,對不起:)) – Andremoniy

回答

1

ANTLR v3.2能夠從該語法生成​​詞法分析器和分析器。儘管有很多警告,但它確實生成了這些文件。

+0

好吧,爲什麼不是3.5?有什麼不同? – Andremoniy

+0

所有版本都是開源的:你做* diff * :) –

+0

這個語法的作者說他們不再支持ANTLR,所以我可能不得不從頭開始用Antlr 4 –