Skip to content

Commit 88cfd6c

Browse files
committed
Included conversion and code generation for relation operators
1 parent e612e64 commit 88cfd6c

4 files changed

Lines changed: 35 additions & 32 deletions

File tree

MCG/MCG_CC/mcg_cc_file_checker.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# responsible for checking of model module content from .exml file.
66
#
77
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8-
# DATE: 13 JUN 2023
8+
# DATE: 23 JUN 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -40,8 +40,7 @@ class FileChecker(object):
4040

4141
# list of actions types
4242
action_3letter_type_list = ["ADD", "SUB", "MUL", "DIV", "AND", "NOT"]
43-
44-
action_2letter_type_list = ["OR"]
43+
action_2letter_type_list = ["OR", "EQ", "NE", "GT", "LT", "GE", "LE"]
4544

4645
# list of interface element types
4746
interface_element_type_list = ["INT8", "INT16", "INT32", "INT64",
@@ -96,10 +95,9 @@ def check_action_type(action_type_ref):
9695
# result flag
9796
action_type_valid = False
9897

99-
# check 3-letter action types
100-
if len(action_type_ref) > 2:
101-
102-
# for all possible action types
98+
# is valid type is not found
99+
if not action_type_valid:
100+
# check all possible 3-letter action types
103101
for action_type in FileChecker.action_3letter_type_list:
104102
# if action type is the same as in reference
105103
if action_type == action_type_ref[0:3]:
@@ -108,10 +106,9 @@ def check_action_type(action_type_ref):
108106
# exit loop
109107
break
110108

111-
# check 2-letter action types
112-
elif len(action_type_ref) < 3:
113-
114-
# for all possible action types
109+
# is valid types is not found
110+
if not action_type_valid:
111+
# check 2-letter action types
115112
for action_type in FileChecker.action_2letter_type_list:
116113
# if action type is the same as in reference
117114
if action_type == action_type_ref[0:2]:

MCG/MCG_CC/mcg_cc_module_converter.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# for conversion of module content into configuration file format.
66
#
77
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8-
# DATE: 13 JUN 2023
8+
# DATE: 23 JUN 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -287,40 +287,45 @@ def convert_specific_action_node_arity_1(self, sorted_node, operator):
287287
# This method converts module action node into configuration file.
288288
def convert_action_node(self, sorted_node):
289289

290-
# if sorted node contains ADD action
290+
# depending on the type of action, covert module node into configuration file.
291291
if sorted_node.name[0:3] == "ADD":
292-
# convert ADD action
293292
self.convert_specific_action_node_arity_n(sorted_node, "+")
294293

295-
# if sorted node contains SUB action
296294
elif sorted_node.name[0:3] == "SUB":
297-
# convert SUB action
298295
self.convert_specific_action_node_arity_n(sorted_node, "-")
299296

300-
# if sorted node contains MUL action
301297
elif sorted_node.name[0:3] == "MUL":
302-
# convert MUL action
303298
self.convert_specific_action_node_arity_n(sorted_node, "*")
304299

305-
# if sorted node contains DIV action
306300
elif sorted_node.name[0:3] == "DIV":
307-
# convert DIV action
308301
self.convert_specific_action_node_arity_n(sorted_node, "/")
309302

310-
# if sorted node contains AND action
311303
elif sorted_node.name[0:3] == "AND":
312-
# convert DIV action
313304
self.convert_specific_action_node_arity_n(sorted_node, "&&")
314305

315-
# if sorted node contains OR action
306+
elif sorted_node.name[0:3] == "NOT":
307+
self.convert_specific_action_node_arity_1(sorted_node, "!")
308+
316309
elif sorted_node.name[0:2] == "OR":
317-
# convert DIV action
318310
self.convert_specific_action_node_arity_n(sorted_node, "||")
319311

320-
# if sorted node contains NOT action
321-
elif sorted_node.name[0:3] == "NOT":
322-
# convert DIV action
323-
self.convert_specific_action_node_arity_1(sorted_node, "!")
312+
elif sorted_node.name[0:2] == "EQ":
313+
self.convert_specific_action_node_arity_n(sorted_node, "==")
314+
315+
elif sorted_node.name[0:2] == "NE":
316+
self.convert_specific_action_node_arity_n(sorted_node, "!=")
317+
318+
elif sorted_node.name[0:2] == "GT":
319+
self.convert_specific_action_node_arity_n(sorted_node, ">")
320+
321+
elif sorted_node.name[0:2] == "LT":
322+
self.convert_specific_action_node_arity_n(sorted_node, "LT")
323+
324+
elif sorted_node.name[0:2] == "GE":
325+
self.convert_specific_action_node_arity_n(sorted_node, ">=")
326+
327+
elif sorted_node.name[0:2] == "LE":
328+
self.convert_specific_action_node_arity_n(sorted_node, "<=")
324329

325330
# Description:
326331
# This method converts module data node into configuration file.

MCG/MCG_CC/mcg_cc_module_sorter.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# for finding and sorting of module nodes.
66
#
77
# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8-
# DATE: 25 MAR 2023
8+
# DATE: 23 JUN 2023
99
#
1010
# LICENSE:
1111
# This file is part of Mod Code Generator (MCG).
@@ -42,7 +42,7 @@ class ModuleSorter(object):
4242
SORTED_NODE_LIST_INDEX = 0
4343

4444
# list of action interaction that require to distinguish main data input
45-
input_sensitivity_action_list = ["SUB", "DIV"]
45+
input_sensitive_action_list = ["SUB", "DIV", "GT", "LT", "GE", "LE"]
4646

4747
# Description:
4848
# This is class constructor.
@@ -311,8 +311,9 @@ def sort_input_data_list(self):
311311
if sorted_node.type == Node.ACTION:
312312

313313
# and if action is input sensitive, i.e. requires to distinguish main input data
314-
for input_sensitivity_action in ModuleSorter.input_sensitivity_action_list:
315-
if sorted_node.name[0:3] == input_sensitivity_action:
314+
for input_sensitive_action in ModuleSorter.input_sensitive_action_list:
315+
if (sorted_node.name[0:3] == input_sensitive_action) or \
316+
(sorted_node.name[0:2] == input_sensitive_action):
316317

317318
# get marker position
318319
marker_position = sorted_node.name.find("+")

Mod Code Generator Manual.pdf

342 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)