mario@108: (* Test whether the keyword XXXX may be used as an identifier for: mario@108: * variable name/identifier 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 variable test has some special cases. mario@108: * Namely, when using IL operators as variable names. mario@108: * Even though the syntax of the IL language would not result mario@108: * in ambiguities in the above case, our parser does not currently mario@108: * allow the use of variables (with names identical to IL mario@108: * operators) within IL code. 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: (* A helper FUNCTION BLOCK declaration *) mario@108: function_block foo_fb mario@108: var_input mario@108: a_1, b_1: int; mario@108: end_var mario@108: var_output mario@108: c_1, d_1: int; mario@108: end_var mario@108: c_1 := 10 + b_1; mario@108: end_function_block mario@108: mario@108: mario@108: (* A helper FUNCTION declaration *) mario@108: function foo_f1 : int mario@108: var_input mario@108: a_1, b_1: int; mario@108: end_var mario@108: var_output mario@108: c_1, d_1: int; mario@108: end_var mario@108: c_1 := 10 + b_1; mario@108: end_function mario@108: mario@108: (* Another helper FUNCTION declaration *) mario@108: function foo_f2 : int mario@108: var_input mario@108: a_1, b_1: foo_fb; mario@108: end_var mario@108: var_output mario@108: c_1, d_1: int; mario@108: end_var mario@108: c_1 := 10; mario@108: end_function mario@108: mario@108: (* Another helper FUNCTION declaration *) mario@108: function bar01 : int mario@108: var_input mario@108: XXXX, a_1, b_1: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function mario@108: mario@108: (* Another helper FUNCTION_BLOCK declaration *) mario@108: function_block bar91 mario@108: var mario@108: e_1, f_1 : int; mario@108: XXXX : foo_fb; mario@108: end_var mario@108: e_1 := 0; mario@108: end_function_block mario@108: mario@108: mario@108: mario@108: mario@108: mario@108: mario@108: mario@108: (* Using XXXX as a standard variable name in IL *) mario@108: mario@108: (* NOTE: Currently not supported for identifiers identical to IL operators. mario@108: * We therefore have two versions of this file, one with the following code mario@108: * commented out (used to test the identifiers that clash with IL operators) mario@108: * and a second with the following code included (used to test identifiers mario@108: * that do not clash with IL operators, such as PRIORITY, SINGLE, etc...) mario@108: *) mario@108: mario@108: mario@108: mario@108: function_block bar92 mario@108: var mario@108: e_1, f_1 : int; mario@108: XXXX : bool; mario@108: fb : foo_fb; mario@108: fb2 : bar91; mario@108: end_var mario@108: (* IL operators that - acording to the standard - are not keywords *) mario@108: LD XXXX mario@108: LDN XXXX mario@108: ANDN XXXX mario@108: ORN XXXX mario@108: XORN XXXX mario@108: R XXXX mario@108: S XXXX mario@108: ST XXXX mario@108: STN XXXX mario@108: mario@108: (* IL operators that - acording to the standard - are also keywords *) mario@108: AND XXXX mario@108: OR XXXX mario@108: XOR XXXX mario@108: NOT XXXX mario@108: end_function_block mario@108: mario@108: mario@108: function_block bar93 mario@108: var mario@108: e_1, f_1 : int; mario@108: XXXX : int; mario@108: end_var mario@108: mario@108: (* IL operators that - acording to the standard - are also keywords *) mario@108: ADD XXXX mario@108: SUB XXXX mario@108: MUL XXXX mario@108: DIV XXXX mario@108: MOD XXXX mario@108: GE XXXX mario@108: GT XXXX mario@108: LE XXXX mario@108: LT XXXX mario@108: EQ XXXX mario@108: NE XXXX mario@108: mario@108: (* Calling function with input parameter named XXXX *) mario@108: bar01 ( mario@108: XXXX := 10 mario@108: ) mario@108: bar01 ( mario@108: a_1 := XXXX mario@108: ) mario@108: bar01 ( mario@108: XXXX := XXXX mario@108: ) mario@108: end_function_block mario@108: mario@108: mario@108: mario@108: mario@108: (* a helper function block *) mario@108: function_block bar94 mario@108: var_input mario@108: e_1, f_1 : int; mario@108: XXXX : foo_fb; mario@108: end_var mario@108: e_1 := XXXX.c_1; mario@108: end_function_block mario@108: mario@108: mario@108: function_block bar95 mario@108: var mario@108: e_1, f_1 : int; mario@108: XXXX : foo_fb; mario@108: fb_1 : bar93; mario@108: end_var mario@108: CAL XXXX(10) mario@108: CAL XXXX (e_1) mario@108: CAL XXXX (10, e_1, e_1, f_1) mario@108: CAL XXXX ( mario@108: a_1 := 10, mario@108: b_1 := e_1, mario@108: c_1 => e_1, mario@108: d_1 => f_1 mario@108: ) mario@108: CAL XXXX ( mario@108: a_1 := 10, mario@108: c_1 => e_1 mario@108: ) mario@108: mario@108: CALC XXXX(10) mario@108: CALC XXXX (e_1) mario@108: CALC XXXX (10, e_1, e_1, f_1) mario@108: CALC XXXX ( mario@108: a_1 := 10, mario@108: b_1 := e_1, mario@108: c_1 => e_1, mario@108: d_1 => f_1 mario@108: ) mario@108: CALC XXXX ( mario@108: a_1 := 10, mario@108: c_1 => e_1 mario@108: ) mario@108: mario@108: CALCN XXXX(10) mario@108: CALCN XXXX (e_1) mario@108: CALCN XXXX (10, e_1, e_1, f_1) mario@108: CALCN XXXX ( mario@108: a_1 := 10, mario@108: b_1 := e_1, mario@108: c_1 => e_1, mario@108: d_1 => f_1 mario@108: ) mario@108: CALCN XXXX ( mario@108: a_1 := 10, mario@108: c_1 => e_1 mario@108: ) mario@108: mario@108: LD XXXX.a_1 mario@108: ST XXXX.b_1 mario@108: LD fb_1.XXXX mario@108: ST fb_1.XXXX mario@108: LD fb_1.XXXX.a_1 mario@108: ST fb_1.XXXX.a_1 mario@108: mario@108: LD XXXX mario@108: foo_f2 XXXX, e_1, f_1 mario@108: foo_f2 ( mario@108: a_1 := XXXX, mario@108: b_1 := XXXX, mario@108: c_1 => e_1, mario@108: d_1 => f_1 mario@108: ) mario@108: mario@108: (* Calling function with input parameter named XXXX *) mario@108: bar01 ( mario@108: XXXX := 10 mario@108: ) mario@108: bar01 ( mario@108: a_1 := XXXX.a_1 mario@108: ) mario@108: bar01 ( mario@108: XXXX := XXXX.a_1 mario@108: ) mario@108: end_function_block mario@108: mario@108: mario@108: function_block bar96 mario@108: var mario@108: e_1, f_1 : int; mario@108: XXXX : CTUD; mario@108: end_var mario@108: CU XXXX mario@108: CD XXXX mario@108: PV XXXX mario@108: end_function_block mario@108: mario@108: mario@108: function_block bar97 mario@108: var mario@108: e_1, f_1 : int; mario@108: XXXX : R_TRIG; mario@108: end_var mario@108: CLK XXXX mario@108: end_function_block mario@108: mario@108: mario@108: mario@108: function_block bar98 mario@108: var mario@108: e_1, f_1 : int; mario@108: XXXX : TP; mario@108: end_var mario@108: IN XXXX mario@108: PT XXXX mario@108: end_function_block mario@108: mario@108: mario@108: mario@108: function_block bar99 mario@108: var mario@108: e_1, f_1 : int; mario@108: XXXX : SR; mario@108: end_var mario@108: R1 XXXX mario@108: S1 XXXX mario@108: end_function_block 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: