Search code examples
cgrammarantlr3xtext

Debug Xtext could not even do k=1 for decision errors


I'm trying to create an Xtext parser for a scripting language that I use. The language is quite close to ANSI-C.

I started by converting this https://github.com/antlr/examples-v3/blob/master/C/C/C.g grammar to Xtext and removing the parts I don't need (structs, typedefs, etc.)

However, I run into problems and I don't know how to debug them properly and find my errors. I receive

error(10): internal error: org.antlr.tool.Grammar.createLookaheadDFA(Grammar.java:1279): could not even do k=1 for decision 39; reason: timed out (>10000ms)

and also OutOfMemoryError exceptions.

EDIT: I have already tried increasing the memory & timeout. However, even with LARGE values, this does not work.

Can anyone suggest ways to "debug" the grammar? Where is decision 39? I would love to locate the problem, but I couldn't find anything.

PS: I've posted the grammar listing here, to not clutter the post up http://pastebin.com/8AYNUbSD


Solution

  • You can generate an Antlr grammar (.g) by activating debug mode in your workflow.mwe2, add the following fragment:

    fragment = org.eclipse.xtext.generator.parser.antlr.DebugAntlrGeneratorFragment {}
    

    Then, you can debug this debug grammar by using AntlrWorks IDE Quick tutorial here