|
1 (* Test whether the keyword XXXX may be used as an identifier for: |
|
2 * variable name/identifier |
|
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 variable test has some special cases. |
|
26 * Namely, when using IL operators as variable names. |
|
27 * Even though the syntax of the IL language would not result |
|
28 * in ambiguities in the above case, our parser does not currently |
|
29 * allow the use of variables (with names identical to IL |
|
30 * operators) within IL code. |
|
31 * |
|
32 * The following test code must therefore consider two possibilities: |
|
33 * - if the identifier under test is an IL operator |
|
34 * - if the identifier under test is not an IL operator |
|
35 *) |
|
36 |
|
37 |
|
38 |
|
39 (* A helper FUNCTION BLOCK declaration *) |
|
40 function_block foo_fb |
|
41 var_input |
|
42 a_1, b_1: int; |
|
43 end_var |
|
44 var_output |
|
45 c_1, d_1: int; |
|
46 end_var |
|
47 c_1 := 10 + b_1; |
|
48 end_function_block |
|
49 |
|
50 |
|
51 (* A helper FUNCTION declaration *) |
|
52 function foo_f1 : int |
|
53 var_input |
|
54 a_1, b_1: int; |
|
55 end_var |
|
56 var_output |
|
57 c_1, d_1: int; |
|
58 end_var |
|
59 c_1 := 10 + b_1; |
|
60 end_function |
|
61 |
|
62 (* Another helper FUNCTION declaration *) |
|
63 function foo_f2 : int |
|
64 var_input |
|
65 a_1, b_1: foo_fb; |
|
66 end_var |
|
67 var_output |
|
68 c_1, d_1: int; |
|
69 end_var |
|
70 c_1 := 10; |
|
71 end_function |
|
72 |
|
73 (* Another helper FUNCTION declaration *) |
|
74 function bar01 : int |
|
75 var_input |
|
76 XXXX, a_1, b_1: int; |
|
77 end_var |
|
78 a_1 := 1; |
|
79 end_function |
|
80 |
|
81 (* Another helper FUNCTION_BLOCK declaration *) |
|
82 function_block bar91 |
|
83 var |
|
84 e_1, f_1 : int; |
|
85 XXXX : foo_fb; |
|
86 end_var |
|
87 e_1 := 0; |
|
88 end_function_block |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 (* Using XXXX as a standard variable name in IL *) |
|
97 |
|
98 (* NOTE: Currently not supported for identifiers identical to IL operators. |
|
99 * We therefore have two versions of this file, one with the following code |
|
100 * commented out (used to test the identifiers that clash with IL operators) |
|
101 * and a second with the following code included (used to test identifiers |
|
102 * that do not clash with IL operators, such as PRIORITY, SINGLE, etc...) |
|
103 *) |
|
104 |
|
105 |
|
106 |
|
107 function_block bar92 |
|
108 var |
|
109 e_1, f_1 : int; |
|
110 XXXX : bool; |
|
111 fb : foo_fb; |
|
112 fb2 : bar91; |
|
113 end_var |
|
114 (* IL operators that - acording to the standard - are not keywords *) |
|
115 LD XXXX |
|
116 LDN XXXX |
|
117 ANDN XXXX |
|
118 ORN XXXX |
|
119 XORN XXXX |
|
120 R XXXX |
|
121 S XXXX |
|
122 ST XXXX |
|
123 STN XXXX |
|
124 |
|
125 (* IL operators that - acording to the standard - are also keywords *) |
|
126 AND XXXX |
|
127 OR XXXX |
|
128 XOR XXXX |
|
129 NOT XXXX |
|
130 end_function_block |
|
131 |
|
132 |
|
133 function_block bar93 |
|
134 var |
|
135 e_1, f_1 : int; |
|
136 XXXX : int; |
|
137 end_var |
|
138 |
|
139 (* IL operators that - acording to the standard - are also keywords *) |
|
140 ADD XXXX |
|
141 SUB XXXX |
|
142 MUL XXXX |
|
143 DIV XXXX |
|
144 MOD XXXX |
|
145 GE XXXX |
|
146 GT XXXX |
|
147 LE XXXX |
|
148 LT XXXX |
|
149 EQ XXXX |
|
150 NE XXXX |
|
151 |
|
152 (* Calling function with input parameter named XXXX *) |
|
153 bar01 ( |
|
154 XXXX := 10 |
|
155 ) |
|
156 bar01 ( |
|
157 a_1 := XXXX |
|
158 ) |
|
159 bar01 ( |
|
160 XXXX := XXXX |
|
161 ) |
|
162 end_function_block |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 (* a helper function block *) |
|
168 function_block bar94 |
|
169 var_input |
|
170 e_1, f_1 : int; |
|
171 XXXX : foo_fb; |
|
172 end_var |
|
173 e_1 := XXXX.c_1; |
|
174 end_function_block |
|
175 |
|
176 |
|
177 function_block bar95 |
|
178 var |
|
179 e_1, f_1 : int; |
|
180 XXXX : foo_fb; |
|
181 fb_1 : bar93; |
|
182 end_var |
|
183 CAL XXXX(10) |
|
184 CAL XXXX (e_1) |
|
185 CAL XXXX (10, e_1, e_1, f_1) |
|
186 CAL XXXX ( |
|
187 a_1 := 10, |
|
188 b_1 := e_1, |
|
189 c_1 => e_1, |
|
190 d_1 => f_1 |
|
191 ) |
|
192 CAL XXXX ( |
|
193 a_1 := 10, |
|
194 c_1 => e_1 |
|
195 ) |
|
196 |
|
197 CALC XXXX(10) |
|
198 CALC XXXX (e_1) |
|
199 CALC XXXX (10, e_1, e_1, f_1) |
|
200 CALC XXXX ( |
|
201 a_1 := 10, |
|
202 b_1 := e_1, |
|
203 c_1 => e_1, |
|
204 d_1 => f_1 |
|
205 ) |
|
206 CALC XXXX ( |
|
207 a_1 := 10, |
|
208 c_1 => e_1 |
|
209 ) |
|
210 |
|
211 CALCN XXXX(10) |
|
212 CALCN XXXX (e_1) |
|
213 CALCN XXXX (10, e_1, e_1, f_1) |
|
214 CALCN XXXX ( |
|
215 a_1 := 10, |
|
216 b_1 := e_1, |
|
217 c_1 => e_1, |
|
218 d_1 => f_1 |
|
219 ) |
|
220 CALCN XXXX ( |
|
221 a_1 := 10, |
|
222 c_1 => e_1 |
|
223 ) |
|
224 |
|
225 LD XXXX.a_1 |
|
226 ST XXXX.b_1 |
|
227 LD fb_1.XXXX |
|
228 ST fb_1.XXXX |
|
229 LD fb_1.XXXX.a_1 |
|
230 ST fb_1.XXXX.a_1 |
|
231 |
|
232 LD XXXX |
|
233 foo_f2 XXXX, e_1, f_1 |
|
234 foo_f2 ( |
|
235 a_1 := XXXX, |
|
236 b_1 := XXXX, |
|
237 c_1 => e_1, |
|
238 d_1 => f_1 |
|
239 ) |
|
240 |
|
241 (* Calling function with input parameter named XXXX *) |
|
242 bar01 ( |
|
243 XXXX := 10 |
|
244 ) |
|
245 bar01 ( |
|
246 a_1 := XXXX.a_1 |
|
247 ) |
|
248 bar01 ( |
|
249 XXXX := XXXX.a_1 |
|
250 ) |
|
251 end_function_block |
|
252 |
|
253 |
|
254 function_block bar96 |
|
255 var |
|
256 e_1, f_1 : int; |
|
257 XXXX : CTUD; |
|
258 end_var |
|
259 CU XXXX |
|
260 CD XXXX |
|
261 PV XXXX |
|
262 end_function_block |
|
263 |
|
264 |
|
265 function_block bar97 |
|
266 var |
|
267 e_1, f_1 : int; |
|
268 XXXX : R_TRIG; |
|
269 end_var |
|
270 CLK XXXX |
|
271 end_function_block |
|
272 |
|
273 |
|
274 |
|
275 function_block bar98 |
|
276 var |
|
277 e_1, f_1 : int; |
|
278 XXXX : TP; |
|
279 end_var |
|
280 IN XXXX |
|
281 PT XXXX |
|
282 end_function_block |
|
283 |
|
284 |
|
285 |
|
286 function_block bar99 |
|
287 var |
|
288 e_1, f_1 : int; |
|
289 XXXX : SR; |
|
290 end_var |
|
291 R1 XXXX |
|
292 S1 XXXX |
|
293 end_function_block |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 (* Checking whether the use of XXXX will confuse any other |
|
300 * normal and correct IL or ST code. |
|
301 *) |
|
302 {#include "basic_code.test" } |
|
303 |