Search This Blog

Tuesday, June 10, 2014

Increase conversion time for xtext parsing - Time out error

When dealing with complex Xtext, some times you end up with the below error.
error(10): internal error: org.antlr.tool.Grammar.createLookaheadDFA(Grammar.java:864): could not even do k=1 for decision 135
Increasing the amount of memory available to the JVM is the first thing you will have to do when dealing with complex grammars. That however doesn't help in this case. That's because this error is due to a timeout inside the ANTLR generator (which converts xtext to antlr) which by default kicks in after 1000ms. After that ANTLR gives up on creating a DFA for your grammar and you may end up with the error message above.


So the solution is to increase your conversion time. This change has to be done in the mw2e workflow or launch configuration.

There is a fragment configured for XtextAntlrGeneratorFragment and XtextAntlrUiGeneratorFragment . Add the antlr param '-Xconversiontimeout ' to them.
fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject {
      antlrParam = "-Xconversiontimeout" antlrParam = "30000"
      options = {
            backtrack = true
      }
}

fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {
      antlrParam = "-Xconversiontimeout" antlrParam = "30000"
}
More antlr options can be found here.

No comments:

Post a Comment