1457 * prev_declared_function_name_token, etc...). |
1457 * prev_declared_function_name_token, etc...). |
1458 * |
1458 * |
1459 * Unfortunately, the language (especially IL) uses tokens that are |
1459 * Unfortunately, the language (especially IL) uses tokens that are |
1460 * not defined as keywords in the spec (e.g. 'IN', 'R1', 'S1', 'PT', etc...)! |
1460 * not defined as keywords in the spec (e.g. 'IN', 'R1', 'S1', 'PT', etc...)! |
1461 * This means that it is valid to name a function 'IN', a variable 'PT', etc... |
1461 * This means that it is valid to name a function 'IN', a variable 'PT', etc... |
1462 * BUT, the lexical parser will interpret these names as tokens (keywords). |
1462 * In order to solve this potential ambiguity, flex only parses the above |
1463 * To allow these names to be used as function names, variable names, etc..., |
1463 * identifiers as keywords / tokens if we are currently parsing IL code. |
1464 * I (Mario) have augmented the definition of identifier to also include the tokens |
1464 * When parsing all code other than IL code, the above identifiers are treated |
1465 * that are not explicitly defined as keywords in the spec!! |
1465 * just like any other identifier. |
1466 * |
1466 * |
1467 * |
1467 * |
1468 * |
1468 * |
1469 * |
1469 * |
1470 * NOTE 2: |
1470 * NOTE 2: |
1527 * - WITH |
1527 * - WITH |
1528 */ |
1528 */ |
1529 |
1529 |
1530 identifier: |
1530 identifier: |
1531 identifier_token {$$ = new identifier_c($1, locloc(@$));} |
1531 identifier_token {$$ = new identifier_c($1, locloc(@$));} |
1532 /* Make sure that all tokens (names) not defined as keywords are included here... |
1532 ; |
1533 * I (Mario) have already done this, but if any changes are made to this file, |
1533 |
1534 * this list MUST be kept consistent!! |
1534 |
1535 */ |
|
1536 /**/ |
|
1537 /* |
|
1538 | PRIORITY {$$ = new identifier_c(strdup("PRIORITY"), locloc(@$));} |
|
1539 | SINGLE {$$ = new identifier_c(strdup("SINGLE"), locloc(@$));} |
|
1540 | INTERVAL {$$ = new identifier_c(strdup("INTERVAL"), locloc(@$));} |
|
1541 */ |
|
1542 /**/ |
|
1543 /* NOTE: AND, NOT, MOD, OR and XOR are keywords, so should not appear on this list... */ |
|
1544 /* |
|
1545 | LD_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1546 | LDN_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1547 | ST_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1548 | STN_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1549 | S_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1550 | R_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1551 | S1_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1552 | R1_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1553 | CLK_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1554 | CU_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1555 | CD_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1556 | PV_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1557 | IN_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1558 | PT_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1559 | ANDN_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1560 */ |
|
1561 /* NOTE: ANDN2_operator corresponds to the string '&N' in the source code! |
|
1562 * This is __not__ a valid name, so it is omitted from this list!! |
|
1563 *| ANDN2_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1564 */ |
|
1565 /* |
|
1566 | ORN_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1567 | XORN_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1568 | ADD_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1569 | SUB_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1570 | MUL_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1571 | DIV_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1572 | GT_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1573 | GE_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1574 | EQ_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1575 | LT_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1576 | LE_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1577 | NE_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1578 | CAL_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1579 | CALC_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1580 | CALCN_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1581 | RET_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1582 | RETC_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1583 | RETCN_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1584 | JMP_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1585 | JMPC_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1586 | JMPCN_operator {$$ = il_operator_c_2_identifier_c($1);} |
|
1587 */ |
|
1588 ; |
|
1589 |
1535 |
1590 /*********************/ |
1536 /*********************/ |
1591 /* B 1.2 - Constants */ |
1537 /* B 1.2 - Constants */ |
1592 /*********************/ |
1538 /*********************/ |
1593 constant: |
1539 constant: |
2558 |
2504 |
2559 symbolic_variable: |
2505 symbolic_variable: |
2560 /* NOTE: To be entirely correct, variable_name must be replacemed by |
2506 /* NOTE: To be entirely correct, variable_name must be replacemed by |
2561 * prev_declared_variable_name | prev_declared_fb_name | prev_declared_global_var_name |
2507 * prev_declared_variable_name | prev_declared_fb_name | prev_declared_global_var_name |
2562 */ |
2508 */ |
2563 identifier |
2509 prev_declared_fb_name |
2564 {$$ = new symbolic_variable_c($1, locloc(@$));} |
|
2565 | prev_declared_fb_name |
|
2566 {$$ = new symbolic_variable_c($1, locloc(@$));} |
2510 {$$ = new symbolic_variable_c($1, locloc(@$));} |
2567 | prev_declared_global_var_name |
2511 | prev_declared_global_var_name |
2568 {$$ = new symbolic_variable_c($1, locloc(@$));} |
2512 {$$ = new symbolic_variable_c($1, locloc(@$));} |
2569 | prev_declared_variable_name |
2513 | prev_declared_variable_name |
2570 {$$ = new symbolic_variable_c($1, locloc(@$));} |
2514 {$$ = new symbolic_variable_c($1, locloc(@$));} |
2571 | multi_element_variable |
2515 | multi_element_variable |
|
2516 /* |
|
2517 | identifier |
|
2518 {$$ = new symbolic_variable_c($1, locloc(@$));} |
|
2519 */ |
2572 ; |
2520 ; |
2573 |
2521 |
2574 |
2522 |
2575 /* NOTE: in section B 1.7, when configuring a program, symbolic_variable |
2523 /* NOTE: in section B 1.7, when configuring a program, symbolic_variable |
2576 * is used. Nevertheless, during the parsing of a configuration, |
2524 * is used. Nevertheless, during the parsing of a configuration, |
3277 * |
3225 * |
3278 * NOTE: Note that 'NOT' is special, as it conflicts |
3226 * NOTE: Note that 'NOT' is special, as it conflicts |
3279 * with two operators: the IL 'NOT' operator, and |
3227 * with two operators: the IL 'NOT' operator, and |
3280 * the unary operator 'NOT' in ST!! |
3228 * the unary operator 'NOT' in ST!! |
3281 * |
3229 * |
3282 * NOTE: The IL language is ambiguous, since using NOT, AND, ... |
3230 * NOTE: The IL language is ambiguous, since using NOT, AND, ... |
3283 * may be interpreted as either an IL operator, or |
3231 * may be interpreted as either an IL operator, or |
3284 * as a standard function call! |
3232 * as a standard function call! |
3285 * I (Mario) opted to interpret it as an IL operator. |
3233 * I (Mario) opted to interpret it as an IL operator. |
3286 * This requires changing the syntax for IL language |
3234 * This requires changing the syntax for IL language |
3287 * function calling, to exclude all function with |
3235 * function calling, to exclude all function with |
4985 * a preceding '-' to be used in primary_expression |
4933 * a preceding '-' to be used in primary_expression |
4986 */ |
4934 */ |
4987 /* NOTE: We use enumerated_value_without_identifier instead of enumerated_value |
4935 /* NOTE: We use enumerated_value_without_identifier instead of enumerated_value |
4988 * in order to remove a reduce/reduce conflict between reducing an |
4936 * in order to remove a reduce/reduce conflict between reducing an |
4989 * identifier to a variable or an enumerated_value. |
4937 * identifier to a variable or an enumerated_value. |
|
4938 * |
|
4939 * This change follows the IEC specification. The specification seems to |
|
4940 * imply (or is it explicit?) that in case the same identifier id used |
|
4941 * for a variable and an enumerated value, then the variable shall be |
|
4942 * considered?????????????? |
4990 */ |
4943 */ |
4991 primary_expression: |
4944 primary_expression: |
4992 /* constant */ |
4945 /* constant */ |
4993 non_negative_constant |
4946 non_negative_constant |
4994 | enumerated_value_without_identifier |
4947 | enumerated_value_without_identifier |