55# for conversion of module content into configuration file format.
66#
77# COPYRIGHT: Copyright (C) 2021-2023 Kamil Deć github.com/deckamil
8- # DATE: 28 MAY 2023
8+ # DATE: 23 JUN 2023
99#
1010# LICENSE:
1111# This file is part of Mod Code Generator (MCG).
@@ -240,8 +240,8 @@ def convert_operation_node(self, sorted_node):
240240 Logger .save_in_log_file ("ModuleConverter" , "Have converted to " + str (conversion_line ) + " line" , False )
241241
242242 # Description:
243- # This method converts module specific action node into configuration file.
244- def convert_specific_action_node (self , sorted_node , math_symbol ):
243+ # This method converts module specific action node with n-argument operator into configuration file.
244+ def convert_specific_action_node_arity_n (self , sorted_node , operator ):
245245
246246 # get output link
247247 output_link = sorted_node .output_data_list [0 ]
@@ -254,40 +254,78 @@ def convert_specific_action_node(self, sorted_node, math_symbol):
254254 input_data_name = input_link [Node .DATA_NAME_INDEX ]
255255 # append input data element to conversion line
256256 conversion_line = conversion_line + str (input_data_name )
257- # append math symbol to conversion line
258- conversion_line = conversion_line + str (" " ) + str (math_symbol ) + str (" " )
257+ # append operator to conversion line
258+ conversion_line = conversion_line + str (" " ) + str (operator ) + str (" " )
259259
260- # remove spare math symbol and whitespace
260+ # remove spare operator and whitespace
261261 conversion_line = conversion_line [0 :len (conversion_line ) - 3 ]
262262 # append conversion line to configuration file
263263 self .configuration_file .append (conversion_line )
264264
265265 # record info
266266 Logger .save_in_log_file ("ModuleConverter" , "Have converted to " + str (conversion_line ) + " line" , False )
267267
268+ # Description:
269+ # This method converts module specific action node with 1-argument operator into configuration file.
270+ def convert_specific_action_node_arity_1 (self , sorted_node , operator ):
271+
272+ # get input link
273+ input_link = sorted_node .input_data_list [0 ]
274+ # get output link
275+ output_link = sorted_node .output_data_list [0 ]
276+ # set beginning of action interaction to conversion line
277+ conversion_line = str ("$INS " ) + str (output_link [Node .DATA_NAME_INDEX ]) + str (" = " ) + \
278+ str (operator ) + str (input_link [Node .DATA_NAME_INDEX ])
279+
280+ # append conversion line to configuration file
281+ self .configuration_file .append (conversion_line )
282+
283+ # record info
284+ Logger .save_in_log_file ("ModuleConverter" , "Have converted to " + str (conversion_line ) + " line" , False )
285+
268286 # Description:
269287 # This method converts module action node into configuration file.
270288 def convert_action_node (self , sorted_node ):
271289
272- # if sorted node contains ADD action
290+ # depending on the type of action, covert module node into configuration file.
273291 if sorted_node .name [0 :3 ] == "ADD" :
274- # convert ADD action
275- self .convert_specific_action_node (sorted_node , "+" )
292+ self .convert_specific_action_node_arity_n (sorted_node , "+" )
276293
277- # if sorted node contains SUB action
278294 elif sorted_node .name [0 :3 ] == "SUB" :
279- # convert SUB action
280- self .convert_specific_action_node (sorted_node , "-" )
295+ self .convert_specific_action_node_arity_n (sorted_node , "-" )
281296
282- # if sorted node contains MUL action
283297 elif sorted_node .name [0 :3 ] == "MUL" :
284- # convert MUL action
285- self .convert_specific_action_node (sorted_node , "*" )
298+ self .convert_specific_action_node_arity_n (sorted_node , "*" )
286299
287- # if sorted node contains DIV action
288300 elif sorted_node .name [0 :3 ] == "DIV" :
289- # convert DIV action
290- self .convert_specific_action_node (sorted_node , "/" )
301+ self .convert_specific_action_node_arity_n (sorted_node , "/" )
302+
303+ elif sorted_node .name [0 :3 ] == "AND" :
304+ self .convert_specific_action_node_arity_n (sorted_node , "&&" )
305+
306+ elif sorted_node .name [0 :3 ] == "NOT" :
307+ self .convert_specific_action_node_arity_1 (sorted_node , "!" )
308+
309+ elif sorted_node .name [0 :2 ] == "OR" :
310+ self .convert_specific_action_node_arity_n (sorted_node , "||" )
311+
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 , "<=" )
291329
292330 # Description:
293331 # This method converts module data node into configuration file.
0 commit comments