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: (* mario@108: #IL_operators ANDN CAL CALC CALCN CD CLK CU IN JMP JMPC JMPCN LD LDN ORN PT PV R R1 RET RETC RETCN S S1 ST STN XORN mario@108: #SFC_qualifiers D DS L N P #R #S SD SL mario@108: NOTE: R and S are identical to IL operators!! 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: * The test code in this file should be valid for all identifiers. mario@108: * Test code that is only valid for identifiers not identical to IL operators mario@108: * is placed in another test file (identifier_as_variable2.test). mario@108: *) 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: mario@108: mario@108: (*********************************************************************) mario@108: (* Testing use of XXXX in several locations of variable declarations *) mario@108: (*********************************************************************) mario@108: 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: function_block bar02 mario@108: var_input mario@108: a_1, XXXX, b_1: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: function_block bar03 mario@108: var_input mario@108: a_1, b_1, XXXX: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: mario@108: function_block bar04 mario@108: var_output mario@108: XXXX, a_1, b_1: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: function_block bar05 mario@108: var_output mario@108: a_1, XXXX, b_1: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: function_block bar06 mario@108: var_output mario@108: a_1, b_1, XXXX: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: mario@108: function_block bar07 mario@108: var_in_out mario@108: XXXX, a_1, b_1: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: function_block bar08 mario@108: var_in_out mario@108: a_1, XXXX, b_1: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: function_block bar09 mario@108: var_in_out mario@108: a_1, b_1, XXXX: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: function_block bar10 mario@108: var_external mario@108: XXXX: int; mario@108: a_1 : int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: function_block bar11 mario@108: var_external mario@108: a_1 : int; mario@108: XXXX : int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: function_block bar12 mario@108: var mario@108: XXXX, a_1, b_1: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: function_block bar13 mario@108: var mario@108: a_1, XXXX, b_1: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: function_block bar14 mario@108: var mario@108: a_1, b_1, XXXX: int; mario@108: end_var mario@108: a_1 := 1; mario@108: end_function_block mario@108: mario@108: mario@108: mario@108: (************************************************) mario@108: (* Using XXXX as a standard variable name in ST *) mario@108: (************************************************) mario@108: mario@108: function_block bar90 mario@108: var mario@108: e_1, f_1 : int; mario@108: XXXX : int; mario@108: fb : foo_fb; mario@108: end_var mario@108: e_1 := bar01 (XXXX := 10); mario@108: e_1 := bar01 (a_1 := XXXX); mario@108: e_1 := bar01 (XXXX := XXXX); mario@108: fb(XXXX, 20); mario@108: fb (10, XXXX, e_1, f_1); mario@108: fb (a_1 := XXXX, b_1:=XXXX, c_1=>XXXX, d_1=>f_1); mario@108: fb(a_1 := 10, b_1:=20, c_1=>e_1, d_1=>XXXX); mario@108: fb (c_1=>XXXX, a_1:=20, d_1=>f_1); mario@108: XXXX := fb.c_1; mario@108: fb.a_1 := XXXX + XXXX * 2 * (XXXX) / foo_f1(XXXX, 10, XXXX, e_1) MOD XXXX MOD XXXX ** XXXX; mario@108: IF (XXXX >= 10) THEN XXXX := 10; END_IF; mario@108: CASE (XXXX + 10) OF mario@108: 10: XXXX := 10; mario@108: 10..20:XXXX := 20; mario@108: ELSE XXXX := 20; mario@108: END_CASE; mario@108: FOR XXXX := 10 TO 20 BY 2 DO mario@108: XXXX := XXXX + 1; mario@108: END_FOR; mario@108: FOR e_1 := XXXX TO 20 DO mario@108: XXXX := XXXX + 1; mario@108: END_FOR; mario@108: FOR e_1 := 10 TO XXXX BY 2 DO mario@108: XXXX := XXXX + 1; mario@108: END_FOR; mario@108: FOR e_1 := 10 TO XXXX DO mario@108: XXXX := XXXX + 1; mario@108: END_FOR; mario@108: FOR e_1 := 10 TO 20 BY XXXX DO mario@108: XXXX := XXXX + 1; mario@108: END_FOR; mario@108: WHILE (XXXX >= 10) DO mario@108: XXXX := 10; mario@108: END_WHILE; mario@108: REPEAT XXXX := 10; UNTIL (XXXX >= 10) END_REPEAT; mario@108: end_function_block mario@108: mario@108: mario@108: mario@108: (* Using XXXX as a function block instance/variable name in ST *) mario@108: 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: XXXX(e_1, 20); mario@108: XXXX (10, e_1, e_1, f_1); mario@108: XXXX (a_1 := e_1, b_1:=e_1 , c_1=>e_1, d_1=>f_1); mario@108: XXXX(a_1 := 10, b_1:=20, c_1=>e_1, d_1=>e_1); mario@108: XXXX (c_1=>e_1, a_1:=20, d_1=>f_1); mario@108: e_1 := XXXX.c_1; mario@108: XXXX.a_1 := e_1; mario@108: e_1 := foo_f2(XXXX, XXXX, e_1, f_1); mario@108: e_1 := foo_f2 (XXXX, XXXX); mario@108: e_1 := foo_f2 (c_1 => e_1, b_1 := XXXX, d_1 := 10, a_1 := XXXX); mario@108: e_1 := foo_f2 (b_1 := XXXX); mario@108: end_function_block 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: 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 bar93 mario@108: var mario@108: e_1, f_1 : int; mario@108: end_var mario@108: mario@108: (* Calling function with input parameter named XXXX ** mario@108: bar01 ( mario@108: XXXX := 10 mario@108: ) mario@108: end_function_block mario@108: *) mario@108: mario@108: mario@108: (* mario@108: function_block bar99 mario@108: (...) mario@108: end_function_block mario@108: *) mario@108: mario@108: mario@108: mario@108: mario@108: mario@108: mario@108: (*************************************************************************************) mario@108: (* Using XXXX as a function block instance/variable/program name in a configuration. *) mario@108: (*************************************************************************************) mario@108: mario@108: (* a helper program *) mario@108: PROGRAM bar000 mario@108: VAR_INPUT mario@108: a_1, XXXX : BOOL; mario@108: END_VAR mario@108: VAR_OUTPUT mario@108: b_1 : BOOL; mario@108: END_VAR mario@108: a_1 := TRUE; mario@108: END_PROGRAM mario@108: mario@108: mario@108: (* using in program parameter *) mario@108: CONFIGURATION config01 mario@108: TASK fast(PRIORITY := 4); mario@108: PROGRAM foo WITH fast: mario@108: bar000(a_1 := TRUE, XXXX := FALSE); mario@108: END_CONFIGURATION mario@108: mario@108: mario@108: (* using as a program name *) mario@108: CONFIGURATION config02 mario@108: TASK fast(PRIORITY := 4); mario@108: PROGRAM XXXX WITH fast: mario@108: bar000(a_1 := TRUE, XXXX := FALSE); mario@108: END_CONFIGURATION mario@108: mario@108: mario@108: (* using as a resource name *) mario@108: CONFIGURATION config03 mario@108: RESOURCE XXXX on processor_type_1 mario@108: TASK fast(PRIORITY := 4); mario@108: PROGRAM foo WITH fast: mario@108: bar000(a_1 := TRUE, XXXX := FALSE); mario@108: END_RESOURCE mario@108: END_CONFIGURATION mario@108: mario@108: mario@108: (* using as a task name *) mario@108: CONFIGURATION config11 mario@108: TASK XXXX(PRIORITY := 4); mario@108: PROGRAM foo WITH XXXX: mario@108: bar000(a_1 := TRUE, XXXX := FALSE); mario@108: END_CONFIGURATION mario@108: mario@108: mario@108: CONFIGURATION config12 mario@108: TASK XXXX(SINGLE := 3, PRIORITY := 4); mario@108: PROGRAM P1 WITH XXXX: mario@108: bar000(a_1 := TRUE, XXXX := FALSE); mario@108: END_CONFIGURATION mario@108: mario@108: mario@108: CONFIGURATION config13 mario@108: TASK XXXX(INTERVAL := T#1s, PRIORITY := 4); mario@108: PROGRAM P1 WITH XXXX: mario@108: bar000(a_1 := TRUE, XXXX := FALSE); mario@108: END_CONFIGURATION mario@108: mario@108: mario@108: CONFIGURATION config14 mario@108: TASK XXXX(SINGLE := 3, INTERVAL := T#1s, PRIORITY := 4); mario@108: PROGRAM P1 WITH XXXX: mario@108: bar000(a_1 := TRUE, XXXX := FALSE); mario@108: END_CONFIGURATION mario@108: mario@108: mario@108: (* using as a variable name *) mario@108: CONFIGURATION config21 mario@108: VAR_GLOBAL mario@108: XXXX : bool; mario@108: END_VAR mario@108: TASK fast(PRIORITY := 4); mario@108: PROGRAM foo WITH fast: mario@108: bar000(a_1 := XXXX, b_1 => XXXX, XXXX := XXXX); mario@108: END_CONFIGURATION mario@108: mario@108: mario@108: mario@108: mario@108: mario@108: 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: