Compiling a larger grammar takes forever [message #756639] |
Mon, 14 November 2011 14:49 |
Hannes F Messages: 7 Registered: November 2011 |
Junior Member |
|
|
Hello Guys!
I've converted a large grammar for the Arden Syntax from a SableCC-compatible form to xText. I mainly changed the grammar syntax and solved left-recursion to accomplish this. Also I added names to a couple of rule calls because in several rules, I got the warning "An unassigned rule call is not allowed when the 'current' is already created." .
The code basically is a valid LL(1)-grammar though it seems it is not a valid xCode grammar because of the problem presented below.
Aside from some warnings of the kind "The rule ... may be consumed without object instantiation...", the code validates fine.
But my problem is, when I try to generate the xText Artifacts, the compiler takes a really long time and does not finish. Once it ran for 6 hours, but it did not complete, so I canceled it.
Because the grammar is really big, I attached the project as a .zip file instead of copying it into this post.
Do you have any ideas how I can get the grammar compiled?
Maybe adding further names to rule calls or anything else?
Edit: I know that there are several Java Errors but I think they should be gone after code generation completes.
[Updated on: Mon, 14 November 2011 14:54] Report message to a moderator
|
|
|
Re: Compiling a larger grammar takes forever [message #756729 is a reply to message #756639] |
Mon, 14 November 2011 20:37 |
Meinte Boersma Messages: 434 Registered: July 2009 Location: Leiden, Netherlands |
Senior Member |
|
|
The ANTLR generation phase when generating the content assist parser exhibits continuous time outs. Along with all the other ANTLR errors which are given for the regular, full-blown parser this indicates that the generated ANTLR grammar is actually broken. This is not really surprising as the Xtext grammar itself is extremely "non-Xtext-y": Xtext is an abstraction over ANTLR (and LL(*), in general) but that also means that you have to take of proper feature assignment for Xtext to be able to do proper generation to an ANTLR grammar, which you are doing almost nowhere - it'd also take care of the "The rule ... may be consumed without object instantiation..." warnings and "An unassigned rule call is not allowed when the 'current' is already created." errors. Also, the layering into 2 grammars which only have terminal definitions is understandable in the light of other parser techniques but unpractical in the Xtext 'verse.
I think you should step back a bit and do a very small DSL from scratch in Xtext or study a few basic examples, in order to gain some more understanding of Xtext. From what I can see, the grammar's not that huge and should be processed within a minute or so on a decent machine. And I think by "adding further names to rule calls" you actually mean feature assignment - in which case, the answer is "yes, that would definitely help".
Xtext blogs: executable models...again? | workshop material | custom scoping with Xtend
|
|
|
|
|
|
Re: Compiling a larger grammar takes forever [message #756899 is a reply to message #756869] |
Tue, 15 November 2011 13:22 |
Meinte Boersma Messages: 434 Registered: July 2009 Location: Leiden, Netherlands |
Senior Member |
|
|
I'm pretty sure the generated lexer can still have severe performance problems (both runtime and while generating) with "small" terminals or large sets of terminals which have common prefixes, since the lexer effectively tries all of the terminals in sequence and doesn't employ, e.g., an efficient trie structure. One case where this applies is parsing XML/SGML - this and the fact that tag keywords occurring in PCDATA and entity references are lexed as keywords and not as texts, made me write a generic SGML lexer: see https://github.com/dslmeinte/Xtext2-DSLs - I'll write a blog about it one day as well.
Especially since Xtext2.x has some support for syntactic predicates, I don't see much reason why a well-behaved (and properly lexed) grammar would need the ANTLR backtracking switched on.
Xtext blogs: executable models...again? | workshop material | custom scoping with Xtend
[Updated on: Tue, 15 November 2011 13:24] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04474 seconds