1317 * - unary_operator, multiply_operator, |
1318 * - unary_operator, multiply_operator, |
1318 * add_operator and comparison_operator |
1319 * add_operator and comparison_operator |
1319 * are not required. Their values are integrated |
1320 * are not required. Their values are integrated |
1320 * directly into other rules... |
1321 * directly into other rules... |
1321 */ |
1322 */ |
1322 %type <leaf> ref_expression /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ |
1323 %type <leaf> ref_expression /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ |
|
1324 %type <leaf> deref_expression /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ |
1323 %type <leaf> expression |
1325 %type <leaf> expression |
1324 %type <leaf> xor_expression |
1326 %type <leaf> xor_expression |
1325 %type <leaf> and_expression |
1327 %type <leaf> and_expression |
1326 %type <leaf> comparison |
1328 %type <leaf> comparison |
1327 %type <leaf> equ_expression |
1329 %type <leaf> equ_expression |
3397 | multi_element_variable |
3399 | multi_element_variable |
3398 /* |
3400 /* |
3399 | identifier |
3401 | identifier |
3400 {$$ = new symbolic_variable_c($1, locloc(@$));} |
3402 {$$ = new symbolic_variable_c($1, locloc(@$));} |
3401 */ |
3403 */ |
3402 ; |
3404 | symbolic_variable '^' |
|
3405 /* Dereferencing operator defined in IEC 61131-3 v3. However, implemented here differently then how it is defined in the standard! See following note for explanation! */ |
|
3406 {$$ = new deref_expression_c($1, locloc(@$));} |
|
3407 ; |
|
3408 /* |
|
3409 * NOTE: The syntax defined in the v3 standard for the dereferencing operator '^' seems to me to be un-intentionally |
|
3410 * limited. For example |
|
3411 * ref_to_bool_var := REF( array_of_bool [1] ); <--- Allowed! |
|
3412 * ref_to_bool_var := REF( ref_to_array_of_bool^[1] ); <--- Allowed! |
|
3413 * bool_var := array_of_ref_to_bool[1]^; <--- NOT Allowed! |
|
3414 * ref_to_array_of_bool^[1] := FALSE; <--- Allowed! |
|
3415 * I consider this a bug in the v3 standard!! |
|
3416 * I have therefore opted to implement this by simply adding a rule to symbolic_variable |
|
3417 * symbolic_variable: |
|
3418 * ... |
|
3419 * | symbolic_variable '^' |
|
3420 * This simple rule should be able to cover all the needed dereferencing syntax! |
|
3421 * I have also added a dereferencing expression for the DREF() operator. |
|
3422 * Since both of them do the exact same operation, they will both be translated to the exact same |
|
3423 * entry type in the abstract syntax tree (an deref_expression_c) |
|
3424 */ |
3403 |
3425 |
3404 |
3426 |
3405 /* NOTE: in section B 1.7, when configuring a program, symbolic_variable |
3427 /* NOTE: in section B 1.7, when configuring a program, symbolic_variable |
3406 * is used. Nevertheless, during the parsing of a configuration, |
3428 * is used. Nevertheless, during the parsing of a configuration, |
3407 * the variables in question are out of scope, so we should |
3429 * the variables in question are out of scope, so we should |
7231 /***********************/ |
7253 /***********************/ |
7232 /* B 3.1 - Expressions */ |
7254 /* B 3.1 - Expressions */ |
7233 /***********************/ |
7255 /***********************/ |
7234 expression: |
7256 expression: |
7235 xor_expression |
7257 xor_expression |
7236 | ref_expression /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ |
7258 | ref_expression /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ |
|
7259 | deref_expression /* an extension to the IEC 61131-3 v2 standard, based on the IEC 61131-3 v3 standard */ |
7237 | expression OR xor_expression |
7260 | expression OR xor_expression |
7238 {$$ = new or_expression_c($1, $3, locloc(@$));} |
7261 {$$ = new or_expression_c($1, $3, locloc(@$));} |
7239 /* ERROR_CHECK_BEGIN */ |
7262 /* ERROR_CHECK_BEGIN */ |
7240 | expression OR error |
7263 | expression OR error |
7241 {$$ = NULL; |
7264 {$$ = NULL; |
7250 /* This is an extension to the IEC 61131-3 standard. It is actually defined in the IEC 61131-3 v3 standard */ |
7273 /* This is an extension to the IEC 61131-3 standard. It is actually defined in the IEC 61131-3 v3 standard */ |
7251 /* The REF() operator returns the adrress of the variable. Basically, it returns a pointer to the variable */ |
7274 /* The REF() operator returns the adrress of the variable. Basically, it returns a pointer to the variable */ |
7252 ref_expression: |
7275 ref_expression: |
7253 REF '(' symbolic_variable ')' |
7276 REF '(' symbolic_variable ')' |
7254 {$$ = new ref_expression_c($3, locloc(@$));} |
7277 {$$ = new ref_expression_c($3, locloc(@$));} |
|
7278 ; |
|
7279 |
|
7280 /* DREF(var_name) */ |
|
7281 /* This is an extension to the IEC 61131-3 standard. It is actually defined in the IEC 61131-3 v3 standard */ |
|
7282 /* The DREF() operator accesses the variable stored in the specified address. Basically, it dereferences a pointer to the variable */ |
|
7283 deref_expression: |
|
7284 DREF '(' symbolic_variable ')' |
|
7285 {$$ = new deref_expression_c($3, locloc(@$));} |
7255 ; |
7286 ; |
7256 |
7287 |
7257 xor_expression: |
7288 xor_expression: |
7258 and_expression |
7289 and_expression |
7259 | xor_expression XOR and_expression |
7290 | xor_expression XOR and_expression |