Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Using a custom OCLAnalyzer
Using a custom OCLAnalyzer [message #53520] Thu, 03 April 2008 22:01 Go to next message
Stefan Schulze is currently offline Stefan Schulze
Messages: 70
Registered: July 2009
Member
Hi,

is it possible to use a custom OCLAnalyzer for parsing an expression?
I'd need it to trigger parsing (and possibly inlining) of my own operations
when the analyzer matches the corresponding OperationCallExp.

Bye,
Stefan
Re: Using a custom OCLAnalyzer [message #53547 is a reply to message #53520] Fri, 04 April 2008 08:00 Go to previous messageGo to next message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, Stefan,

The refactoring in the 1.2 release of the (formerly internal) OCLParser into
the current structure of AbstractOCLParser, OCLParser, AbstractOCLAnalyzer,
and OCLAnalyzer was contributed by the GMT UMLX project specifically in
order to support the construction of QVT parsers. As you probably know,
the QVT languages extend the syntax and semantics of OCL, so the
implementation in UMLX is probably a good example of what you can
accomplish by extending the OCLAnalyzer.

I would expect that you can achieve what you need by extending the
OCLAnalyzer, but I couldn't really answer definitively without more detail
of your case. You can also have a look at the QVTo component in the M2M
project, which implements the Operational QVT language as an extension to
MDT OCL, with evaluation of (among other things) custom operations and
QVT "queries."

HTH,

Christian


Stefan Schulze wrote:

> Hi,
>
> is it possible to use a custom OCLAnalyzer for parsing an expression?
> I'd need it to trigger parsing (and possibly inlining) of my own
> operations when the analyzer matches the corresponding OperationCallExp.
>
> Bye,
> Stefan
Re: Using a custom OCLAnalyzer [message #53728 is a reply to message #53547] Mon, 07 April 2008 18:26 Go to previous messageGo to next message
Stefan Schulze is currently offline Stefan Schulze
Messages: 70
Registered: July 2009
Member
Hi Christian,

I had a look at the QvtOperationalParser, but it looks like I have to
rewrite wide parts of org.eclipse.ocl.internal.helper.HelperUtil to utilize
my own OCLAnalyzer. I hoped I could do something like
setAnalyzer(myOclAnalyzer) or something to inject my own OCLAnalyzer into
the process of analyzing and parsing.

Stefan


"Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
news:ft558h$nf3$1@build.eclipse.org...
> Hi, Stefan,
>
> The refactoring in the 1.2 release of the (formerly internal) OCLParser
> into
> the current structure of AbstractOCLParser, OCLParser,
> AbstractOCLAnalyzer,
> and OCLAnalyzer was contributed by the GMT UMLX project specifically in
> order to support the construction of QVT parsers. As you probably know,
> the QVT languages extend the syntax and semantics of OCL, so the
> implementation in UMLX is probably a good example of what you can
> accomplish by extending the OCLAnalyzer.
>
> I would expect that you can achieve what you need by extending the
> OCLAnalyzer, but I couldn't really answer definitively without more detail
> of your case. You can also have a look at the QVTo component in the M2M
> project, which implements the Operational QVT language as an extension to
> MDT OCL, with evaluation of (among other things) custom operations and
> QVT "queries."
Re: Using a custom OCLAnalyzer [message #53755 is a reply to message #53728] Tue, 08 April 2008 02:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Stefan Schulze wrote:
> Hi Christian,
>
> I had a look at the QvtOperationalParser, but it looks like I have to
> rewrite wide parts of org.eclipse.ocl.internal.helper.HelperUtil to utilize
> my own OCLAnalyzer. I hoped I could do something like
> setAnalyzer(myOclAnalyzer) or something to inject my own OCLAnalyzer into
> the process of analyzing and parsing.
>
> Stefan

Typically the Analyzer constructs the Parser which constructs the Lexer which constructs KeywordLexer, so you need to intercept the
Analyzer construction to construct your alternative Analyzer.

The various helpers assist in some forms of usage, but are not obligatory. The QVTr and QVTc analyzers are used directly from a
QVTcTopLevelEnvironment that extends QVTTopLevelEnvironment that extends QVTEnvironment that extends CSTEnvironment that extends
EcoreEnvironment. Within the top level environment you just override:


@Override protected QVTcAnalyzer createAnalyzer() {
return new QVTcAnalyzer(this);
}

which suits QVT usage where parsing occurs on files rather than just evaluation occurring on expressions.

Provision of a modified Analyzer is relatively straightforward because the EssentialOCL analysis is provided in AbstractOCLAnalyzer.
OCLAnalyzer is an EssentialOCL extension to support 'Complete'OCL and is easily discarded. Many methods in AbstractOCLAnalyzer are
overrideable allowing extended or alternate semantics. Further refactoring may yet improve the modularity of override opportunities.

UMLX' QVTc and QVTr analyzers inherit just the EssentialOCL analysis.

UMLX also extends OCLAnalyzer with an OCLFileAnalyzer that supports usage of a file of concatenated OCL contexts.

A drop of UMLX is available from http://www.eclipse.org/gmt/umlx/download/. A new drop should be available shortly after GMF makes
it to M6. (The web pages are badly out of date and the Wiki non-existent.)

Regards

Ed Willink
Re: Using a custom OCLAnalyzer [message #53781 is a reply to message #53755] Tue, 08 April 2008 20:54 Go to previous message
Stefan Schulze is currently offline Stefan Schulze
Messages: 70
Registered: July 2009
Member
Hi Ed, Hi Christian,

thank you for your explanations.
I finally solved it by adding an additional pass with a custom visitor to
traverse the OperationCallExps and parse my custom operations.

Bye,
Stefan
Previous Topic:Evaluation of allInstances and self usage
Next Topic:[Announcement] Eclipse/OMG Symposium at the OMG Technical Meeting in Ottawa
Goto Forum:
  


Current Time: Thu Jul 31 17:59:18 EDT 2014

Powered by FUDForum. Page generated in 0.02216 seconds