1 /* |
1 /* |
2 * (c) 2003-2007 Mario de Sousa |
2 * matiec - a compiler for the programming languages defined in IEC 61131-3 |
3 * |
3 * |
4 * Offered to the public under the terms of the GNU General Public License |
4 * Copyright (C) 2003-2011 Mario de Sousa (msousa@fe.up.pt) |
5 * as published by the Free Software Foundation; either version 2 of the |
5 * |
6 * License, or (at your option) any later version. |
6 * This program is free software: you can redistribute it and/or modify |
7 * |
7 * it under the terms of the GNU General Public License as published by |
8 * This program is distributed in the hope that it will be useful, but |
8 * the Free Software Foundation, either version 3 of the License, or |
9 * WITHOUT ANY WARRANTY; without even the implied warranty of |
9 * (at your option) any later version. |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
10 * |
11 * Public License for more details. |
11 * This program is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 * GNU General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License |
|
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
18 * |
12 * |
19 * |
13 * This code is made available on the understanding that it will not be |
20 * This code is made available on the understanding that it will not be |
14 * used in safety-critical situations without a full and competent review. |
21 * used in safety-critical situations without a full and competent review. |
15 */ |
22 */ |
16 |
23 |
17 /* |
24 /* |
18 * An IEC 61131-3 IL, ST and SFC compiler. |
25 * An IEC 61131-3 compiler. |
19 * |
26 * |
20 * Based on the |
27 * Based on the |
21 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
28 * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) |
22 * |
29 * |
23 */ |
30 */ |
281 |
288 |
282 /**********************************************************************************/ |
289 /**********************************************************************************/ |
283 /* B XXX - Things that are missing from the standard, but should have been there! */ |
290 /* B XXX - Things that are missing from the standard, but should have been there! */ |
284 /**********************************************************************************/ |
291 /**********************************************************************************/ |
285 |
292 |
286 |
293 /* Pragmas that our compiler will accept. |
287 /* The pragmas... */ |
294 * See the comment in iec.flex for why these pragmas exist. |
|
295 */ |
|
296 %token disable_code_generation_pragma_token |
|
297 %token enable_code_generation_pragma_token |
|
298 %type <leaf> disable_code_generation_pragma |
|
299 %type <leaf> enable_code_generation_pragma |
|
300 |
|
301 |
|
302 /* All other pragmas that we do not support... */ |
|
303 /* In most stage 4, the text inside the pragmas will simply be copied to the output file. |
|
304 * This allows us to insert C code (if using stage 4 generating C code) |
|
305 * inside/interningled with the IEC 61131-3 code! |
|
306 */ |
288 %token <ID> pragma_token |
307 %token <ID> pragma_token |
289 %type <leaf> pragma |
308 %type <leaf> pragma |
|
309 |
|
310 /* The joining of all previous pragmas, i.e. any possible pragma */ |
|
311 %type <leaf> any_pragma |
290 |
312 |
291 |
313 |
292 /* Where do these tokens belong?? They are missing from the standard! */ |
314 /* Where do these tokens belong?? They are missing from the standard! */ |
293 /* NOTE: There are other tokens related to these 'EN' ENO', that are also |
315 /* NOTE: There are other tokens related to these 'EN' ENO', that are also |
294 * missing from the standard. However, their location in the annex B is |
316 * missing from the standard. However, their location in the annex B is |
324 |
346 |
325 /*********************/ |
347 /*********************/ |
326 /* B 1.2 - Constants */ |
348 /* B 1.2 - Constants */ |
327 /*********************/ |
349 /*********************/ |
328 %type <leaf> constant |
350 %type <leaf> constant |
329 /* a helper symbol for expression */ |
351 %type <leaf> non_negative_constant |
330 %type <leaf> non_negative_constant |
|
331 |
|
332 |
352 |
333 /******************************/ |
353 /******************************/ |
334 /* B 1.2.1 - Numeric Literals */ |
354 /* B 1.2.1 - Numeric Literals */ |
335 /******************************/ |
355 /******************************/ |
336 /* Done totally within flex... |
356 /* Done totally within flex... |
337 bit |
357 bit |
338 */ |
358 */ |
339 %type <leaf> numeric_literal |
359 %type <leaf> numeric_literal |
340 /* helper symbol for non_negative_constant */ |
|
341 %type <leaf> non_negative_numeric_literal |
|
342 %type <leaf> integer_literal |
360 %type <leaf> integer_literal |
343 %type <leaf> signed_integer |
361 %type <leaf> signed_integer |
344 /* a helper symbol for non_negative_constant */ |
|
345 %type <leaf> non_negative_signed_integer |
|
346 %token <ID> integer_token |
362 %token <ID> integer_token |
347 %type <leaf> integer |
363 %type <leaf> integer |
348 %token <ID> binary_integer_token |
364 %token <ID> binary_integer_token |
349 %type <leaf> binary_integer |
365 %type <leaf> binary_integer |
350 %token <ID> octal_integer_token |
366 %token <ID> octal_integer_token |
352 %token <ID> hex_integer_token |
368 %token <ID> hex_integer_token |
353 %type <leaf> hex_integer |
369 %type <leaf> hex_integer |
354 %token <ID> real_token |
370 %token <ID> real_token |
355 %type <leaf> real |
371 %type <leaf> real |
356 %type <leaf> signed_real |
372 %type <leaf> signed_real |
357 /* helper symbol for non_negative_real_literal */ |
|
358 %type <leaf> non_negative_signed_real |
|
359 %type <leaf> real_literal |
373 %type <leaf> real_literal |
360 /* helper symbol for non_negative_numeric_literal */ |
|
361 %type <leaf> non_negative_real_literal |
|
362 // %type <leaf> exponent |
374 // %type <leaf> exponent |
363 %type <leaf> bit_string_literal |
375 %type <leaf> bit_string_literal |
364 %type <leaf> boolean_literal |
376 %type <leaf> boolean_literal |
|
377 |
|
378 %token safeboolean_true_literal_token |
|
379 %token safeboolean_false_literal_token |
|
380 %token boolean_true_literal_token |
|
381 %token boolean_false_literal_token |
365 |
382 |
366 %token FALSE |
383 %token FALSE |
367 %token TRUE |
384 %token TRUE |
368 |
385 |
369 |
386 |
520 |
537 |
521 %token WSTRING |
538 %token WSTRING |
522 %token STRING |
539 %token STRING |
523 %token BOOL |
540 %token BOOL |
524 |
541 |
525 // %token TIME |
542 %token TIME |
526 // %token DATE |
543 %token DATE |
527 // %token DATE_AND_TIME |
544 %token DATE_AND_TIME |
528 %token DT |
545 %token DT |
529 // %token TIME_OF_DAY |
546 %token TIME_OF_DAY |
530 %token TOD |
547 %token TOD |
531 |
548 |
|
549 /******************************************************/ |
|
550 /* Symbols defined in */ |
|
551 /* "Safety Software Technical Specification, */ |
|
552 /* Part 1: Concepts and Function Blocks, */ |
|
553 /* Version 1.0 – Official Release" */ |
|
554 /* by PLCopen - Technical Committee 5 - 2006-01-31 */ |
|
555 /******************************************************/ |
|
556 |
|
557 %token SAFEBYTE |
|
558 %token SAFEWORD |
|
559 %token SAFEDWORD |
|
560 %token SAFELWORD |
|
561 |
|
562 %token SAFELREAL |
|
563 %token SAFEREAL |
|
564 |
|
565 %token SAFESINT |
|
566 %token SAFEINT |
|
567 %token SAFEDINT |
|
568 %token SAFELINT |
|
569 |
|
570 %token SAFEUSINT |
|
571 %token SAFEUINT |
|
572 %token SAFEUDINT |
|
573 %token SAFEULINT |
|
574 |
|
575 %token SAFEWSTRING |
|
576 %token SAFESTRING |
|
577 %token SAFEBOOL |
|
578 |
|
579 %token SAFETIME |
|
580 %token SAFEDATE |
|
581 %token SAFEDATE_AND_TIME |
|
582 %token SAFEDT |
|
583 %token SAFETIME_OF_DAY |
|
584 %token SAFETOD |
532 |
585 |
533 /********************************/ |
586 /********************************/ |
534 /* B 1.3.2 - Generic data types */ |
587 /* B 1.3.2 - Generic data types */ |
535 /********************************/ |
588 /********************************/ |
536 /* Strangely, the following symbol does seem to be required! */ |
589 /* Strangely, the following symbol does seem to be required! */ |
1344 /* B XXX - Things that are missing from the standard, but should have been there! */ |
1389 /* B XXX - Things that are missing from the standard, but should have been there! */ |
1345 /**********************************************************************************/ |
1390 /**********************************************************************************/ |
1346 |
1391 |
1347 |
1392 |
1348 /* the pragmas... */ |
1393 /* the pragmas... */ |
|
1394 |
|
1395 |
|
1396 disable_code_generation_pragma: |
|
1397 disable_code_generation_pragma_token {$$ = new disable_code_generation_pragma_c(locloc(@$));} |
|
1398 |
|
1399 enable_code_generation_pragma: |
|
1400 enable_code_generation_pragma_token {$$ = new enable_code_generation_pragma_c(locloc(@$));} |
|
1401 |
1349 pragma: |
1402 pragma: |
1350 pragma_token {$$ = new pragma_c($1, locloc(@$));} |
1403 pragma_token {$$ = new pragma_c($1, locloc(@$));} |
|
1404 |
|
1405 any_pragma: |
|
1406 disable_code_generation_pragma |
|
1407 | enable_code_generation_pragma |
|
1408 | pragma |
|
1409 ; |
1351 |
1410 |
1352 |
1411 |
1353 /* EN/ENO */ |
1412 /* EN/ENO */ |
1354 /* Tese tokens are essentially used as variable names, so we handle them |
1413 /* Tese tokens are essentially used as variable names, so we handle them |
1355 * similarly to these... |
1414 * similarly to these... |
1451 {if (tree_root == NULL) |
1510 {if (tree_root == NULL) |
1452 tree_root = new library_c(); |
1511 tree_root = new library_c(); |
1453 $$ = (list_c *)tree_root; |
1512 $$ = (list_c *)tree_root; |
1454 } |
1513 } |
1455 | library library_element_declaration |
1514 | library library_element_declaration |
|
1515 {$$ = $1; $$->add_element($2);} |
|
1516 | library any_pragma |
1456 {$$ = $1; $$->add_element($2);} |
1517 {$$ = $1; $$->add_element($2);} |
1457 /* ERROR_CHECK_BEGIN */ |
1518 /* ERROR_CHECK_BEGIN */ |
1458 | library error library_element_declaration |
1519 | library error library_element_declaration |
1459 {$$ = $1; print_err_msg(locf(@2), locl(@2), "unknown syntax error."); yyerrok;} |
1520 {$$ = $1; print_err_msg(locf(@2), locl(@2), "unknown syntax error."); yyerrok;} |
1460 | library error END_OF_INPUT |
1521 | library error END_OF_INPUT |
1595 | character_string |
1656 | character_string |
1596 | time_literal |
1657 | time_literal |
1597 | bit_string_literal |
1658 | bit_string_literal |
1598 | boolean_literal |
1659 | boolean_literal |
1599 /* NOTE: in order to remove reduce/reduce conflicts, |
1660 /* NOTE: in order to remove reduce/reduce conflicts, |
|
1661 * [between -9.5 being parsed as |
|
1662 * (i) a signed real, |
|
1663 * (ii) or as a real preceded by the '-' operator |
|
1664 * ] |
|
1665 * we need to define a variant of the constant construct |
|
1666 * where any constant is never preceded by the '-' character. |
|
1667 * In order to do this, we have borugh the signed_real |
|
1668 * directly into the definition of the constant construct |
|
1669 * (so we can define another non_negative_constant |
|
1670 * construct that does not include it!) |
|
1671 */ |
|
1672 | signed_real |
|
1673 /* NOTE: in order to remove reduce/reduce conflicts, |
1600 * unsigned_integer, signed_integer, binary_integer, octal_integer |
1674 * unsigned_integer, signed_integer, binary_integer, octal_integer |
1601 * and hex_integer have been integrated directly into |
1675 * and hex_integer have been integrated directly into |
1602 * the constants construct, instead of belonging to |
1676 * the constants construct, instead of belonging to |
1603 * either the bit_string_literal or integer_literal |
1677 * both the bit_string_literal or integer_literal |
1604 * construct. |
1678 * construct. |
1605 */ |
1679 */ |
1606 /* NOTE: unsigned_integer, although used in some |
1680 /* NOTE: unsigned_integer, although used in some |
1607 * rules, is not defined in the spec! |
1681 * rules, is not defined in the spec! |
1608 * We therefore replaced unsigned_integer as integer |
1682 * We therefore replaced unsigned_integer as integer |
1612 | binary_integer |
1686 | binary_integer |
1613 | octal_integer |
1687 | octal_integer |
1614 | hex_integer |
1688 | hex_integer |
1615 ; |
1689 ; |
1616 |
1690 |
1617 /* a helper symbol for expression */ |
1691 |
1618 /* A constant without any preceding '-', but may |
1692 /* NOTE: in order to remove reduce/reduce conflicts, |
1619 * include a preceding '+' ! |
1693 * [between -9.5 being parsed as |
|
1694 * (i) a signed real, |
|
1695 * (ii) or as a real preceded by the '-' operator |
|
1696 * ] |
|
1697 * we need to define a variant of the constant construct |
|
1698 * where any constant is never preceded by the '-' character. |
|
1699 * In order to do this, we have borugh the signed_real |
|
1700 * directly into the definition of the constant construct |
|
1701 * (so we can define another non_negative_constant |
|
1702 * construct that does not include it!) |
1620 */ |
1703 */ |
1621 non_negative_constant: |
1704 non_negative_constant: |
1622 non_negative_numeric_literal |
1705 numeric_literal |
1623 | character_string |
1706 | character_string |
1624 | time_literal |
1707 | time_literal |
1625 | bit_string_literal |
1708 | bit_string_literal |
1626 | boolean_literal |
1709 | boolean_literal |
1627 | non_negative_signed_integer |
1710 /* NOTE: in order to remove reduce/reduce conflicts, |
|
1711 * [between -9.5 being parsed as |
|
1712 * (i) a signed real, |
|
1713 * (ii) or as a real preceded by the '-' operator |
|
1714 * ] |
|
1715 * we need to define a variant of the constant construct |
|
1716 * where any constant is never preceded by the '-' character. |
|
1717 * In order to do this, we have borugh the signed_real |
|
1718 * directly into the definition of the constant construct |
|
1719 * (so we can define another non_negative_constant |
|
1720 * construct that does not include it!) |
|
1721 */ |
|
1722 /* | signed_real */ |
|
1723 | real /* an unsigned real */ |
|
1724 /* NOTE: in order to remove reduce/reduce conflicts, |
|
1725 * unsigned_integer, signed_integer, binary_integer, octal_integer |
|
1726 * and hex_integer have been integrated directly into |
|
1727 * the constants construct, instead of belonging to |
|
1728 * both the bit_string_literal or integer_literal |
|
1729 * construct. |
|
1730 */ |
|
1731 /* NOTE: unsigned_integer, although used in some |
|
1732 * rules, is not defined in the spec! |
|
1733 * We therefore replaced unsigned_integer as integer |
|
1734 */ |
|
1735 | integer /* i.e. an unsigned_integer */ |
|
1736 /* | signed_integer */ |
1628 | binary_integer |
1737 | binary_integer |
1629 | octal_integer |
1738 | octal_integer |
1630 | hex_integer |
1739 | hex_integer |
1631 ; |
1740 ; |
1632 |
|
1633 |
1741 |
1634 |
1742 |
1635 /******************************/ |
1743 /******************************/ |
1636 /* B 1.2.1 - Numeric Literals */ |
1744 /* B 1.2.1 - Numeric Literals */ |
1637 /******************************/ |
1745 /******************************/ |
1661 * real_literal: [real_type_name '#'] singned_real |
1769 * real_literal: [real_type_name '#'] singned_real |
1662 * signed_real: ['+'|'-'] real |
1770 * signed_real: ['+'|'-'] real |
1663 * Flex handles real, while bison handles signed_real |
1771 * Flex handles real, while bison handles signed_real |
1664 * and real_literal. |
1772 * and real_literal. |
1665 * |
1773 * |
1666 * - According to the spec, intger '.' integer |
1774 * - According to the spec, integer '.' integer |
1667 * may be reduced to either a real or a fixed_point. |
1775 * may be reduced to either a real or a fixed_point. |
1668 * It is nevertheless possible to figure out from the |
1776 * It is nevertheless possible to figure out from the |
1669 * context which of the two rules should be used in |
1777 * context which of the two rules should be used in |
1670 * the reduction. |
1778 * the reduction. |
1671 * Unfortunately, due to the issue described above |
1779 * Unfortunately, due to the issue described above |
1759 ; |
1861 ; |
1760 |
1862 |
1761 signed_integer: |
1863 signed_integer: |
1762 integer |
1864 integer |
1763 | '+' integer {$$ = $2;} |
1865 | '+' integer {$$ = $2;} |
1764 | '-' integer {$$ = new neg_literal_c($2, locloc(@$));} |
1866 | '-' integer {$$ = new neg_integer_c($2, locloc(@$));} |
1765 ; |
|
1766 |
|
1767 /* a helper symbol for non_negative_constant */ |
|
1768 /* A integer without any preceding '-', but may |
|
1769 * include a preceding '+' ! |
|
1770 */ |
|
1771 non_negative_signed_integer: |
|
1772 integer |
|
1773 | '+' integer {$$ = $2;} |
|
1774 ; |
1867 ; |
1775 |
1868 |
1776 |
1869 |
1777 real_literal: |
1870 real_literal: |
1778 signed_real |
1871 /* NOTE: see note in the definition of constant for reason |
1779 | real_type_name '#' signed_real |
1872 * why signed_real is missing here! |
|
1873 */ |
|
1874 /* signed_real */ |
|
1875 real_type_name '#' signed_real |
1780 {$$ = new real_literal_c($1, $3, locf(@1), locl(@3));} |
1876 {$$ = new real_literal_c($1, $3, locf(@1), locl(@3));} |
1781 /* ERROR_CHECK_BEGIN */ |
1877 /* ERROR_CHECK_BEGIN */ |
1782 | real_type_name signed_real |
1878 | real_type_name signed_real |
1783 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between real type name and value in real literal."); yynerrs++;} |
1879 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between real type name and value in real literal."); yynerrs++;} |
1784 | real_type_name '#' error |
1880 | real_type_name '#' error |
1788 yyerrok; |
1884 yyerrok; |
1789 } |
1885 } |
1790 /* ERROR_CHECK_END */ |
1886 /* ERROR_CHECK_END */ |
1791 ; |
1887 ; |
1792 |
1888 |
1793 /* helper symbol for non_negative_numeric_literal */ |
|
1794 non_negative_real_literal: |
|
1795 non_negative_signed_real |
|
1796 | real_type_name '#' signed_real |
|
1797 {$$ = new real_literal_c($1, $3, locf(@1), locl(@3));} |
|
1798 ; |
|
1799 |
1889 |
1800 signed_real: |
1890 signed_real: |
1801 real |
1891 real |
1802 | '+' real {$$ = $2;} |
1892 | '+' real {$$ = $2;} |
1803 | '-' real {$$ = new neg_literal_c($2, locloc(@2));} |
1893 | '-' real {$$ = new neg_real_c($2, locloc(@2));} |
1804 ; |
1894 ; |
1805 |
1895 |
1806 /* helper symbol for non_negative_real_literal */ |
|
1807 non_negative_signed_real: |
|
1808 real |
|
1809 | '+' real {$$ = $2;} |
|
1810 ; |
|
1811 |
1896 |
1812 |
1897 |
1813 bit_string_literal: |
1898 bit_string_literal: |
1814 bit_string_type_name '#' integer /* i.e. unsigned_integer */ |
1899 bit_string_type_name '#' integer /* i.e. unsigned_integer */ |
1815 {$$ = new bit_string_literal_c($1, $3, locf(@1), locl(@3));} |
1900 {$$ = new bit_string_literal_c($1, $3, locf(@1), locl(@3));} |
1836 | bit_string_type_name octal_integer |
1921 | bit_string_type_name octal_integer |
1837 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between bit string type name and value in bit string literal."); yynerrs++;} |
1922 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between bit string type name and value in bit string literal."); yynerrs++;} |
1838 | bit_string_type_name hex_integer |
1923 | bit_string_type_name hex_integer |
1839 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between bit string type name and value in bit string literal."); yynerrs++;} |
1924 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between bit string type name and value in bit string literal."); yynerrs++;} |
1840 | bit_string_type_name '#' error |
1925 | bit_string_type_name '#' error |
1841 {$$ = NULL; |
1926 {$$ = NULL; |
1842 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for bit string literal.");} |
1927 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no value defined for bit string literal.");} |
1843 else {print_err_msg(locf(@3), locl(@3), "invalid value for bit string literal."); yyclearin;} |
1928 else {print_err_msg(locf(@3), locl(@3), "invalid value for bit string literal."); yyclearin;} |
1844 yyerrok; |
1929 yyerrok; |
1845 } |
1930 } |
1846 /* ERROR_CHECK_END */ |
1931 /* ERROR_CHECK_END */ |
1847 ; |
1932 ; |
1848 |
1933 |
1849 |
1934 |
1850 boolean_literal: |
1935 boolean_literal: |
1851 TRUE {$$ = new boolean_literal_c(new bool_type_name_c(locloc(@$)), |
1936 boolean_true_literal_token |
1852 new boolean_true_c(locloc(@$)), |
1937 {$$ = new boolean_literal_c(new bool_type_name_c(locloc(@$)), |
1853 locloc(@$));} |
1938 new boolean_true_c(locloc(@$)), |
1854 | FALSE {$$ = new boolean_literal_c(new bool_type_name_c(locloc(@$)), |
1939 locloc(@$)); |
|
1940 } |
|
1941 | boolean_false_literal_token |
|
1942 {$$ = new boolean_literal_c(new bool_type_name_c(locloc(@$)), |
1855 new boolean_false_c(locloc(@$)), |
1943 new boolean_false_c(locloc(@$)), |
1856 locloc(@$));} |
1944 locloc(@$)); |
|
1945 } |
|
1946 | safeboolean_true_literal_token |
|
1947 {$$ = new boolean_literal_c(new safebool_type_name_c(locloc(@$)), |
|
1948 new boolean_true_c(locloc(@$)), |
|
1949 locloc(@$)); |
|
1950 } |
|
1951 | safeboolean_false_literal_token |
|
1952 {$$ = new boolean_literal_c(new safebool_type_name_c(locloc(@$)), |
|
1953 new boolean_false_c(locloc(@$)), |
|
1954 locloc(@$)); |
|
1955 } |
|
1956 | FALSE |
|
1957 {$$ = new boolean_literal_c(NULL, |
|
1958 new boolean_false_c(locloc(@$)), |
|
1959 locloc(@$)); |
|
1960 } |
|
1961 | TRUE |
|
1962 {$$ = new boolean_literal_c(NULL, |
|
1963 new boolean_true_c(locloc(@$)), |
|
1964 locloc(@$)); |
|
1965 } |
1857 /* |
1966 /* |
1858 | BOOL '#' '1' {} |
1967 | BOOL '#' '1' {} |
1859 | BOOL '#' '0' {} |
1968 | BOOL '#' '0' {} |
1860 */ |
1969 */ |
1861 /* NOTE: the rules |
1970 /* NOTE: the rules |
1933 * |
2042 * |
1934 * We therefore have flex returning the token T_SHARP |
2043 * We therefore have flex returning the token T_SHARP |
1935 * when it comes across 'T#' |
2044 * when it comes across 'T#' |
1936 */ |
2045 */ |
1937 TIME '#' interval |
2046 TIME '#' interval |
1938 {$$ = new duration_c(NULL, $3, locloc(@$));} |
2047 {$$ = new duration_c(new time_type_name_c(locloc(@1)), NULL, $3, locloc(@$));} |
1939 | TIME '#' '-' interval |
2048 | TIME '#' '-' interval |
1940 {$$ = new duration_c(new neg_time_c(locloc(@$)), $4, locloc(@$));} |
2049 {$$ = new duration_c(new time_type_name_c(locloc(@1)), new neg_time_c(locloc(@$)), $4, locloc(@$));} |
1941 | T_SHARP interval |
2050 | T_SHARP interval |
1942 {$$ = new duration_c(NULL, $2, locloc(@$));} |
2051 {$$ = new duration_c(new time_type_name_c(locloc(@1)), NULL, $2, locloc(@$));} |
1943 | T_SHARP '-' interval |
2052 | T_SHARP '-' interval |
1944 {$$ = new duration_c(new neg_time_c(locloc(@$)), $3, locloc(@$));} |
2053 {$$ = new duration_c(new time_type_name_c(locloc(@1)), new neg_time_c(locloc(@$)), $3, locloc(@$));} |
|
2054 | SAFETIME '#' interval |
|
2055 {$$ = new duration_c(new safetime_type_name_c(locloc(@1)), NULL, $3, locloc(@$));} |
|
2056 | SAFETIME '#' '-' interval |
|
2057 {$$ = new duration_c(new safetime_type_name_c(locloc(@1)), new neg_time_c(locloc(@$)), $4, locloc(@$));} |
1945 /* ERROR_CHECK_BEGIN */ |
2058 /* ERROR_CHECK_BEGIN */ |
1946 | TIME interval |
2059 | TIME interval |
1947 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'TIME' and interval in duration."); yynerrs++;} |
2060 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'TIME' and interval in duration."); yynerrs++;} |
1948 | TIME '-' interval |
2061 | TIME '-' interval |
1949 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'TIME' and interval in duration."); yynerrs++;} |
2062 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'TIME' and interval in duration."); yynerrs++;} |
2104 /************************************/ |
2217 /************************************/ |
2105 /* B 1.2.3.2 - Time of day and Date */ |
2218 /* B 1.2.3.2 - Time of day and Date */ |
2106 /************************************/ |
2219 /************************************/ |
2107 time_of_day: |
2220 time_of_day: |
2108 TIME_OF_DAY '#' daytime |
2221 TIME_OF_DAY '#' daytime |
2109 {$$ = new time_of_day_c($3, locloc(@$));} |
2222 {$$ = new time_of_day_c(new tod_type_name_c(locloc(@1)), $3, locloc(@$));} |
|
2223 | SAFETIME_OF_DAY '#' daytime |
|
2224 {$$ = new time_of_day_c(new safetod_type_name_c(locloc(@1)), $3, locloc(@$));} |
2110 /* ERROR_CHECK_BEGIN */ |
2225 /* ERROR_CHECK_BEGIN */ |
2111 | TIME_OF_DAY daytime |
2226 | TIME_OF_DAY daytime |
2112 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'TIME_OF_DAY' and daytime in time of day."); yynerrs++;} |
2227 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'TIME_OF_DAY' and daytime in time of day."); yynerrs++;} |
2113 | TIME_OF_DAY '#' error |
2228 | TIME_OF_DAY '#' error |
2114 {$$ = NULL; |
2229 {$$ = NULL; |
2151 day_second: fixed_point; |
2266 day_second: fixed_point; |
2152 |
2267 |
2153 |
2268 |
2154 date: |
2269 date: |
2155 DATE '#' date_literal |
2270 DATE '#' date_literal |
2156 {$$ = new date_c($3, locloc(@$));} |
2271 {$$ = new date_c(new date_type_name_c(locloc(@1)), $3, locloc(@$));} |
2157 | D_SHARP date_literal |
2272 | D_SHARP date_literal |
2158 {$$ = new date_c($2, locloc(@$));} |
2273 {$$ = new date_c(new date_type_name_c(locloc(@1)), $2, locloc(@$));} |
|
2274 | SAFEDATE '#' date_literal |
|
2275 {$$ = new date_c(new safedate_type_name_c(locloc(@1)), $3, locloc(@$));} |
2159 /* ERROR_CHECK_BEGIN */ |
2276 /* ERROR_CHECK_BEGIN */ |
2160 | DATE date_literal |
2277 | DATE date_literal |
2161 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'DATE' and date literal in date."); yynerrs++;} |
2278 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'DATE' and date literal in date."); yynerrs++;} |
2162 | DATE '#' error |
2279 | DATE '#' error |
2163 {$$ = NULL; |
2280 {$$ = NULL; |
2204 day: integer; |
2321 day: integer; |
2205 |
2322 |
2206 |
2323 |
2207 date_and_time: |
2324 date_and_time: |
2208 DATE_AND_TIME '#' date_literal '-' daytime |
2325 DATE_AND_TIME '#' date_literal '-' daytime |
2209 {$$ = new date_and_time_c($3, $5, locloc(@$));} |
2326 {$$ = new date_and_time_c(new dt_type_name_c(locloc(@1)), $3, $5, locloc(@$));} |
|
2327 | SAFEDATE_AND_TIME '#' date_literal '-' daytime |
|
2328 {$$ = new date_and_time_c(new safedt_type_name_c(locloc(@1)), $3, $5, locloc(@$));} |
2210 /* ERROR_CHECK_BEGIN */ |
2329 /* ERROR_CHECK_BEGIN */ |
2211 | DATE_AND_TIME date_literal '-' daytime |
2330 | DATE_AND_TIME date_literal '-' daytime |
2212 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'DATE_AND_TIME' and date literal in date and time."); yynerrs++;} |
2331 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "'#' missing between 'DATE_AND_TIME' and date literal in date and time."); yynerrs++;} |
2213 | DATE_AND_TIME '#' '-' daytime |
2332 | DATE_AND_TIME '#' '-' daytime |
2214 {$$ = NULL; print_err_msg(locl(@2), locf(@3), "no value defined for date literal in date and time."); yynerrs++;} |
2333 {$$ = NULL; print_err_msg(locl(@2), locf(@3), "no value defined for date literal in date and time."); yynerrs++;} |
2249 |
2368 |
2250 |
2369 |
2251 /***********************************/ |
2370 /***********************************/ |
2252 /* B 1.3.1 - Elementary Data Types */ |
2371 /* B 1.3.1 - Elementary Data Types */ |
2253 /***********************************/ |
2372 /***********************************/ |
|
2373 /******************************************************/ |
|
2374 /* SAFExxxx Symbols defined in */ |
|
2375 /* "Safety Software Technical Specification, */ |
|
2376 /* Part 1: Concepts and Function Blocks, */ |
|
2377 /* Version 1.0 – Official Release" */ |
|
2378 /* by PLCopen - Technical Committee 5 - 2006-01-31 */ |
|
2379 /******************************************************/ |
|
2380 |
2254 elementary_type_name: |
2381 elementary_type_name: |
2255 numeric_type_name |
2382 numeric_type_name |
2256 | date_type_name |
2383 | date_type_name |
2257 | bit_string_type_name |
2384 | bit_string_type_name |
2258 | elementary_string_type_name |
2385 | elementary_string_type_name |
2260 | BOOL {$$ = new bool_type_name_c(locloc(@$));} |
2387 | BOOL {$$ = new bool_type_name_c(locloc(@$));} |
2261 /* NOTE: see note under the B 1.2.1 section of token |
2388 /* NOTE: see note under the B 1.2.1 section of token |
2262 * and grouping type definition for reason why BOOL |
2389 * and grouping type definition for reason why BOOL |
2263 * was added to this definition. |
2390 * was added to this definition. |
2264 */ |
2391 */ |
2265 /******************************************************/ |
2392 | SAFETIME {$$ = new safetime_type_name_c(locloc(@$));} |
2266 /* Symbols defined in */ |
|
2267 /* "Safety Software Technical Specification, */ |
|
2268 /* Part 1: Concepts and Function Blocks, */ |
|
2269 /* Version 1.0 – Official Release" */ |
|
2270 /* by PLCopen - Technical Committee 5 - 2006-01-31 */ |
|
2271 /******************************************************/ |
|
2272 | SAFEBOOL {$$ = new safebool_type_name_c(locloc(@$));} |
2393 | SAFEBOOL {$$ = new safebool_type_name_c(locloc(@$));} |
2273 ; |
2394 ; |
2274 |
2395 |
2275 numeric_type_name: |
2396 numeric_type_name: |
2276 integer_type_name |
2397 integer_type_name |
2281 signed_integer_type_name |
2402 signed_integer_type_name |
2282 | unsigned_integer_type_name |
2403 | unsigned_integer_type_name |
2283 ; |
2404 ; |
2284 |
2405 |
2285 signed_integer_type_name: |
2406 signed_integer_type_name: |
2286 SINT {$$ = new sint_type_name_c(locloc(@$));} |
2407 SINT {$$ = new sint_type_name_c(locloc(@$));} |
2287 | INT {$$ = new int_type_name_c(locloc(@$));} |
2408 | INT {$$ = new int_type_name_c(locloc(@$));} |
2288 | DINT {$$ = new dint_type_name_c(locloc(@$));} |
2409 | DINT {$$ = new dint_type_name_c(locloc(@$));} |
2289 | LINT {$$ = new lint_type_name_c(locloc(@$));} |
2410 | LINT {$$ = new lint_type_name_c(locloc(@$));} |
|
2411 | SAFESINT {$$ = new safesint_type_name_c(locloc(@$));} |
|
2412 | SAFEINT {$$ = new safeint_type_name_c(locloc(@$));} |
|
2413 | SAFEDINT {$$ = new safedint_type_name_c(locloc(@$));} |
|
2414 | SAFELINT {$$ = new safelint_type_name_c(locloc(@$));} |
2290 ; |
2415 ; |
2291 |
2416 |
2292 unsigned_integer_type_name: |
2417 unsigned_integer_type_name: |
2293 USINT {$$ = new usint_type_name_c(locloc(@$));} |
2418 USINT {$$ = new usint_type_name_c(locloc(@$));} |
2294 | UINT {$$ = new uint_type_name_c(locloc(@$));} |
2419 | UINT {$$ = new uint_type_name_c(locloc(@$));} |
2295 | UDINT {$$ = new udint_type_name_c(locloc(@$));} |
2420 | UDINT {$$ = new udint_type_name_c(locloc(@$));} |
2296 | ULINT {$$ = new ulint_type_name_c(locloc(@$));} |
2421 | ULINT {$$ = new ulint_type_name_c(locloc(@$));} |
|
2422 | SAFEUSINT {$$ = new safeusint_type_name_c(locloc(@$));} |
|
2423 | SAFEUINT {$$ = new safeuint_type_name_c(locloc(@$));} |
|
2424 | SAFEUDINT {$$ = new safeudint_type_name_c(locloc(@$));} |
|
2425 | SAFEULINT {$$ = new safeulint_type_name_c(locloc(@$));} |
2297 ; |
2426 ; |
2298 |
2427 |
2299 real_type_name: |
2428 real_type_name: |
2300 REAL {$$ = new real_type_name_c(locloc(@$));} |
2429 REAL {$$ = new real_type_name_c(locloc(@$));} |
2301 | LREAL {$$ = new lreal_type_name_c(locloc(@$));} |
2430 | LREAL {$$ = new lreal_type_name_c(locloc(@$));} |
|
2431 | SAFEREAL {$$ = new safereal_type_name_c(locloc(@$));} |
|
2432 | SAFELREAL {$$ = new safelreal_type_name_c(locloc(@$));} |
2302 ; |
2433 ; |
2303 |
2434 |
2304 date_type_name: |
2435 date_type_name: |
2305 DATE {$$ = new date_type_name_c(locloc(@$));} |
2436 DATE {$$ = new date_type_name_c(locloc(@$));} |
2306 | TIME_OF_DAY {$$ = new tod_type_name_c(locloc(@$));} |
2437 | TIME_OF_DAY {$$ = new tod_type_name_c(locloc(@$));} |
2307 | TOD {$$ = new tod_type_name_c(locloc(@$));} |
2438 | TOD {$$ = new tod_type_name_c(locloc(@$));} |
2308 | DATE_AND_TIME {$$ = new dt_type_name_c(locloc(@$));} |
2439 | DATE_AND_TIME {$$ = new dt_type_name_c(locloc(@$));} |
2309 | DT {$$ = new dt_type_name_c(locloc(@$));} |
2440 | DT {$$ = new dt_type_name_c(locloc(@$));} |
|
2441 | SAFEDATE {$$ = new safedate_type_name_c(locloc(@$));} |
|
2442 | SAFETIME_OF_DAY {$$ = new safetod_type_name_c(locloc(@$));} |
|
2443 | SAFETOD {$$ = new safetod_type_name_c(locloc(@$));} |
|
2444 | SAFEDATE_AND_TIME {$$ = new safedt_type_name_c(locloc(@$));} |
|
2445 | SAFEDT {$$ = new safedt_type_name_c(locloc(@$));} |
2310 ; |
2446 ; |
2311 |
2447 |
2312 |
2448 |
2313 bit_string_type_name: |
2449 bit_string_type_name: |
2314 BYTE {$$ = new byte_type_name_c(locloc(@$));} |
2450 BYTE {$$ = new byte_type_name_c(locloc(@$));} |
2315 | WORD {$$ = new word_type_name_c(locloc(@$));} |
2451 | WORD {$$ = new word_type_name_c(locloc(@$));} |
2316 | DWORD {$$ = new dword_type_name_c(locloc(@$));} |
2452 | DWORD {$$ = new dword_type_name_c(locloc(@$));} |
2317 | LWORD {$$ = new lword_type_name_c(locloc(@$));} |
2453 | LWORD {$$ = new lword_type_name_c(locloc(@$));} |
|
2454 | SAFEBYTE {$$ = new safebyte_type_name_c(locloc(@$));} |
|
2455 | SAFEWORD {$$ = new safeword_type_name_c(locloc(@$));} |
|
2456 | SAFEDWORD {$$ = new safedword_type_name_c(locloc(@$));} |
|
2457 | SAFELWORD {$$ = new safelword_type_name_c(locloc(@$));} |
2318 /* NOTE: see note under the B 1.2.1 section of token |
2458 /* NOTE: see note under the B 1.2.1 section of token |
2319 * and grouping type definition for reason why the BOOL |
2459 * and grouping type definition for reason why the BOOL |
2320 * was omitted from this definition. |
2460 * was omitted from this definition. |
2321 */ |
2461 */ |
2322 ; |
2462 ; |
6373 /* ERROR_CHECK_END */ |
6515 /* ERROR_CHECK_END */ |
6374 ; |
6516 ; |
6375 |
6517 |
6376 |
6518 |
6377 il_param_instruction: |
6519 il_param_instruction: |
6378 il_param_assignment ',' eol_list |
6520 il_param_assignment ',' eol_list |
6379 | il_param_out_assignment ',' eol_list |
6521 | il_param_out_assignment ',' eol_list |
6380 /* ERROR_CHECK_BEGIN */ |
6522 /* ERROR_CHECK_BEGIN */ |
6381 | il_param_assignment ',' error |
6523 | il_param_assignment ',' error |
6382 {$$ = NULL; print_err_msg(locl(@2), locf(@3), "EOL missing at the end of parameter assignment in parameter assignment list."); yyerrok;} |
6524 {$$ = NULL; print_err_msg(locl(@2), locf(@3), "EOL missing at the end of parameter assignment in parameter assignment list."); yyerrok;} |
6383 | il_param_out_assignment ',' error |
6525 | il_param_out_assignment ',' error |
6605 il_assign_out_operator: |
6747 il_assign_out_operator: |
6606 /* variable_name SENDTO */ |
6748 /* variable_name SENDTO */ |
6607 /* any_identifier SENDTO */ |
6749 /* any_identifier SENDTO */ |
6608 sendto_identifier SENDTO |
6750 sendto_identifier SENDTO |
6609 {$$ = new il_assign_out_operator_c(NULL, $1, locloc(@$));} |
6751 {$$ = new il_assign_out_operator_c(NULL, $1, locloc(@$));} |
|
6752 /* The following is not required, as the sendto_identifier_token returned by flex will |
|
6753 * also include the 'ENO' identifier. |
|
6754 * The resulting abstract syntax tree is identical with or without this following rule, |
|
6755 * as both the eno_identifier and the sendto_identifier are stored as |
|
6756 * an identifier_c !! |
|
6757 */ |
|
6758 /* |
6610 | eno_identifier SENDTO |
6759 | eno_identifier SENDTO |
6611 {$$ = new il_assign_out_operator_c(NULL, $1, locloc(@$));} |
6760 {$$ = new il_assign_out_operator_c(NULL, $1, locloc(@$));} |
|
6761 */ |
6612 /*| NOT variable_name SENDTO */ |
6762 /*| NOT variable_name SENDTO */ |
6613 | NOT sendto_identifier SENDTO |
6763 | NOT sendto_identifier SENDTO |
6614 {$$ = new il_assign_out_operator_c(new not_paramassign_c(locloc(@1)), $2, locloc(@$));} |
6764 {$$ = new il_assign_out_operator_c(new not_paramassign_c(locloc(@1)), $2, locloc(@$));} |
|
6765 /* The following is not required, as the sendto_identifier_token returned by flex will |
|
6766 * also include the 'ENO' identifier. |
|
6767 * The resulting abstract syntax tree is identical with or without this following rule, |
|
6768 * as both the eno_identifier and the sendto_identifier are stored as |
|
6769 * an identifier_c !! |
|
6770 * |
|
6771 * NOTE: Removing the following rule also removes a shift/reduce conflict from the parser. |
|
6772 * This conflict is not really an error/ambiguity in the syntax, but rather |
|
6773 * due to the fact that more than a single look-ahead token would be required |
|
6774 * to correctly parse the syntax, something that bison does not support. |
|
6775 * |
|
6776 * The shift/reduce conflict arises because bison does not know whether |
|
6777 * to parse the 'NOT ENO' in the following code |
|
6778 * LD 1 |
|
6779 * funct_name ( |
|
6780 * NOT ENO => bool_var, |
|
6781 * EN := TRUE |
|
6782 * ) |
|
6783 * as either a il_param_assignment (wrong!) or an il_param_out_assignment.(correct). |
|
6784 * The '=>' delimiter (known as SEND_TO in this iec.y file) is a dead giveaway that |
|
6785 * it should be parsed as an il_param_out_assignment, but still, bison gets confused! |
|
6786 * Bison considers the possibility of reducing the 'NOT ENO' as an NOT_operator with |
|
6787 * the 'ENO' operand |
|
6788 * (NOT_operator -> il_simple_operator -> il_simple_operation -> il_simple_instruction -> |
|
6789 * -> simple_instr_list -> il_param_assignment) |
|
6790 * instead of reducing it to an il_param_out_operator. |
|
6791 * ( il_param_out_operator -> il_param_out_assignment) |
|
6792 * |
|
6793 * Note that the shift/reduce conflict only manifests itself in the il_formal_funct_call, |
|
6794 * where both the il_param_out_assignment and il_param_assignment are used! |
|
6795 * |
|
6796 * il_param_out_assignment --+--> il_param_instruction -> il_param_instruction_list --+ |
|
6797 * | | |
|
6798 * il_param_assignment --+ | |
|
6799 * | |
|
6800 * il_formal_funct_call <- il_param_list <-+ |
|
6801 * |
|
6802 */ |
|
6803 /* |
6615 | NOT eno_identifier SENDTO |
6804 | NOT eno_identifier SENDTO |
6616 {$$ = new il_assign_out_operator_c(new not_paramassign_c(locloc(@1)), $2, locloc(@$));} |
6805 {$$ = new il_assign_out_operator_c(new not_paramassign_c(locloc(@1)), $2, locloc(@$));} |
|
6806 */ |
6617 /* ERROR_CHECK_BEGIN */ |
6807 /* ERROR_CHECK_BEGIN */ |
6618 | error SENDTO |
6808 | error SENDTO |
6619 {$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid parameter defined in parameter out assignment."); yyerrok;} |
6809 {$$ = NULL; print_err_msg(locf(@1), locl(@1), "invalid parameter defined in parameter out assignment."); yyerrok;} |
6620 | NOT SENDTO |
6810 | NOT SENDTO |
6621 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no parameter defined in parameter out assignment."); yynerrs++;} |
6811 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no parameter defined in parameter out assignment."); yynerrs++;} |
6888 * (i.e. the constant 9 negative) |
7078 * (i.e. the constant 9 negative) |
6889 * OR |
7079 * OR |
6890 * expression<-unary_expression<-constant<-integer |
7080 * expression<-unary_expression<-constant<-integer |
6891 * (i.e. the constant 9, preceded by a unary negation) |
7081 * (i.e. the constant 9, preceded by a unary negation) |
6892 * |
7082 * |
6893 * To remove the conlfict, we only allow constants without |
7083 * To remove the conflict, we only allow constants without |
6894 * a preceding '-' to be used in primary_expression |
7084 * a preceding '-' to be used in primary_expression |
|
7085 * (i.e. as a parameter to the unary negation operator) |
6895 */ |
7086 */ |
6896 /* NOTE: We use enumerated_value_without_identifier instead of enumerated_value |
7087 /* NOTE: We use enumerated_value_without_identifier instead of enumerated_value |
6897 * in order to remove a reduce/reduce conflict between reducing an |
7088 * in order to remove a reduce/reduce conflict between reducing an |
6898 * identifier to a variable or an enumerated_value. |
7089 * identifier to a variable or an enumerated_value. |
6899 * |
7090 * |
6915 /* ERROR_CHECK_BEGIN */ |
7105 /* ERROR_CHECK_BEGIN */ |
6916 | '(' expression error |
7106 | '(' expression error |
6917 {$$ = NULL; print_err_msg(locl(@2), locf(@3), "')' missing at the end of expression in ST expression."); yyerrok;} |
7107 {$$ = NULL; print_err_msg(locl(@2), locf(@3), "')' missing at the end of expression in ST expression."); yyerrok;} |
6918 /* ERROR_CHECK_END */ |
7108 /* ERROR_CHECK_END */ |
6919 ; |
7109 ; |
|
7110 |
|
7111 |
|
7112 primary_expression: |
|
7113 constant |
|
7114 //| enumerated_value_without_identifier |
|
7115 enumerated_value |
|
7116 | variable |
|
7117 | '(' expression ')' |
|
7118 {$$ = $2;} |
|
7119 | function_invocation |
|
7120 /* ERROR_CHECK_BEGIN */ |
|
7121 | '(' expression error |
|
7122 {$$ = NULL; print_err_msg(locl(@2), locf(@3), "')' missing at the end of expression in ST expression."); yyerrok;} |
|
7123 /* ERROR_CHECK_END */ |
|
7124 ; |
|
7125 |
6920 |
7126 |
6921 |
7127 |
6922 /* intermediate helper symbol for primary_expression */ |
7128 /* intermediate helper symbol for primary_expression */ |
6923 /* NOTE: function_name includes the standard function name 'NOT' ! |
7129 /* NOTE: function_name includes the standard function name 'NOT' ! |
6924 * This introduces a reduce/reduce conflict, as NOT(var) |
7130 * This introduces a reduce/reduce conflict, as NOT(var) |
6970 /* B 3.2 Statements */ |
7176 /* B 3.2 Statements */ |
6971 /********************/ |
7177 /********************/ |
6972 statement_list: |
7178 statement_list: |
6973 statement ';' |
7179 statement ';' |
6974 {$$ = new statement_list_c(locloc(@$)); $$->add_element($1);} |
7180 {$$ = new statement_list_c(locloc(@$)); $$->add_element($1);} |
6975 | pragma |
7181 | any_pragma |
6976 {$$ = new statement_list_c(locloc(@$)); $$->add_element($1);} |
7182 {$$ = new statement_list_c(locloc(@$)); $$->add_element($1);} |
6977 | statement_list statement ';' |
7183 | statement_list statement ';' |
6978 {$$ = $1; $$->add_element($2);} |
7184 {$$ = $1; $$->add_element($2);} |
6979 | statement_list pragma |
7185 | statement_list any_pragma |
6980 {$$ = $1; $$->add_element($2);} |
7186 {$$ = $1; $$->add_element($2);} |
6981 /* ERROR_CHECK_BEGIN */ |
7187 /* ERROR_CHECK_BEGIN */ |
6982 | statement error |
7188 | statement error |
6983 {$$ = new statement_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at the end of statement in ST statement."); yyerrok;} |
7189 {$$ = new statement_list_c(locloc(@$)); print_err_msg(locl(@1), locf(@2), "';' missing at the end of statement in ST statement."); yyerrok;} |
6984 | statement_list statement error |
7190 | statement_list statement error |
7136 {$$ = new input_variable_param_assignment_c($1, $3, locloc(@$));} |
7342 {$$ = new input_variable_param_assignment_c($1, $3, locloc(@$));} |
7137 /*| variable_name SENDTO variable */ |
7343 /*| variable_name SENDTO variable */ |
7138 /*| any_identifier SENDTO variable */ |
7344 /*| any_identifier SENDTO variable */ |
7139 | sendto_identifier SENDTO variable |
7345 | sendto_identifier SENDTO variable |
7140 {$$ = new output_variable_param_assignment_c(NULL, $1, $3, locloc(@$));} |
7346 {$$ = new output_variable_param_assignment_c(NULL, $1, $3, locloc(@$));} |
|
7347 /* The following is not required, as the sendto_identifier_token returned by flex will |
|
7348 * also include the 'ENO' identifier. |
|
7349 * The resulting abstract syntax tree is identical with or without this following rule, |
|
7350 * as both the eno_identifier and the sendto_identifier are stored as |
|
7351 * an identifier_c !! |
|
7352 */ |
|
7353 /* |
7141 | eno_identifier SENDTO variable |
7354 | eno_identifier SENDTO variable |
7142 {$$ = new output_variable_param_assignment_c(NULL, $1, $3, locloc(@$));} |
7355 {$$ = new output_variable_param_assignment_c(NULL, $1, $3, locloc(@$));} |
|
7356 */ |
7143 /*| NOT variable_name SENDTO variable */ |
7357 /*| NOT variable_name SENDTO variable */ |
7144 /*| NOT any_identifier SENDTO variable*/ |
7358 /*| NOT any_identifier SENDTO variable*/ |
7145 | NOT sendto_identifier SENDTO variable |
7359 | NOT sendto_identifier SENDTO variable |
7146 {$$ = new output_variable_param_assignment_c(new not_paramassign_c(locloc(@$)), $2, $4, locloc(@$));} |
7360 {$$ = new output_variable_param_assignment_c(new not_paramassign_c(locloc(@$)), $2, $4, locloc(@$));} |
|
7361 /* The following is not required, as the sendto_identifier_token returned by flex will |
|
7362 * also include the 'ENO' identifier. |
|
7363 * The resulting abstract syntax tree is identical with or without this following rule, |
|
7364 * as both the eno_identifier and the sendto_identifier are stored as |
|
7365 * an identifier_c !! |
|
7366 */ |
|
7367 /* |
7147 | NOT eno_identifier SENDTO variable |
7368 | NOT eno_identifier SENDTO variable |
7148 {$$ = new output_variable_param_assignment_c(new not_paramassign_c(locloc(@$)), $2, $4, locloc(@$));} |
7369 {$$ = new output_variable_param_assignment_c(new not_paramassign_c(locloc(@$)), $2, $4, locloc(@$));} |
|
7370 */ |
7149 /* ERROR_CHECK_BEGIN */ |
7371 /* ERROR_CHECK_BEGIN */ |
7150 | any_identifier ASSIGN error |
7372 | any_identifier ASSIGN error |
7151 {$$ = NULL; |
7373 {$$ = NULL; |
7152 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined in ST formal parameter assignment.");} |
7374 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined in ST formal parameter assignment.");} |
7153 else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter assignment."); yyclearin;} |
7375 else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter assignment."); yyclearin;} |
7163 {$$ = NULL; |
7385 {$$ = NULL; |
7164 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined in ST formal parameter out assignment.");} |
7386 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined in ST formal parameter out assignment.");} |
7165 else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter out assignment."); yyclearin;} |
7387 else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter out assignment."); yyclearin;} |
7166 yyerrok; |
7388 yyerrok; |
7167 } |
7389 } |
|
7390 /* |
7168 | eno_identifier SENDTO error |
7391 | eno_identifier SENDTO error |
7169 {$$ = NULL; |
7392 {$$ = NULL; |
7170 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined in ST formal parameter out assignment.");} |
7393 if (is_current_syntax_token()) {print_err_msg(locl(@2), locf(@3), "no expression defined in ST formal parameter out assignment.");} |
7171 else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter out assignment."); yyclearin;} |
7394 else {print_err_msg(locf(@3), locl(@3), "invalid expression in ST formal parameter out assignment."); yyclearin;} |
7172 yyerrok; |
7395 yyerrok; |
7173 } |
7396 } |
|
7397 */ |
7174 | NOT SENDTO variable |
7398 | NOT SENDTO variable |
7175 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no parameter name defined in ST formal parameter out negated assignment."); yynerrs++;} |
7399 {$$ = NULL; print_err_msg(locl(@1), locf(@2), "no parameter name defined in ST formal parameter out negated assignment."); yynerrs++;} |
7176 | NOT error SENDTO variable |
7400 | NOT error SENDTO variable |
7177 {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid parameter name defined in ST formal parameter out negated assignment."); yyerrok;} |
7401 {$$ = NULL; print_err_msg(locf(@2), locl(@2), "invalid parameter name defined in ST formal parameter out negated assignment."); yyerrok;} |
7178 | NOT sendto_identifier SENDTO error |
7402 | NOT sendto_identifier SENDTO error |
7179 {$$ = NULL; |
7403 {$$ = NULL; |
7180 if (is_current_syntax_token()) {print_err_msg(locl(@3), locf(@4), "no expression defined in ST formal parameter out negated assignment.");} |
7404 if (is_current_syntax_token()) {print_err_msg(locl(@3), locf(@4), "no expression defined in ST formal parameter out negated assignment.");} |
7181 else {print_err_msg(locf(@4), locl(@4), "invalid expression in ST formal parameter out negated assignment."); yyclearin;} |
7405 else {print_err_msg(locf(@4), locl(@4), "invalid expression in ST formal parameter out negated assignment."); yyclearin;} |
7182 yyerrok; |
7406 yyerrok; |
7183 } |
7407 } |
|
7408 /* |
7184 | NOT eno_identifier SENDTO error |
7409 | NOT eno_identifier SENDTO error |
7185 {$$ = NULL; |
7410 {$$ = NULL; |
7186 if (is_current_syntax_token()) {print_err_msg(locl(@3), locf(@4), "no expression defined in ST formal parameter out negated assignment.");} |
7411 if (is_current_syntax_token()) {print_err_msg(locl(@3), locf(@4), "no expression defined in ST formal parameter out negated assignment.");} |
7187 else {print_err_msg(locf(@4), locl(@4), "invalid expression in ST formal parameter out negated assignment."); yyclearin;} |
7412 else {print_err_msg(locf(@4), locl(@4), "invalid expression in ST formal parameter out negated assignment."); yyclearin;} |
7188 yyerrok; |
7413 yyerrok; |
7189 } |
7414 } |
|
7415 */ |
7190 /* ERROR_CHECK_END */ |
7416 /* ERROR_CHECK_END */ |
7191 ; |
7417 ; |
7192 |
7418 |
7193 |
7419 |
7194 |
7420 |
7800 for(int i = 0; standard_function_block_names[i] != NULL; i++) |
8031 for(int i = 0; standard_function_block_names[i] != NULL; i++) |
7801 if (library_element_symtable.find_value(standard_function_block_names[i]) == |
8032 if (library_element_symtable.find_value(standard_function_block_names[i]) == |
7802 library_element_symtable.end_value()) |
8033 library_element_symtable.end_value()) |
7803 library_element_symtable.insert(standard_function_block_names[i], standard_function_block_name_token); |
8034 library_element_symtable.insert(standard_function_block_names[i], standard_function_block_name_token); |
7804 |
8035 |
7805 #if YYDEBUG |
|
7806 yydebug = 1; |
|
7807 #endif |
|
7808 |
8036 |
7809 /* now parse the input file... */ |
8037 /* now parse the input file... */ |
|
8038 #if YYDEBUG |
|
8039 yydebug = 1; |
|
8040 #endif |
7810 yyin = in_file; |
8041 yyin = in_file; |
7811 allow_function_overloading = false; |
8042 allow_function_overloading = false; |
7812 full_token_loc = full_token_loc_; |
8043 full_token_loc = full_token_loc_; |
7813 current_filename = filename; |
8044 current_filename = filename; |
7814 current_tracking = GetNewTracking(yyin); |
8045 current_tracking = GetNewTracking(yyin); |