Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » OCL compilation
OCL compilation [message #48987] |
Thu, 07 September 2006 05:37  |
Eclipse User |
|
|
|
Hello,
I would like to extends my meta-model with constraints AND new Operation.
I've chosen OCL language.
I have some trouble to compile OCL expressions.
I want to edit an ocl file like this :
package test
context TestClass def:
test1(t:String): String =
'coucou1'.concat(t)
def:
test2(t:String): String =
'coucou2'.concat(t)
endpackage
I've tried to compile these definition. the Parser send me an error :
misplace construct. I've rewritten the OCL with only one definition :
package test
context TestClass def:
test1(t:String): String =
'coucou'.concat(t)
endpackage
The parser compile this expression with success. And I can invoke test2
operation later, GREAT!
PROBLEM :
I would like to define and compile some OCL constraints or operation (inv
or def) from files. And call these operations or constraints from other
files or String like this
IOCLHelper helper = HelperUtil.createOCLHelper();
EObject context = (EObject)resource.getContents().get(0);
helper.setContext(TestPackage.eINSTANCE.getTestClass());
OCLExpression exp;
// where exp is the compilation of the OCL file with constraints and
operation
exp = ExpressionsFactory.eINSTANCE.createOCLExpression(expressionS tring);
System.out.println(helper.evaluate(context, "self.test1('toto')"));
System.out.println(helper.evaluate(context, "self.test2('toto')"));
** First I've look at the grammar in your OCL plugin (OCLLPGParser.g
:lpg grammar) and I think that this grammar block me (extended bnf
:notation):
package -> 'package' pathName context+ 'endpackage'
| context*
context -> classifierContext
| operationContext
| propertyContext
classifierContext -> context pathName invOrDef
....
* I would need this :
classifierContext -> context pathName invOrDef+
** Secondly I've tried to do this in another way, I've rewritten the code :
package test
context TestClass def:
test1(t:String): String =
'coucou1'.concat(t)
context TestClass def:
test2(t:String): String =
'coucou2'.concat(t)
endpackage
The parser accept this code but there's an exception thrown that tell me
that 'self' (context) can't be redefined.
The only solution that I saw is to re-run the parser with each new 'def'
or 'inv:'. I don't like this solution.
Please, Does anybody know how can I find the good way to compile OCL
Expressions?
Sorry for the long mail.
Thanks for any helps
Regards
Laurent
|
|
|
Re: OCL compilation [message #49196 is a reply to message #48987] |
Thu, 07 September 2006 15:29   |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Laurent,
You raise some good problems. You may want to add yourself to the cc list
of an existing bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=144210
regarding providing a public API for parsing OCL documents. Evidently, the
internal API that you are currently using also has problems.
Could you please raise bugs for:
- the problem in the grammar file of classifier context not replicating
invOrDefCS
- the exception complaining that the 'self' context cannot be redefined
I can't promise fixes in time for the 1.0.1 release, but we'll see.
Thanks,
Christian
Laurent Le Goff wrote:
> Hello,
> I would like to extends my meta-model with constraints AND new Operation.
> I've chosen OCL language.
> I have some trouble to compile OCL expressions.
> I want to edit an ocl file like this :
> package test
> context TestClass def:
> test1(t:String): String =
> 'coucou1'.concat(t)
> def:
> test2(t:String): String =
> 'coucou2'.concat(t)
> endpackage
>
> I've tried to compile these definition. the Parser send me an error :
> misplace construct. I've rewritten the OCL with only one definition :
> package test
> context TestClass def:
> test1(t:String): String =
> 'coucou'.concat(t)
> endpackage
>
> The parser compile this expression with success. And I can invoke test2
> operation later, GREAT!
>
> PROBLEM :
> I would like to define and compile some OCL constraints or operation (inv
> or def) from files. And call these operations or constraints from other
> files or String like this
>
> IOCLHelper helper = HelperUtil.createOCLHelper();
> EObject context = (EObject)resource.getContents().get(0);
> helper.setContext(TestPackage.eINSTANCE.getTestClass());
>
> OCLExpression exp;
> // where exp is the compilation of the OCL file with constraints and
> operation
> exp = ExpressionsFactory.eINSTANCE.createOCLExpression(expressionS tring);
> System.out.println(helper.evaluate(context, "self.test1('toto')"));
> System.out.println(helper.evaluate(context, "self.test2('toto')"));
>
> ** First I've look at the grammar in your OCL plugin (OCLLPGParser.g
> :lpg grammar) and I think that this grammar block me (extended bnf
> :notation):
>
> package -> 'package' pathName context+ 'endpackage'
> | context*
>
> context -> classifierContext
> | operationContext
> | propertyContext
>
> classifierContext -> context pathName invOrDef
> ...
>
> * I would need this :
>
> classifierContext -> context pathName invOrDef+
>
> ** Secondly I've tried to do this in another way, I've rewritten the code
> : package test
> context TestClass def:
> test1(t:String): String =
> 'coucou1'.concat(t)
> context TestClass def:
> test2(t:String): String =
> 'coucou2'.concat(t)
> endpackage
>
> The parser accept this code but there's an exception thrown that tell me
> that 'self' (context) can't be redefined.
>
> The only solution that I saw is to re-run the parser with each new 'def'
> or 'inv:'. I don't like this solution.
>
> Please, Does anybody know how can I find the good way to compile OCL
> Expressions?
>
> Sorry for the long mail.
> Thanks for any helps
>
> Regards
> Laurent
|
|
|
Re: OCL compilation [message #49234 is a reply to message #49196] |
Fri, 08 September 2006 03:53  |
Eclipse User |
|
|
|
hello Christian,
thanks for your answer. I entered bugs in bugzilla:
* grammar restriction
https://bugs.eclipse.org/bugs/show_bug.cgi?id=156656
* 'self' cannot be redefine
https://bugs.eclipse.org/bugs/show_bug.cgi?id=156657
I hope that bugs will have to be resolved in the next version ;-)
Regards
Laurent
Le Thu, 07 Sep 2006 15:29:00 -0400, Christian W. Damus a écrit :
>
> Hi, Laurent,
>
> You raise some good problems. You may want to add yourself to the cc list
> of an existing bug:
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=144210
>
> regarding providing a public API for parsing OCL documents. Evidently, the
> internal API that you are currently using also has problems.
>
> Could you please raise bugs for:
> - the problem in the grammar file of classifier context not replicating
> invOrDefCS
> - the exception complaining that the 'self' context cannot be redefined
>
> I can't promise fixes in time for the 1.0.1 release, but we'll see.
>
> Thanks,
>
> Christian
>
>
> Laurent Le Goff wrote:
>
>> Hello,
>> I would like to extends my meta-model with constraints AND new Operation.
>> I've chosen OCL language.
>> I have some trouble to compile OCL expressions.
>> I want to edit an ocl file like this :
>> package test
>> context TestClass def:
>> test1(t:String): String =
>> 'coucou1'.concat(t)
>> def:
>> test2(t:String): String =
>> 'coucou2'.concat(t)
>> endpackage
>>
>> I've tried to compile these definition. the Parser send me an error :
>> misplace construct. I've rewritten the OCL with only one definition :
>> package test
>> context TestClass def:
>> test1(t:String): String =
>> 'coucou'.concat(t)
>> endpackage
>>
>> The parser compile this expression with success. And I can invoke test2
>> operation later, GREAT!
>>
>> PROBLEM :
>> I would like to define and compile some OCL constraints or operation (inv
>> or def) from files. And call these operations or constraints from other
>> files or String like this
>>
>> IOCLHelper helper = HelperUtil.createOCLHelper();
>> EObject context = (EObject)resource.getContents().get(0);
>> helper.setContext(TestPackage.eINSTANCE.getTestClass());
>>
>> OCLExpression exp;
>> // where exp is the compilation of the OCL file with constraints and
>> operation
>> exp = ExpressionsFactory.eINSTANCE.createOCLExpression(expressionS tring);
>> System.out.println(helper.evaluate(context, "self.test1('toto')"));
>> System.out.println(helper.evaluate(context, "self.test2('toto')"));
>>
>> ** First I've look at the grammar in your OCL plugin (OCLLPGParser.g
>> :lpg grammar) and I think that this grammar block me (extended bnf
>> :notation):
>>
>> package -> 'package' pathName context+ 'endpackage'
>> | context*
>>
>> context -> classifierContext
>> | operationContext
>> | propertyContext
>>
>> classifierContext -> context pathName invOrDef
>> ...
>>
>> * I would need this :
>>
>> classifierContext -> context pathName invOrDef+
>>
>> ** Secondly I've tried to do this in another way, I've rewritten the code
>> : package test
>> context TestClass def:
>> test1(t:String): String =
>> 'coucou1'.concat(t)
>> context TestClass def:
>> test2(t:String): String =
>> 'coucou2'.concat(t)
>> endpackage
>>
>> The parser accept this code but there's an exception thrown that tell me
>> that 'self' (context) can't be redefined.
>>
>> The only solution that I saw is to re-run the parser with each new 'def'
>> or 'inv:'. I don't like this solution.
>>
>> Please, Does anybody know how can I find the good way to compile OCL
>> Expressions?
>>
>> Sorry for the long mail.
>> Thanks for any helps
>>
>> Regards
>> Laurent
|
|
|
Re: OCL compilation [message #590462 is a reply to message #48987] |
Thu, 07 September 2006 15:29  |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Laurent,
You raise some good problems. You may want to add yourself to the cc list
of an existing bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=144210
regarding providing a public API for parsing OCL documents. Evidently, the
internal API that you are currently using also has problems.
Could you please raise bugs for:
- the problem in the grammar file of classifier context not replicating
invOrDefCS
- the exception complaining that the 'self' context cannot be redefined
I can't promise fixes in time for the 1.0.1 release, but we'll see.
Thanks,
Christian
Laurent Le Goff wrote:
> Hello,
> I would like to extends my meta-model with constraints AND new Operation.
> I've chosen OCL language.
> I have some trouble to compile OCL expressions.
> I want to edit an ocl file like this :
> package test
> context TestClass def:
> test1(t:String): String =
> 'coucou1'.concat(t)
> def:
> test2(t:String): String =
> 'coucou2'.concat(t)
> endpackage
>
> I've tried to compile these definition. the Parser send me an error :
> misplace construct. I've rewritten the OCL with only one definition :
> package test
> context TestClass def:
> test1(t:String): String =
> 'coucou'.concat(t)
> endpackage
>
> The parser compile this expression with success. And I can invoke test2
> operation later, GREAT!
>
> PROBLEM :
> I would like to define and compile some OCL constraints or operation (inv
> or def) from files. And call these operations or constraints from other
> files or String like this
>
> IOCLHelper helper = HelperUtil.createOCLHelper();
> EObject context = (EObject)resource.getContents().get(0);
> helper.setContext(TestPackage.eINSTANCE.getTestClass());
>
> OCLExpression exp;
> // where exp is the compilation of the OCL file with constraints and
> operation
> exp = ExpressionsFactory.eINSTANCE.createOCLExpression(expressionS tring);
> System.out.println(helper.evaluate(context, "self.test1('toto')"));
> System.out.println(helper.evaluate(context, "self.test2('toto')"));
>
> ** First I've look at the grammar in your OCL plugin (OCLLPGParser.g
> :lpg grammar) and I think that this grammar block me (extended bnf
> :notation):
>
> package -> 'package' pathName context+ 'endpackage'
> | context*
>
> context -> classifierContext
> | operationContext
> | propertyContext
>
> classifierContext -> context pathName invOrDef
> ...
>
> * I would need this :
>
> classifierContext -> context pathName invOrDef+
>
> ** Secondly I've tried to do this in another way, I've rewritten the code
> : package test
> context TestClass def:
> test1(t:String): String =
> 'coucou1'.concat(t)
> context TestClass def:
> test2(t:String): String =
> 'coucou2'.concat(t)
> endpackage
>
> The parser accept this code but there's an exception thrown that tell me
> that 'self' (context) can't be redefined.
>
> The only solution that I saw is to re-run the parser with each new 'def'
> or 'inv:'. I don't like this solution.
>
> Please, Does anybody know how can I find the good way to compile OCL
> Expressions?
>
> Sorry for the long mail.
> Thanks for any helps
>
> Regards
> Laurent
|
|
|
Re: OCL compilation [message #590507 is a reply to message #49196] |
Fri, 08 September 2006 03:53  |
Eclipse User |
|
|
|
hello Christian,
thanks for your answer. I entered bugs in bugzilla:
* grammar restriction
https://bugs.eclipse.org/bugs/show_bug.cgi?id=156656
* 'self' cannot be redefine
https://bugs.eclipse.org/bugs/show_bug.cgi?id=156657
I hope that bugs will have to be resolved in the next version ;-)
Regards
Laurent
Le Thu, 07 Sep 2006 15:29:00 -0400, Christian W. Damus a écrit :
>
> Hi, Laurent,
>
> You raise some good problems. You may want to add yourself to the cc list
> of an existing bug:
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=144210
>
> regarding providing a public API for parsing OCL documents. Evidently, the
> internal API that you are currently using also has problems.
>
> Could you please raise bugs for:
> - the problem in the grammar file of classifier context not replicating
> invOrDefCS
> - the exception complaining that the 'self' context cannot be redefined
>
> I can't promise fixes in time for the 1.0.1 release, but we'll see.
>
> Thanks,
>
> Christian
>
>
> Laurent Le Goff wrote:
>
>> Hello,
>> I would like to extends my meta-model with constraints AND new Operation.
>> I've chosen OCL language.
>> I have some trouble to compile OCL expressions.
>> I want to edit an ocl file like this :
>> package test
>> context TestClass def:
>> test1(t:String): String =
>> 'coucou1'.concat(t)
>> def:
>> test2(t:String): String =
>> 'coucou2'.concat(t)
>> endpackage
>>
>> I've tried to compile these definition. the Parser send me an error :
>> misplace construct. I've rewritten the OCL with only one definition :
>> package test
>> context TestClass def:
>> test1(t:String): String =
>> 'coucou'.concat(t)
>> endpackage
>>
>> The parser compile this expression with success. And I can invoke test2
>> operation later, GREAT!
>>
>> PROBLEM :
>> I would like to define and compile some OCL constraints or operation (inv
>> or def) from files. And call these operations or constraints from other
>> files or String like this
>>
>> IOCLHelper helper = HelperUtil.createOCLHelper();
>> EObject context = (EObject)resource.getContents().get(0);
>> helper.setContext(TestPackage.eINSTANCE.getTestClass());
>>
>> OCLExpression exp;
>> // where exp is the compilation of the OCL file with constraints and
>> operation
>> exp = ExpressionsFactory.eINSTANCE.createOCLExpression(expressionS tring);
>> System.out.println(helper.evaluate(context, "self.test1('toto')"));
>> System.out.println(helper.evaluate(context, "self.test2('toto')"));
>>
>> ** First I've look at the grammar in your OCL plugin (OCLLPGParser.g
>> :lpg grammar) and I think that this grammar block me (extended bnf
>> :notation):
>>
>> package -> 'package' pathName context+ 'endpackage'
>> | context*
>>
>> context -> classifierContext
>> | operationContext
>> | propertyContext
>>
>> classifierContext -> context pathName invOrDef
>> ...
>>
>> * I would need this :
>>
>> classifierContext -> context pathName invOrDef+
>>
>> ** Secondly I've tried to do this in another way, I've rewritten the code
>> : package test
>> context TestClass def:
>> test1(t:String): String =
>> 'coucou1'.concat(t)
>> context TestClass def:
>> test2(t:String): String =
>> 'coucou2'.concat(t)
>> endpackage
>>
>> The parser accept this code but there's an exception thrown that tell me
>> that 'self' (context) can't be redefined.
>>
>> The only solution that I saw is to re-run the parser with each new 'def'
>> or 'inv:'. I don't like this solution.
>>
>> Please, Does anybody know how can I find the good way to compile OCL
>> Expressions?
>>
>> Sorry for the long mail.
>> Thanks for any helps
>>
>> Regards
>> Laurent
|
|
|
Goto Forum:
Current Time: Fri Jul 11 10:16:03 EDT 2025
Powered by FUDForum. Page generated in 0.71667 seconds
|