Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL AST(OCL)
OCL AST [message #833020] Fri, 30 March 2012 17:46 Go to next message
HaoWu Missing name is currently offline HaoWu Missing name
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 06:54 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4014
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: Thu Jul 31 19:52:51 EDT 2014

Powered by FUDForum. Page generated in 0.02788 seconds