|
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 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 PT PV R R1 RET RETC RETCN S S1 ST STN XORN |
|
19 #SFC_qualifiers #D #DS #L #N #P #R #S #SD #SL |
|
20 #Task_initialisers #PRIORITY #SINGLE #INTERVAL |
|
21 *) |
|
22 |
|
23 (* NOTE: The identifier as a function test has some special cases. |
|
24 * Namely, when using IL operators as function names. |
|
25 * For example, if a function LD has been previoulsy defined, |
|
26 * The following IL code may be interpreted as either a |
|
27 * function call or an IL operation |
|
28 * LD 10 |
|
29 * Due to undefined situations as the above, our |
|
30 * IEC compiler currently will always interpret IL operator identifiers. |
|
31 * inside IL code as an IL operator. |
|
32 * This means that calling, from IL code, of functions whose names |
|
33 * coincide with an IL operator is not possible. |
|
34 * |
|
35 * The following test code must therefore consider two possibilities: |
|
36 * - if the identifier under test is an IL operator |
|
37 * - if the identifier under test is not an IL operator |
|
38 *) |
|
39 |
|
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 |
|
71 (* Calling of the function from within IL code *) |
|
72 (* NOTE: some legal identifiers, for ex. IL operators, |
|
73 * will not actually be interpreted as a reference to |
|
74 * the function, but rather as an IL operator. |
|
75 * However, no error should occur, as the compiler is written |
|
76 * to give priority to interpreting it as an IL operator. |
|
77 *) |
|
78 |
|
79 (* |
|
80 function bar000 : int |
|
81 var |
|
82 e_1, f_1 : int; |
|
83 end_var |
|
84 XXXX 10 |
|
85 LD 20 |
|
86 XXXX 30 |
|
87 XXXX 10, 20 |
|
88 XXXX ( |
|
89 b_1 := 10, |
|
90 a_1 := 20 |
|
91 ) |
|
92 XXXX( |
|
93 b_1 := 10, |
|
94 a_1 := 20 |
|
95 ) |
|
96 XXXX ( |
|
97 b_1 := 10 |
|
98 ) |
|
99 XXXX( |
|
100 b_1 := 10 |
|
101 ) |
|
102 end_function |
|
103 *) |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 (* Checking whether the use of XXXX will confuse the logic |
|
109 * used to determine if a POU body is in IL or ST language. |
|
110 *) |
|
111 |
|
112 (* |
|
113 function bar001 : int |
|
114 var |
|
115 e_1, f_1 : int; |
|
116 end_var |
|
117 XXXX 10 |
|
118 end_function |
|
119 |
|
120 |
|
121 function bar002 : int |
|
122 var |
|
123 e_1, f_1 : int; |
|
124 end_var |
|
125 XXXX 10, 20 |
|
126 end_function |
|
127 |
|
128 |
|
129 function bar003 : 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 function bar004 : int |
|
141 var |
|
142 e_1, f_1 : int; |
|
143 end_var |
|
144 XXXX ( |
|
145 b_1 := 10, |
|
146 a_1 := 20 |
|
147 ) |
|
148 end_function |
|
149 *) |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 (* Checking whether the use of XXXX will confuse any other |
|
160 * normal and correct IL or ST code. |
|
161 *) |
|
162 {#include "basic_code.test"} |
|
163 |
|
164 |