|
1 (* Test whether the keyword XXXX may be used as an identifier for: |
|
2 * FUNCTION declaration |
|
3 * |
|
4 * The XXXX names in the following code are merely a placeholder. |
|
5 * They will be replaced by several identifiers before actual testing |
|
6 * of the compiler. |
|
7 *) |
|
8 |
|
9 (* The identifiers that will replace the XXXX |
|
10 * must be placed on a line starting with # |
|
11 * All identifiers preceded by # are ignored! |
|
12 * The identifier list must be placed inside an IEC 61131-3 comment. |
|
13 *) |
|
14 (* This file is specific for identifiers NOT identical to IL operators. |
|
15 * See the note following the identifier list |
|
16 *) |
|
17 (* |
|
18 #IL_operators #ANDN #CAL #CALC #CALCN #CD #CLK #CU #IN #JMP #JMPC #JMPCN #LD #LDN #ORN |
|
19 #IL_operators #PT #PV #R #R1 #RET #RETC #RETCN #S #S1 #ST #STN #XORN |
|
20 NOTE: R and S are identical to IL operators!! |
|
21 #SFC_qualifiers D DS L N P #R #S SD SL |
|
22 #Task_initialisers PRIORITY SINGLE INTERVAL |
|
23 *) |
|
24 |
|
25 (* NOTE: The identifier as a function test has some special cases. |
|
26 * Namely, when using IL operators as function names. |
|
27 * For example, if a function LD has been previoulsy defined, |
|
28 * The following IL code may be interpreted as either a |
|
29 * function call or an IL operation |
|
30 * LD 10 |
|
31 * Due to undefined situations as the above, our |
|
32 * IEC compiler currently will always interpret IL operator identifiers. |
|
33 * inside IL code as an IL operator. |
|
34 * This means that calling, from IL code, of functions whose names |
|
35 * coincide with an IL operator is not possible. |
|
36 * |
|
37 * The following test code must therefore consider two possibilities: |
|
38 * - if the identifier under test is an IL operator |
|
39 * - if the identifier under test is not an IL operator |
|
40 *) |
|
41 |
|
42 |
|
43 |
|
44 (* The FUNCTION declaration *) |
|
45 |
|
46 function XXXX : int |
|
47 var_input |
|
48 a_1, b_1: int; |
|
49 end_var |
|
50 XXXX := a_1 + b_1; |
|
51 end_function |
|
52 |
|
53 |
|
54 |
|
55 (* Calling of the function from within ST code *) |
|
56 function foo : int |
|
57 var |
|
58 c_1, d_1 : int; |
|
59 e_1, f_1 : int; |
|
60 end_var |
|
61 d_1 := XXXX(c_1, d_1); |
|
62 d_1 := XXXX(10, 20); |
|
63 c_1 := XXXX(20, 22); |
|
64 c_1 := XXXX(b_1 := e_1, a_1 := f_1); |
|
65 c_1 := XXXX (a_1 := e_1, b_1 := f_1); |
|
66 end_function |
|
67 |
|
68 |
|
69 |
|
70 (* Calling of the function from within IL code *) |
|
71 |
|
72 function bar000 : int |
|
73 var |
|
74 e_1, f_1 : int; |
|
75 end_var |
|
76 XXXX 10 |
|
77 LD 20 |
|
78 XXXX 30 |
|
79 XXXX 10, 20 |
|
80 XXXX ( |
|
81 b_1 := 10, |
|
82 a_1 := 20 |
|
83 ) |
|
84 XXXX( |
|
85 b_1 := 10, |
|
86 a_1 := 20 |
|
87 ) |
|
88 XXXX ( |
|
89 b_1 := 10 |
|
90 ) |
|
91 XXXX( |
|
92 b_1 := 10 |
|
93 ) |
|
94 end_function |
|
95 |
|
96 |
|
97 |
|
98 (* Checking whether the use of XXXX will confuse the logic |
|
99 * used to determine if a POU body is in IL or ST language. |
|
100 *) |
|
101 |
|
102 function bar001 : int |
|
103 var |
|
104 e_1, f_1 : int; |
|
105 end_var |
|
106 XXXX 10 |
|
107 end_function |
|
108 |
|
109 |
|
110 function bar002 : int |
|
111 var |
|
112 e_1, f_1 : int; |
|
113 end_var |
|
114 XXXX 10, 20 |
|
115 end_function |
|
116 |
|
117 |
|
118 function bar003 : int |
|
119 var |
|
120 e_1, f_1 : int; |
|
121 end_var |
|
122 XXXX( |
|
123 b_1 := 10, |
|
124 a_1 := 20 |
|
125 ) |
|
126 end_function |
|
127 |
|
128 |
|
129 function bar004 : int |
|
130 var |
|
131 e_1, f_1 : int; |
|
132 end_var |
|
133 XXXX ( |
|
134 b_1 := 10, |
|
135 a_1 := 20 |
|
136 ) |
|
137 end_function |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 (* Checking whether the use of XXXX will confuse any other |
|
145 * normal and correct IL or ST code. |
|
146 *) |
|
147 {#include "basic_code.test" } |
|
148 |
|
149 |