mario@108: (* Test whether the keyword XXXX may be used as an identifier for:
mario@108:  * FUNCTION declaration
mario@108:  *
mario@108:  * The XXXX names in the following code are merely a placeholder.
mario@108:  * They will be replaced by several identifiers before actual testing
mario@108:  * of the compiler.
mario@108:  *)
mario@108: 
mario@108: (* The identifiers that will replace the XXXX
mario@108:  * must be placed on a line starting with #
mario@108:  * All identifiers preceded by # are ignored!
mario@108:  * The identifier list must be placed inside an IEC 61131-3 comment.
mario@108:  *)
mario@108: (* This file is specific for identifiers NOT identical to IL operators.
mario@108:  *  See the note following the identifier list
mario@108:  *)
mario@108: (*
mario@108: #IL_operators #ANDN #CAL #CALC #CALCN #CD #CLK #CU #IN #JMP #JMPC #JMPCN #LD #LDN #ORN 
mario@108: #IL_operators #PT #PV #R #R1 #RET #RETC #RETCN #S #S1 #ST #STN #XORN
mario@108:      NOTE: R and S are identical to IL operators!!
mario@108: #SFC_qualifiers D DS L N P #R #S SD SL   
mario@108: #Task_initialisers PRIORITY SINGLE INTERVAL
mario@108: *)
mario@108: 
mario@108: (* NOTE: The identifier as a function test has some special cases.
mario@108:  *       Namely, when using IL operators as function names.
mario@108:  *       For example, if a function LD has been previoulsy defined,
mario@108:  *       The following IL code may be interpreted as either a 
mario@108:  *       function call or an IL operation
mario@108:  *         LD 10
mario@108:  *       Due to undefined situations as the above, our 
mario@108:  *       IEC compiler currently will always interpret IL operator identifiers.
mario@108:  *       inside IL code as an IL operator.
mario@108:  *       This means that calling, from IL code, of functions whose names
mario@108:  *       coincide with an IL operator is not possible.
mario@108:  *
mario@108:  *       The following test code must therefore consider two possibilities:
mario@108:  *        - if the identifier under test is an IL operator
mario@108:  *        - if the identifier under test is not an IL operator
mario@108:  *)
mario@108: 
mario@108: 
mario@108: 
mario@108: (* The FUNCTION declaration *)
mario@108: 
mario@108: function XXXX : int
mario@108:  var_input
mario@108:   a_1, b_1: int;
mario@108:  end_var
mario@108:   XXXX := a_1 + b_1;
mario@108: end_function
mario@108: 
mario@108: 
mario@108: 
mario@108: (* Calling of the function from within ST code *)
mario@108: function foo : int
mario@108:  var
mario@108:   c_1, d_1 : int;
mario@108:   e_1, f_1 : int;
mario@108:  end_var
mario@108:   d_1 := XXXX(c_1, d_1);
mario@108:   d_1 := XXXX(10, 20);
mario@108:   c_1 := XXXX(20, 22);
mario@108:   c_1 := XXXX(b_1 := e_1, a_1 := f_1);
mario@108:   c_1 := XXXX (a_1 := e_1, b_1 := f_1);
mario@108: end_function
mario@108: 
mario@108: 
mario@108: 
mario@108: (* Calling of the function from within IL code *)
mario@108: 
mario@108: function bar000 : int
mario@108:  var
mario@108:   e_1, f_1 : int;
mario@108:  end_var
mario@108:   XXXX 10
mario@108:   LD 20
mario@108:   XXXX 30
mario@108:   XXXX 10, 20
mario@108:   XXXX (
mario@108:     b_1 := 10,
mario@108:     a_1 := 20
mario@108:    )
mario@108:   XXXX(
mario@108:     b_1 := 10,
mario@108:     a_1 := 20
mario@108:    )
mario@108:   XXXX (
mario@108:     b_1 := 10
mario@108:    )
mario@108:   XXXX(
mario@108:     b_1 := 10
mario@108:    )
mario@108: end_function
mario@108: 
mario@108: 
mario@108: 
mario@108: (* Checking whether the use of XXXX will confuse the logic 
mario@108:  * used to determine if a POU body is in IL or ST language.
mario@108:  *)
mario@108: 
mario@108: function bar001 : int
mario@108:  var
mario@108:   e_1, f_1 : int;
mario@108:  end_var
mario@108:   XXXX 10
mario@108: end_function
mario@108: 
mario@108: 
mario@108: function bar002 : int
mario@108:  var
mario@108:   e_1, f_1 : int;
mario@108:  end_var
mario@108:   XXXX 10, 20
mario@108: end_function
mario@108: 
mario@108: 
mario@108: function bar003 : int
mario@108:  var
mario@108:   e_1, f_1 : int;
mario@108:  end_var
mario@108:   XXXX(
mario@108:     b_1 := 10,
mario@108:     a_1 := 20
mario@108:    )
mario@108: end_function
mario@108: 
mario@108: 
mario@108: function bar004 : int
mario@108:  var
mario@108:   e_1, f_1 : int;
mario@108:  end_var
mario@108:   XXXX (
mario@108:     b_1 := 10,
mario@108:     a_1 := 20
mario@108:    )
mario@108: end_function
mario@108: 
mario@108: 
mario@108: 
mario@108: 
mario@108: 
mario@108: 
mario@108: (* Checking whether the use of XXXX will confuse any other
mario@108:  * normal and correct IL or ST code.
mario@108:  *)
mario@108: {#include "basic_code.test" }
mario@108: 
mario@108: