Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Performance issues when using actions in expressions
Performance issues when using actions in expressions [message #560088] Tue, 21 September 2010 07:41 Go to next message
Roland S. is currently offline Roland S.Friend
Messages: 36
Registered: September 2009
Member
Hi there,

right now my grammar definition for expressions looks like this:



Expression:									
	
		firstoperator=Operator? firstvalue=BasicValue (moreexpressions+=BasicValueWithOperator)*;
 
BasicValueWithOperator:

		operator=Operator prefix=AddOp? value=BasicValue;



As you can see, expressions are just stored in a list.

When parsing this file:

https://svn.modelica.org/projects/Modelica/trunk/Modelica/Fl uid/Utilities.mo

the performance is acceptable (but far from good). The parser needs 2.1 seconds to parse the file.

Now I want to store the expressions in a tree-like way as explained by Sven Efftinge ( http://blog.efftinge.de/2010/08/parsing-expressions-with-xte xt.html).

My revised grammar then looks like this:


Expression:									
	
		BasicExpression ({Expression.left=current} operator=Operator prefix=AddOp? right=Expression)? ;
 

BasicExpression returns Expression:
 	
 		operator=Operator? value=BasicValue ;



The resulting AST is far better for post-processing (as checked with a smaller file). But the parser doesn't even stop parsing any more, when using the file from above.

I would be thankful for any hint solving this issue.

Regards,
Roland
Re: Performance issues when using actions in expressions [message #560102 is a reply to message #560088] Tue, 21 September 2010 08:37 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
The pattern Sven described would like this in your case:
Expression:									
	
		BasicExpression ({Expression.left=current} operator=Operator prefix=AddOp? right=BasicExpression)* ;
 

BasicExpression returns Expression:
 	
 		operator=Operator? value=BasicValue ;

I.e., the assignment to the 'right' feature calls BasicExpression instead of Expression. This might explain both the performance issue as well as the non-termination thing, but I haven't tried because you didn't provide the rest of the grammar (specifically the AddOp, Operator, BasicValue rules).


Re: Performance issues when using actions in expressions [message #560107 is a reply to message #560088] Tue, 21 September 2010 08:49 Go to previous message
Roland S. is currently offline Roland S.Friend
Messages: 36
Registered: September 2009
Member
That was indeed the problem!

Thanks for your reply.
Previous Topic:How to add assignments in expressions?
Next Topic:Content assist behaves differently with similar grammar definition
Goto Forum:
  


Current Time: Thu Apr 25 06:37:52 GMT 2024

Powered by FUDForum. Page generated in 0.03981 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top