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: 13 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,73 @@ 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
272290 # if sorted node contains ADD action
273291 if sorted_node .name [0 :3 ] == "ADD" :
274292 # convert ADD action
275- self .convert_specific_action_node (sorted_node , "+" )
293+ self .convert_specific_action_node_arity_n (sorted_node , "+" )
276294
277295 # if sorted node contains SUB action
278296 elif sorted_node .name [0 :3 ] == "SUB" :
279297 # convert SUB action
280- self .convert_specific_action_node (sorted_node , "-" )
298+ self .convert_specific_action_node_arity_n (sorted_node , "-" )
281299
282300 # if sorted node contains MUL action
283301 elif sorted_node .name [0 :3 ] == "MUL" :
284302 # convert MUL action
285- self .convert_specific_action_node (sorted_node , "*" )
303+ self .convert_specific_action_node_arity_n (sorted_node , "*" )
286304
287305 # if sorted node contains DIV action
288306 elif sorted_node .name [0 :3 ] == "DIV" :
289307 # convert DIV action
290- self .convert_specific_action_node (sorted_node , "/" )
308+ self .convert_specific_action_node_arity_n (sorted_node , "/" )
309+
310+ # if sorted node contains AND action
311+ elif sorted_node .name [0 :3 ] == "AND" :
312+ # convert DIV action
313+ self .convert_specific_action_node_arity_n (sorted_node , "&&" )
314+
315+ # if sorted node contains OR action
316+ elif sorted_node .name [0 :2 ] == "OR" :
317+ # convert DIV action
318+ self .convert_specific_action_node_arity_n (sorted_node , "||" )
319+
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 , "!" )
291324
292325 # Description:
293326 # This method converts module data node into configuration file.
0 commit comments