Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Parsing expressions without context
Parsing expressions without context [message #650009] Fri, 21 January 2011 12:45 Go to next message
Robert Missing name is currently offline Robert Missing nameFriend
Messages: 11
Registered: July 2009
Junior Member
Would it be possible to parse an OCL expression using MDT-OCL without the the need to specify the context or UML model associated to the expression? I am interested in analyzing the abstract syntax of a group of OCL expressions. For this activity, I don't really need of the context of the expressions, but rather just the parsed representations of the expressions. It seems that MDT-OCL requires the context in order to parse any OCL expression.
Re: Parsing expressions without context [message #650011 is a reply to message #650009] Fri, 21 January 2011 12:52 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 21.01.2011 13:45, schrieb Robert:
> Would it be possible to parse an OCL expression using MDT-OCL without the the need to specify the context or UML model associated to the expression? I am interested in analyzing the abstract syntax of a group of OCL expressions. For this activity, I don't really need of the context of the expressions, but rather just the parsed representations of the expressions. It seems that MDT-OCL requires the context in order to parse any OCL expression.
I think you can use a static context in most places, e.g. MyPackage.LITERALS.MY_CLASS.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: Parsing expressions without context [message #650027 is a reply to message #650011] Fri, 21 January 2011 13:56 Go to previous messageGo to next message
Robert Missing name is currently offline Robert Missing nameFriend
Messages: 11
Registered: July 2009
Junior Member
But wouldn't I still need to define the classes like MY_CLASS in the example? I would like to take OCL expressions from many different sources, collect them altogether into one file, and analyze their structure or syntax without having to include the model associated to these different expressions. Is this possible in MDT-OCL?
Re: Parsing expressions without context [message #650308 is a reply to message #650027] Mon, 24 January 2011 10:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Robert

For JUnit tests MDT/OCL often uses a null context, though older code may
NPE on this in which case you can use any old irrelevant class. Try
EcorePackage.Literals.EINVOCATION_TARGET_EXCEPTION.

Regards

Ed Willink


On 21/01/2011 13:56, Robert wrote:
> But wouldn't I still need to define the classes like MY_CLASS in the
> example? I would like to take OCL expressions from many different
> sources, collect them altogether into one file, and analyze their
> structure or syntax without having to include the model associated to
> these different expressions. Is this possible in MDT-OCL?
Re: Parsing expressions without context [message #650726 is a reply to message #650308] Wed, 26 January 2011 09:45 Go to previous messageGo to next message
Robert Missing name is currently offline Robert Missing nameFriend
Messages: 11
Registered: July 2009
Junior Member
Is there a specific JUnit that you could direct me to that does this? I looked at some tests, but it seems that an artificial context is still being setup (e.g., org.eclipse.ocl.tests.GenericKeywordsTest and org.eclipse.ocl.tests.GenericIteratorsTest).

Would another (better) option be to use the concrete syntax instead (like in org.eclipse.ocl.tests.GenericParserBacktrackingTest)? My goal is to compare expressions using some type of structural representation.
Re: Parsing expressions without context [message #650737 is a reply to message #650726] Wed, 26 January 2011 10:22 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Robert

The new model-driven standard library support was promoted from its
branch a couple of days ago.

It has a much more library operation focussed set of tests, that now
demonstrate that numerous awkward corner cases no pass.

org.eclipse.ocl.examples.test.generic.GenericEvaluateCollect ionOperationsTest
demonstrates a null context.

Tests using assertQueryResults demonstrate the use of OCL to define both
expression under test and expected result.

e.g.

assertQueryResults(null, "Sequence{1..3,6..9}",
"Sequence{1..4,6,7..9}->excluding(4)");

context: null ,
expected result: "Sequence{1..3,6..9}"
testing: "Sequence{1..4,6,7..9}->excluding(4)"

[The aim is to have org.elipse.ocl.examples.pivot available as a full
alternative to org.elipse.ocl.ecore or org.elipse.ocl.uml for MDT/OCL
3.1.0 (Indigo), with promotion occurring to org.elipse.ocl.pivot in
MDT/OCL 4.0.0 (Indigo+1) with the Ecore/UML bindings increasingly
deprecated. The promotion is timed to align with Xtext changing to 2.0
for Indigo M5 in a week. Hopefully M5 wil support a clean installation;
until then piecing the M4 plus a bit contributions together may be hard.]

Regards

Ed Willink


On 26/01/2011 09:45, Robert wrote:
> Is there a specific JUnit that you could direct me to that does this?
> I looked at some tests, but it seems that an artificial context is
> still being setup (e.g., org.eclipse.ocl.tests.GenericKeywordsTest and
> org.eclipse.ocl.tests.GenericIteratorsTest).
>
> Would another (better) option be to use the concrete syntax instead
> (like in org.eclipse.ocl.tests.GenericParserBacktrackingTest)? My goal
> is to compare expressions using some type of structural representation.
Re: Parsing expressions without context [message #666602 is a reply to message #650737] Thu, 21 April 2011 09:36 Go to previous message
miguelafr  is currently offline miguelafr Friend
Messages: 9
Registered: April 2011
Junior Member
Where can I download the source code of org.eclipse.ocl.examples.test.generic.GenericEvaluateCollect ionOperationsTest from?

I need to do the same as Robert, that is, parsing an OCL expression without a context. Thus, I could transform an OCL expression into Java objects in order to process them. And I do not need to associate any Java class to the OCL expression, because in my case the OCL expressions will not refer to Java classes.
Previous Topic:Unresolved operation '<' for 'Ecore::ecore::EInt'
Next Topic:Retrieve literals from enum
Goto Forum:
  


Current Time: Thu Apr 18 19:08:25 GMT 2024

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

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

Back to the top