Skip to content

Commit

Permalink
minor bug fix OCL, documentation updated
Browse files Browse the repository at this point in the history
  • Loading branch information
FitashUlHaq committed May 23, 2024
1 parent 59e6479 commit b5ca9ce
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 37 deletions.
31 changes: 0 additions & 31 deletions besser/BUML/notations/ocl/OCLWrapper.py

This file was deleted.

11 changes: 7 additions & 4 deletions besser/BUML/notations/ocl/RootHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self,ocl=None,dm=None,om=None):
self.pre = False
self.post = False
self.if_else_roots = []
self.context_name=""

def get_root(self):
return self.root
Expand Down Expand Up @@ -202,12 +203,14 @@ def verify(self,item):
if 'or' in item[0:2]:
item = item[2:]
referredOP = 'OR'
prop = self.factory.create_property_Call_Expression(item, 'NI')
if 'allInstances' in item[0:12]:
return
if referredOP is None:
prop = self.factory.create_property_Call_Expression(item, 'NI')
# prop= self.factory.create_property_Call_Expression(item,'NI')
self.add_to_root(prop)
else:
opCallExp = self.factory.create_operation_call_expression(name="and")
opCallExp = self.factory.create_operation_call_expression(name=referredOP)
opCallExp.referredOperation = self.factory.create_infix_operator(referredOP)
self.add_to_root(opCallExp)
pass
Expand Down Expand Up @@ -253,7 +256,7 @@ def handle_binary_expression(self, expression, operator,inbetween= None,beforeSi
elif "real" in leftside:
leftPart = self.factory.create_real_literal_expression("NP", float(expressionParts[0]))
elif "bool" in leftside:
leftPart = self.factory.create_boolean_literal_expression("NP", bool(expressionParts[0]))
leftPart = self.factory.create_boolean_literal_expression("NP", (expressionParts[0]))
elif "str" in leftside:
leftPart = self.factory.create_string_literal_expression("str", expressionParts[0].replace("'",""))

Expand All @@ -264,7 +267,7 @@ def handle_binary_expression(self, expression, operator,inbetween= None,beforeSi
elif "real" in rightside:
rightPart = self.factory.create_real_literal_expression("NP", float(expressionParts[1]))
elif "bool" in rightside:
rightPart = self.factory.create_boolean_literal_expression("NP", bool(expressionParts[1]))
rightPart = self.factory.create_boolean_literal_expression("NP", (expressionParts[1]))
elif "str" in rightside:
rightPart = self.factory.create_string_literal_expression("str", expressionParts[1].replace("'",""))

Expand Down
6 changes: 6 additions & 0 deletions docs/source/buml_language/model_types/ocl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ We are able to parse all the queries from the metamodel. The work on OCL interpr
context library inv inv1: self.books>0
.. note::

BOCL Interpreter is available at https://github.com/BESSER-PEARL/BOCL-Interpreter. With this interpreter you can validate your OCL constraints defined on BUML models.



Supported notations
-------------------

Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/ocl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ We can set a rule that says *every book must have more than zero pages*. To do t
context Book: self.pages > 0
.. note::
Please note that the work on the OCL interpreter is ongoing, and it will be added in the near future.

BOCL Interpreter is available at https://github.com/BESSER-PEARL/BOCL-Interpreter. With this interpreter you can validate your OCL constraints defined on BUML models.

0 comments on commit b5ca9ce

Please sign in to comment.