44 /*****************************************************************/ |
44 /*****************************************************************/ |
45 /*****************************************************************/ |
45 /*****************************************************************/ |
46 /*****************************************************************/ |
46 /*****************************************************************/ |
47 /*****************************************************************/ |
47 /*****************************************************************/ |
48 /* */ |
48 /* */ |
49 /* Symbols defined in: */ |
49 /* safe<xxxxxx> Symbols are defined in: */ |
50 /* PLCopen - Technical Committee 5 */ |
50 /* PLCopen - Technical Committee 5 */ |
51 /* Safety Software Technical Specification, */ |
51 /* Safety Software Technical Specification, */ |
52 /* Part 1: Concepts and Function Blocks, */ |
52 /* Part 1: Concepts and Function Blocks, */ |
53 /* Version 1.0 – Official Release - 2006-01-31 */ |
53 /* Version 1.0 – Official Release - 2006-01-31 */ |
54 /* */ |
54 /* */ |
55 /*****************************************************************/ |
55 /*****************************************************************/ |
56 /*****************************************************************/ |
56 /*****************************************************************/ |
57 /*****************************************************************/ |
57 /*****************************************************************/ |
58 /*****************************************************************/ |
58 /*****************************************************************/ |
59 |
59 |
60 |
|
61 |
|
62 |
|
63 SYM_REF0(safebool_type_name_c) |
|
64 |
60 |
65 |
61 |
66 |
62 |
67 |
63 |
68 |
64 |
127 SYM_TOKEN(hex_integer_c) |
123 SYM_TOKEN(hex_integer_c) |
128 |
124 |
129 /* Note: |
125 /* Note: |
130 * We do not have signed_integer_c and signed_real_c classes. |
126 * We do not have signed_integer_c and signed_real_c classes. |
131 * These are stored in the parse tree as a integer_c or real_c |
127 * These are stored in the parse tree as a integer_c or real_c |
132 * preceded by a unary minus operator. |
128 * preceded by a unary minus operator if they are inside an expression, |
|
129 * or a neg_integer_c and neg_real_c when used outside an ST expression. |
133 */ |
130 */ |
134 /* Not required: |
131 /* Not required: |
135 SYM_TOKEN(signed_integer_c) |
132 SYM_TOKEN(signed_integer_c) |
136 SYM_TOKEN(signed_real_c) |
133 SYM_TOKEN(signed_real_c) |
137 */ |
134 */ |
138 |
135 |
139 SYM_REF1(neg_literal_c, exp) |
136 /* NOTE: literal __values__ are stored directly in classes such as: |
|
137 * - real_c |
|
138 * - integer_c |
|
139 * - binary_integer_c |
|
140 * - etc... |
|
141 * |
|
142 * However, for both the real_c and the integer_c, if they are preceded |
|
143 * by a '-' negation sign, they are further encapsulated inside |
|
144 * a neg_literal_c (i.e. the neg_literal_c will point to the |
|
145 * real_c or integer_c with the value being negated. |
|
146 * neg_literal_c -> integer_literal_c |
|
147 * OR |
|
148 * neg_literal_c -> real_literal_c |
|
149 * |
|
150 * In the semantic verification and code generation stages of the compiler, |
|
151 * the integer_c is treated as a basic (undefined) data type, since an integer |
|
152 * constant may be used as a BYTE, BOOLEAN, REAL, etc..., depending on the |
|
153 * context in which it is used. |
|
154 * However, an integer_c that is preceded by a '-' may not be used |
|
155 * as an ANY_BIT data type (BYTE, BOOLEAN, WORD, ...). |
|
156 * We must therefore be able to determine, holding a simple pointer |
|
157 * to an integer_c, if that integer_c value is preceded by a '-'. |
|
158 * However, since the neg_literal_c points to the integer_c, and not |
|
159 * vice-versa, we can't determine that. |
|
160 * There are 3 simple ways of working around this: |
|
161 * - change the order of the pointers: |
|
162 * have the integer_c and real_c point to the neg_literal_c |
|
163 * - maintain the order of the pointers, and |
|
164 * add redundant info to the integer_c and real_c |
|
165 * - replace the neg_literal_c with two distinc classes |
|
166 * (neg_integer_c and neg_real_c), one for each |
|
167 * lietral type. This means that we can now treat |
|
168 * each of these classes as an unknown data type |
|
169 * just as we do with the integer_c and real_c. |
|
170 * |
|
171 * The second option is simply ugly. |
|
172 * and the first has a serious drawback: when generating code it is |
|
173 * easier to encapsulate the real or integer values inside prefix |
|
174 * and postfix symbols (e.g. NEG(<value>) - with postfix ')' ) |
|
175 * if we keep the pointer order as is. |
|
176 * |
|
177 * For the above reasoning, we use the third option. |
|
178 */ |
|
179 SYM_REF1(neg_real_c, exp) |
|
180 SYM_REF1(neg_integer_c, exp) |
140 |
181 |
141 /* Not required: |
182 /* Not required: |
142 SYM_REF2(numeric_literal_c, type, value) |
183 SYM_REF2(numeric_literal_c, type, value) |
143 */ |
184 */ |
144 SYM_REF2(integer_literal_c, type, value) |
185 SYM_REF2(integer_literal_c, type, value) |
145 SYM_REF2(real_literal_c, type, value) |
186 SYM_REF2(real_literal_c, type, value) |
146 SYM_REF2(bit_string_literal_c, type, value) |
187 SYM_REF2(bit_string_literal_c, type, value) |
|
188 /* A typed or untyped boolean literal... */ |
|
189 /* type may be NULL */ |
147 SYM_REF2(boolean_literal_c, type, value) |
190 SYM_REF2(boolean_literal_c, type, value) |
148 |
191 |
149 /* helper class for boolean_literal_c */ |
192 /* helper class for boolean_literal_c */ |
150 SYM_REF0(boolean_true_c) |
193 SYM_REF0(boolean_true_c) |
151 |
194 |
166 |
209 |
167 /************************/ |
210 /************************/ |
168 /* B 1.2.3.1 - Duration */ |
211 /* B 1.2.3.1 - Duration */ |
169 /************************/ |
212 /************************/ |
170 SYM_REF0(neg_time_c) |
213 SYM_REF0(neg_time_c) |
171 SYM_REF2(duration_c, neg, interval) |
214 SYM_REF3(duration_c, type_name, neg, interval) |
172 SYM_TOKEN(fixed_point_c) |
215 SYM_TOKEN(fixed_point_c) |
173 SYM_REF2(days_c, days, hours) |
216 SYM_REF2(days_c, days, hours) |
174 SYM_REF2(hours_c, hours, minutes) |
217 SYM_REF2(hours_c, hours, minutes) |
175 SYM_REF2(minutes_c, minutes, seconds) |
218 SYM_REF2(minutes_c, minutes, seconds) |
176 SYM_REF2(seconds_c, seconds, milliseconds) |
219 SYM_REF2(seconds_c, seconds, milliseconds) |
178 |
221 |
179 |
222 |
180 /************************************/ |
223 /************************************/ |
181 /* B 1.2.3.2 - Time of day and Date */ |
224 /* B 1.2.3.2 - Time of day and Date */ |
182 /************************************/ |
225 /************************************/ |
183 SYM_REF1(time_of_day_c, daytime) |
226 SYM_REF2(time_of_day_c, type_name, daytime) |
184 SYM_REF3(daytime_c, day_hour, day_minute, day_second) |
227 SYM_REF3(daytime_c, day_hour, day_minute, day_second) |
185 SYM_REF1(date_c, date_literal) |
228 SYM_REF2(date_c, type_name, date_literal) |
186 SYM_REF3(date_literal_c, year, month, day) |
229 SYM_REF3(date_literal_c, year, month, day) |
187 SYM_REF2(date_and_time_c, date_literal, daytime) |
230 SYM_REF3(date_and_time_c, type_name, date_literal, daytime) |
188 |
231 |
189 |
232 |
190 /**********************/ |
233 /**********************/ |
191 /* B.1.3 - Data types */ |
234 /* B.1.3 - Data types */ |
192 /**********************/ |
235 /**********************/ |
213 SYM_REF0(dword_type_name_c) |
256 SYM_REF0(dword_type_name_c) |
214 SYM_REF0(lword_type_name_c) |
257 SYM_REF0(lword_type_name_c) |
215 SYM_REF0(string_type_name_c) |
258 SYM_REF0(string_type_name_c) |
216 SYM_REF0(wstring_type_name_c) |
259 SYM_REF0(wstring_type_name_c) |
217 |
260 |
218 /* |
261 /*****************************************************************/ |
219 SYM_REF0(constant_int_type_name_c) |
262 /* Keywords defined in "Safety Software Technical Specification" */ |
220 SYM_REF0(constant_real_type_name_c) |
263 /*****************************************************************/ |
221 */ |
264 |
|
265 SYM_REF0(safetime_type_name_c) |
|
266 SYM_REF0(safebool_type_name_c) |
|
267 SYM_REF0(safesint_type_name_c) |
|
268 SYM_REF0(safeint_type_name_c) |
|
269 SYM_REF0(safedint_type_name_c) |
|
270 SYM_REF0(safelint_type_name_c) |
|
271 SYM_REF0(safeusint_type_name_c) |
|
272 SYM_REF0(safeuint_type_name_c) |
|
273 SYM_REF0(safeudint_type_name_c) |
|
274 SYM_REF0(safeulint_type_name_c) |
|
275 SYM_REF0(safereal_type_name_c) |
|
276 SYM_REF0(safelreal_type_name_c) |
|
277 SYM_REF0(safedate_type_name_c) |
|
278 SYM_REF0(safetod_type_name_c) |
|
279 SYM_REF0(safedt_type_name_c) |
|
280 SYM_REF0(safebyte_type_name_c) |
|
281 SYM_REF0(safeword_type_name_c) |
|
282 SYM_REF0(safedword_type_name_c) |
|
283 SYM_REF0(safelword_type_name_c) |
|
284 SYM_REF0(safestring_type_name_c) |
|
285 SYM_REF0(safewstring_type_name_c) |
222 |
286 |
223 |
287 |
224 /********************************/ |
288 /********************************/ |
225 /* B.1.3.2 - Generic data types */ |
289 /* B.1.3.2 - Generic data types */ |
226 /********************************/ |
290 /********************************/ |