Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL AST(OCL)
OCL AST [message #833020] Fri, 30 March 2012 21:46 Go to next message
HaoWu Missing name is currently offline HaoWu Missing nameFriend
Messages: 5
Registered: August 2010
Junior Member
Hi,
Does anyone know how to parse an OCL file into a full AST. I have a model in ecore format, and an external OCL file. How can I use API to parse this ocl file into a full AST with knowing the knowledge of the model. Also how can i traverse the AST tree, and i know u can do it with a visitor pattern. But are there any examples to show how to do that. I mean a full example will be great. Any ideas?


Thanks very much.
Re: OCL AST [message #833362 is a reply to message #833020] Sat, 31 March 2012 10:54 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The AST for a Complete OCL document is currently unspecified.

The new Pivot binding for Eclipse OCL prototypes a solution for this
oversight. Each Complete OCL document is parsed into parallel packages
that have very normal structure.

The older Ecore/UML bindings supported visitors for the OCL AST but not
for the Ecore structure. The new Pivot binding supports visitors uniformly.

So, you can solve the problem using the older code but the structures
you traverse will be a bit pragmatic. The new code is more uniform but
technically still experimental and a good API facade has yet to be done.

If you look at
org.eclipse.ocl.examples.test.xtext.ImportTests.testImport_CompleteOCL_Ecore()
you will have a fileResource that is what you want.

To see a visitor at work look at
org.eclipse.ocl.examples.pivot.prettyprint.PrettyPrintNameVisitor.prettyPrint().

Regards

Ed Willink

On 30/03/2012 22:46, HaoWu Mising name wrote:
> Hi,
> Does anyone know how to parse an OCL file into a full AST. I have a
> model in ecore format, and an external OCL file. How can I use API to
> parse this ocl file into a full AST with knowing the knowledge of the
> model. Also how can i traverse the AST tree, and i know u can do it
> with a visitor pattern. But are there any examples to show how to do
> that. I mean a full example will be great. Any ideas?
>
>
> Thanks very much.
Previous Topic:derived attribute in OCLinEcore editor
Next Topic:How to define an OCL constraint for a modelElements association relationship
Goto Forum:
  


Current Time: Wed Apr 24 21:24:09 GMT 2024

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

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

Back to the top