Home » Modeling » TMF (Xtext) » Xtext hangs
Xtext hangs [message #879696] |
Thu, 31 May 2012 12:59  |
Eclipse User |
|
|
|
I have this grammar:
grammar org.xtext.example.mydsl1.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "some link I can not post in the forum"
Model:
elems+=MyRule*;
MyRule:
'++' MyRule {MyRule.left = current} name = ID
|'--' MyRule {MyRule.left = current} name = ID
|'..' MyRule {MyRule.left = current} name = ID
;
The valid input I want to be is like this one:
"++ child1 ++ parent1 -- parent2"
Ans I want to get a tree like this:
name = parent2, left = {name = parent1, left = {name = child1, left = null}}
When I try to run MWE2, Xtext hangs just after "Registered GenModel".
when the third line in MyRule is deleted generating infrastructure works fine but the language does not work (I have many exceptions in runtime, the first is "The activator org.xtext.example.mydsl.ui.internal.MyDslActivator for bundle org.xtext.example.mydsl.ui is invalid") and the input "++ Hi" is not parsed correctly. What's wrong in the grammar?
|
|
|
Re: Xtext hangs [message #879739 is a reply to message #879696] |
Thu, 31 May 2012 14:52   |
Eclipse User |
|
|
|
Well, there are several things that are a bit odd...
On 2012-31-05 18:59, Oleg Bolshakov wrote:
> I have this grammar:
> grammar org.xtext.example.mydsl1.MyDsl with
> org.eclipse.xtext.common.Terminals
>
> generate myDsl "some link I can not post in the forum"
>
> Model:
> elems+=MyRule*;
>
> MyRule:
> '++' MyRule {MyRule.left = current} name = ID
> |'--' MyRule {MyRule.left = current} name = ID
> |'..' MyRule {MyRule.left = current} name = ID
> ;
>
Given input ++a ++a is that two MyRule instances added to Model.elems or
one? (Now it is ambiguous)
You do not remember the operator ++, -- or .. there is no trace of those
in the resulting AST.
> The valid input I want to be is like this one:
> "++ child1 ++ parent1 -- parent2"
>
> Ans I want to get a tree like this:
> name = parent2, left = {name = parent1, left = {name = child1, left =
> null}}
>
How is the recursion supposed to end? You expect a null MyRule.left to
be at the end, but how would it ever get there since all the pre-ops
(++, --, ..) require that they are followed by a MyRule.
Did you perhaps want something like this:
Model : elems = CompoundMyRule?
CompoundMyRule : MyRule ({MyRule.left = current} MyRule)* ;
MyRule : op = ('++' |'--' |'..') name = ID ;
i.e. the last found MyRule is returned at the top of the result tree.
If there is only one, that MyRule has left == null.
> When I try to run MWE2, Xtext hangs just after "Registered GenModel".
> when the third line in MyRule is deleted generating infrastructure works
> fine but the language does not work (I have many exceptions in runtime,
> the first is "The activator
> org.xtext.example.mydsl.ui.internal.MyDslActivator for bundle
> org.xtext.example.mydsl.ui is invalid") and the input "++ Hi" is not
> parsed correctly. What's wrong in the grammar?
Not surprising, the grammar is highly ambiguous, and it looks like it
requires an infinite input to be able to parse a MyRule :).
- henrik
|
|
| | |
Re: Xtext hangs [message #879816 is a reply to message #879804] |
Thu, 31 May 2012 18:24   |
Eclipse User |
|
|
|
I have
-Xmx2000m
for a complex grammar I worked on.
When you say it hangs - how long did you wait? There is a timeout
eventually, I forgot how long it is. I had a problem that the timeout
was to short so I had to bump it. (Since then I have simplified my
grammar considerably).
If you increase memory you may get a decent error message (or a working
grammar).
Do you have backtracking turned on? If you have and grammar is complex
you may hit the timeout and you get a grammar that is not what you expect.
I really don't know why what you wrote becomes very complex to solve.
Have you tried if you combine all of the operators into one?
i.e.
MyRule:
NameRule
| op = ('++'['--'|'..') MyRule {MyRule.left = current} right = ID
;
You really do need to remember the operator anyway, and there is no
difference between the rules. Even if you don't want that (for other
reasons), you could try it and see if that reduced the complexity enough
to get some other feedback (or a working parser).
I suspect you have more things in your grammar than just this. Is it
perhaps just an illustration of the problem? Often problems are
"elsewhere" in a complex grammar, and it would help if you posted the
entire grammar.
anyway... hope the above helps you.
- henrik
On 2012-31-05 23:48, Oleg Bolshakov wrote:
> I was really wrong about the tree and yes, the grammar makes input as
> though to be infinite.
> Sebastian, I didn't increase memory and am not sure how to do it
> properly, if you mean new Eclipse configurations, so there seem to be
> default VM parameters for my Eclipse: "-Dosgi.requiredJavaVersion=1.5
> -Xms40m -Xmx384m".
>
> Henrik, thank you for you version of grammar, it's not ambiguous as mine.
> But what about this one grammar, hanging my Xtext too?
> Model:
> elems+=MyRule*;
>
> MyRule:
> NameRule
> |'++' MyRule {MyRule.left = current} right = ID
> |'--' MyRule {MyRule.left = current} right = ID
> |'..' MyRule {MyRule.left = current} right = ID
> ;
>
> NameRule:
> name = ID
> ;
>
> Here MyRule is not infinite when after ther operator ('++'|'--'|'..')
> there is an ID (and one else ID for right part)
|
|
|
Re: Xtext hangs [message #879954 is a reply to message #879816] |
Fri, 01 June 2012 03:41   |
Eclipse User |
|
|
|
I've tried to increase amount of available Eclipse memory in eclipse.ini from -Xmx384m to -Xmx1000m, but Eclipse seem to not take more memory when generating workflow. I still have about 230 MB of memory in Eclipse.exe use and about 80 Mb of Javaw.exe (I have 2 GB on my PC and just the half is used actually in this moment by the whole system).
I waited for 10 minutes for the workflow to generate, but in vain.
what I see in console is:
0 [main] INFO lipse.emf.mwe.utils.StandaloneSetup - Registering platform uri '<link>'
1122 [main] INFO ipse.emf.mwe.utils.DirectoryCleaner - Cleaning <link>
1139 [main] INFO ipse.emf.mwe.utils.DirectoryCleaner - Cleaning <link>
1327 [main] INFO ipse.xtext.generator.LanguageConfig - generating infrastructure for org.xtext.example.mydsl1.MyDsl with fragments : ImplicitRuntimeFragment, ImplicitUiFragment, GrammarAccessFragment, EcoreGeneratorFragment, SerializerFragment, ResourceFactoryFragment, XtextAntlrGeneratorFragment, JavaValidatorFragment, ImportNamespacesScopingFragment, QualifiedNamesFragment, BuilderIntegrationFragment, GeneratorFragment, FormatterFragment, LabelProviderFragment, OutlineTreeProviderFragment, QuickOutlineFragment, QuickfixProviderFragment, JavaBasedContentAssistFragment, XtextAntlrUiGeneratorFragment, Junit4Fragment, TypesGeneratorFragment, XbaseGeneratorFragment, CodetemplatesGeneratorFragment, RefactorElementNameFragment, CompareFragment
3325 [main] INFO clipse.emf.mwe.utils.GenModelHelper - Registered GenModel '<link>' from '<link>/MyDsl.genmodel'
After this part of log for good grammars I used to see the message "generating Java-based EValidator API" which I get about in 2-3 seconds after the last line in above log.
This grammar...
MyRule:
NameRule
| op = ('++'['--'|'..') MyRule {MyRule.left = current} right = ID
;
...gets a syntax error: An unassigned rule call is not allowed, when the 'current' was already created.
This grammar...
MyRule:
NameRule
| ('++'['--'|'..') MyRule {MyRule.left = current} right = ID
;
...adds in about 3 seconds one error message in console: "constraint is INVALID for context MyRule_MyRule_1_2 and type NameRule" and then hangs Eclipse.
This grammar...
MyRule:
NameRule
| ('++'['--') MyRule {MyRule.left = current} right = ID
;
...does not hang Eclipse, adds the previously mentioned error message but after that generates validator and finishes fine in seconds.
The resulting editor seem to work, being able to parse this input "++ aa aa -- bb bb" and showing syntax error for "++ aa".
This grammar...
MyRule:
NameRule
| '++' MyRule {MyRule.left = current} right = ID
| '--' MyRule {MyRule.left = current} right = ID
;
does everything like the previous one but there is no error in workflow console.
The whole grammar listed in some above message is not used with any extra rules: I created an ampty Xtext project for experimenting with this simple grammars which make Xtext workflow generating process hang (when I said before "hangs Eclipse" I told just about workflow generation process that I can stop in, for example, console view).
P.S. But this Grammar seem to work (correct variant of Henrik's suggestion)!!
MyRule returns MyRule:
op = ('++' | '--' | '..') left = MyRule? right = ID
;
Yeah..so the point is that if you have some sort of prefix in grammar, when some rule may contain another inside - you should create an AST object as soon as you understood - you have a parent element and then you should just try to calculate the children by assigning its calling rule to a property of just created parent object. So it seems that our grammars were not correct, right?
[Updated on: Fri, 01 June 2012 06:43] by Moderator
|
|
|
Re: Xtext hangs [message #880053 is a reply to message #879954] |
Fri, 01 June 2012 06:36   |
Eclipse User |
|
|
|
Maybe something like this is what you want:
MyRule:
NameRule
| op=('++'|'--'|'..') right = ID
({MyRule.left == current}
op=('++'|'--'|'..') right=ID)*
;
NameRule : name = ID ;
Or
Rule : NameRule | MyRule ;
MyRule : op=('++'|'--'|'..') right = ID
({MyRule.left == current}
op=('++'|'--'|'..') right=ID)*
;
NameRule : name = ID ;
Regards
- henrik
On 2012-01-06 9:41, Oleg Bolshakov wrote:
> I've tried to increase amount of available Eclipse memory in eclipse.ini
> from -Xmx384m to -Xmx1000m, but Eclipse seem to not take more memory
> when generating workflow. I still have about 230 MB of memory in
> Eclipse.exe use and about 80 Mb of Javaw.exe (I have 2 GB on my PC and
> just the half is used actually in this moment by the whole system).
>
> I waited for 10 minutes for the workflow to generate, but in vain.
> what I see in console is:
> 0 [main] INFO lipse.emf.mwe.utils.StandaloneSetup - Registering platform
> uri '<link>'
> 1122 [main] INFO ipse.emf.mwe.utils.DirectoryCleaner - Cleaning <link>
> 1139 [main] INFO ipse.emf.mwe.utils.DirectoryCleaner - Cleaning <link>
> 1327 [main] INFO ipse.xtext.generator.LanguageConfig - generating
> infrastructure for org.xtext.example.mydsl1.MyDsl with fragments :
> ImplicitRuntimeFragment, ImplicitUiFragment, GrammarAccessFragment,
> EcoreGeneratorFragment, SerializerFragment, ResourceFactoryFragment,
> XtextAntlrGeneratorFragment, JavaValidatorFragment,
> ImportNamespacesScopingFragment, QualifiedNamesFragment,
> BuilderIntegrationFragment, GeneratorFragment, FormatterFragment,
> LabelProviderFragment, OutlineTreeProviderFragment,
> QuickOutlineFragment, QuickfixProviderFragment,
> JavaBasedContentAssistFragment, XtextAntlrUiGeneratorFragment,
> Junit4Fragment, TypesGeneratorFragment, XbaseGeneratorFragment,
> CodetemplatesGeneratorFragment, RefactorElementNameFragment,
> CompareFragment
> 3325 [main] INFO clipse.emf.mwe.utils.GenModelHelper - Registered
> GenModel '<link>' from '<link>/MyDsl.genmodel'
>
> After this part of log for good grammars I used to see the message
> "generating Java-based EValidator API" which I get about in 2-3 seconds
> after the last line in above log.
>
> This grammar...
> MyRule:
> NameRule
> | op = ('++'['--'|'..') MyRule {MyRule.left = current} right = ID
> ;
> ...gets a syntax error: An unassigned rule call is not allowed, when the
> 'current' was already created.
>
> This grammar...
> MyRule:
> NameRule
> | ('++'['--'|'..') MyRule {MyRule.left = current} right = ID
> ;
> ...adds in about 3 seconds one error message in console: "constraint is
> INVALID for context MyRule_MyRule_1_2 and type NameRule" and then hangs
> Eclipse.
>
> This grammar...
> MyRule:
> NameRule
> | ('++'['--') MyRule {MyRule.left = current} right = ID
> ;
> ...does not hang Eclipse, adds the previously mentioned error message
> but after that generates validator and finishes fine in seconds.
> The resulting editor seem to work, being able to parse this input "++ aa
> aa -- bb bb" and showing syntax error for "++ aa".
>
> This grammar...
> MyRule:
> NameRule
> | '++' MyRule {MyRule.left = current} right = ID | '--' MyRule
> {MyRule.left = current} right = ID
> ;
> does everything like the previous one but there is no error in workflow
> console.
|
|
| | | |
Re: Xtext hangs [message #880597 is a reply to message #880210] |
Sat, 02 June 2012 07:46  |
Eclipse User |
|
|
|
On 2012-01-06 18:25, Oleg Bolshakov wrote:
> I see now. You're right. How do you think, does it differ: {MyRule.left
> == current} op=('++'|'--'|'..')
New MyRule created with current as left, new MyRule becomes current, and
op is set in the new.
> from
> op=('++'|'--'|'..') {MyRule.left == current}?
> I suppose MyRule element to be created just when the operator was found.
op is set in the current MyRule, a new MyRule is then created with the
current as left.
The last ? does not make sense (optionally create new instance and
assign left...)
Regards
- henrik
|
|
|
Goto Forum:
Current Time: Sun Jul 06 20:46:08 EDT 2025
Powered by FUDForum. Page generated in 0.05319 seconds
|