Changeset 202
- Timestamp:
- 06/13/06 22:26:37 (2 years ago)
- Files:
-
- trunk/enki/BaseParser.d (modified) (1 diff)
- trunk/enki/Directive.d (modified) (1 diff)
- trunk/enki/EnkiParser.d (modified) (33 diffs)
- trunk/enki/Expression.d (modified) (5 diffs)
- trunk/enki/Rule.d (modified) (15 diffs)
- trunk/enki/bootstrap.d (modified) (6 diffs)
- trunk/enki/enki.bnf (modified) (3 diffs)
- trunk/enki/enki.d (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/enki/BaseParser.d
r196 r202 72 72 /** conversion helpers **/ 73 73 74 protected String hexToChar(String input){ 75 uint value = 0; 76 foreach(char ch; input){ 77 value *= 16; 78 if(ch >= 'a') value += (ch-'a') + 10; 79 else if(ch >= 'A') value += (ch-'A') + 10; 80 else if(ch >= '0') value += (ch-'0'); 81 } 82 String output; 83 output ~= cast(char)value; 84 85 debug writefln("hexToChar: %s to %s",input,output); 86 87 return output; 74 protected String hexToChar(String hexValue){ 75 return "\\x" ~ hexValue; 88 76 } 89 77 trunk/enki/Directive.d
r196 r202 267 267 268 268 public String toBNF(){ 269 return ".code (\"" ~ code ~ "\");\n";269 return ".code{{{" ~ code ~ "}}}\n"; 270 270 } 271 271 trunk/enki/EnkiParser.d
r196 r202 10 10 class EnkiParser : BaseEnkiParser{ 11 11 12 /+ 13 Copyright (c) 2006 Eric Anderton 14 15 Permission is hereby granted, free of charge, to any person 16 obtaining a copy of this software and associated documentation 17 files (the "Software"), to deal in the Software without 18 restriction, including without limitation the rights to use, 19 copy, modify, merge, publish, distribute, sublicense, and/or 20 sell copies of the Software, and to permit persons to whom the 21 Software is furnished to do so, subject to the following 22 conditions: 23 24 The above copyright notice and this permission notice shall be 25 included in all copies or substantial portions of the Software. 26 27 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 28 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 29 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 30 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 31 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 32 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 33 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 34 OTHER DEALINGS IN THE SOFTWARE. 35 +/ 12 36 /* 13 37 … … 665 689 SubExpression 666 690 = SubExpression expr 667 ::= Production:expr | Substitution:expr | Terminal:expr | Regexp:expr | GroupExpr:expr | OptionalExpr:expr | ZeroOrMoreExpr:expr | NegateExpr:expr | TestExpr:expr | Literal :expr ;691 ::= Production:expr | Substitution:expr | Terminal:expr | Regexp:expr | GroupExpr:expr | OptionalExpr:expr | ZeroOrMoreExpr:expr | NegateExpr:expr | TestExpr:expr | LiteralExpr:expr | CustomTerminal:expr ; 668 692 669 693 */ … … 676 700 {//Expression 677 701 uint start = position; 678 if((parse_Production().assign!(SubExpression)(bind_expr)) || (parse_Substitution().assign!(SubExpression)(bind_expr)) || (parse_Terminal().assign!(SubExpression)(bind_expr)) || (parse_Regexp().assign!(SubExpression)(bind_expr)) || (parse_GroupExpr().assign!(SubExpression)(bind_expr)) || (parse_OptionalExpr().assign!(SubExpression)(bind_expr)) || (parse_ZeroOrMoreExpr().assign!(SubExpression)(bind_expr)) || (parse_NegateExpr().assign!(SubExpression)(bind_expr)) || (parse_TestExpr().assign!(SubExpression)(bind_expr)) || (parse_Literal ().assign!(SubExpression)(bind_expr))){702 if((parse_Production().assign!(SubExpression)(bind_expr)) || (parse_Substitution().assign!(SubExpression)(bind_expr)) || (parse_Terminal().assign!(SubExpression)(bind_expr)) || (parse_Regexp().assign!(SubExpression)(bind_expr)) || (parse_GroupExpr().assign!(SubExpression)(bind_expr)) || (parse_OptionalExpr().assign!(SubExpression)(bind_expr)) || (parse_ZeroOrMoreExpr().assign!(SubExpression)(bind_expr)) || (parse_NegateExpr().assign!(SubExpression)(bind_expr)) || (parse_TestExpr().assign!(SubExpression)(bind_expr)) || (parse_LiteralExpr().assign!(SubExpression)(bind_expr)) || (parse_CustomTerminal().assign!(SubExpression)(bind_expr))){ 679 703 clearErrors(); 680 704 goto match53; 681 705 }else{ 682 setError("Expected Production, Substitution, Terminal, Regexp, GroupExpr, OptionalExpr, ZeroOrMoreExpr, NegateExpr, TestExpr or Literal.");706 setError("Expected Production, Substitution, Terminal, Regexp, GroupExpr, OptionalExpr, ZeroOrMoreExpr, NegateExpr, TestExpr, LiteralExpr or CustomTerminal."); 683 707 position = start; 684 708 goto mismatch54; … … 1358 1382 /* 1359 1383 1360 Literal 1361 = new LiteralExpr(String name,Binding binding )1362 ::= "@" Identifier:name ws [ Binding:binding ] ;1363 1364 */ 1365 public ResultT!(LiteralExpr) parse_Literal (){1366 debug writefln("parse_Literal ()");1384 LiteralExpr 1385 = new LiteralExpr(String name,Binding binding,ProductionArg[] args) 1386 ::= "@" Identifier:name ws [ "!(" ws ProductionArg:~args { ws "," ws ProductionArg:~args } ")"] [ Binding:binding ] ; 1387 1388 */ 1389 public ResultT!(LiteralExpr) parse_LiteralExpr(){ 1390 debug writefln("parse_LiteralExpr()"); 1367 1391 uint start = position; 1368 1392 String bind_name; 1369 1393 Binding bind_binding; 1394 ProductionArg[] bind_args; 1370 1395 1371 1396 … … 1384 1409 {//Expression 1385 1410 uint start = position; 1411 if(!(terminal("!(").success)){ 1412 goto mismatch106; 1413 } 1414 if(!(parse_ws().success)){ 1415 goto mismatch106; 1416 } 1417 if(!(parse_ProductionArg().assignCat!(ProductionArg[])(bind_args))){ 1418 goto mismatch106; 1419 } 1420 {//ZeroOrMoreExpr 1421 uint start = position; 1422 uint termPos; 1423 loop107: 1424 termPos = position; 1425 {//Expression 1426 uint start = position; 1427 if((terminal(")").success)){ 1428 clearErrors(); 1429 goto loopend108; 1430 }else{ 1431 position = start; 1432 } 1433 } 1434 {//Expression 1435 uint start = position; 1436 if((parse_ws().success && terminal(",").success && parse_ws().success && parse_ProductionArg().assignCat!(ProductionArg[])(bind_args))){ 1437 clearErrors(); 1438 goto loop107; 1439 }else{ 1440 setError("Expected Whitespace."); 1441 position = start; 1442 goto mismatch106; 1443 } 1444 } 1445 loopend108: 1446 {} 1447 } 1448 goto match105; 1449 mismatch106: 1450 position = start; 1451 match105: 1452 clearErrors(); 1453 } 1454 } 1455 {//OptionalExpr 1456 {//Expression 1457 uint start = position; 1386 1458 if((parse_Binding().assign!(Binding)(bind_binding))){ 1387 1459 clearErrors(); … … 1400 1472 } 1401 1473 match101: 1402 debug writefln("parse_Literal () PASS");1403 ResultT!(LiteralExpr) passed = ResultT!(LiteralExpr)(new LiteralExpr(bind_name,bind_binding ));1474 debug writefln("parse_LiteralExpr() PASS"); 1475 ResultT!(LiteralExpr) passed = ResultT!(LiteralExpr)(new LiteralExpr(bind_name,bind_binding,bind_args)); 1404 1476 return passed; 1405 1477 mismatch102: 1406 1478 position = start; 1407 1479 ResultT!(LiteralExpr) failed = ResultT!(LiteralExpr)(); 1480 return failed; 1481 } 1482 1483 /* 1484 1485 CustomTerminal 1486 = new CustomTerminal(String name,Binding binding) 1487 ::= "&" Identifier:name ws [ Binding:binding ] ; 1488 1489 */ 1490 public ResultT!(CustomTerminal) parse_CustomTerminal(){ 1491 debug writefln("parse_CustomTerminal()"); 1492 uint start = position; 1493 String bind_name; 1494 Binding bind_binding; 1495 1496 1497 {//Expression 1498 uint start = position; 1499 if(!(terminal("&").success)){ 1500 goto mismatch112; 1501 } 1502 if(!(parse_Identifier().assign!(String)(bind_name))){ 1503 goto mismatch112; 1504 } 1505 if(!(parse_ws().success)){ 1506 goto mismatch112; 1507 } 1508 {//OptionalExpr 1509 {//Expression 1510 uint start = position; 1511 if((parse_Binding().assign!(Binding)(bind_binding))){ 1512 clearErrors(); 1513 }else{ 1514 position = start; 1515 } 1516 } 1517 } 1518 goto match111; 1519 mismatch112: 1520 position = start; 1521 goto mismatch110; 1522 match111: 1523 clearErrors(); 1524 goto match109; 1525 } 1526 match109: 1527 debug writefln("parse_CustomTerminal() PASS"); 1528 ResultT!(CustomTerminal) passed = ResultT!(CustomTerminal)(new CustomTerminal(bind_name,bind_binding)); 1529 return passed; 1530 mismatch110: 1531 position = start; 1532 ResultT!(CustomTerminal) failed = ResultT!(CustomTerminal)(); 1408 1533 return failed; 1409 1534 } … … 1426 1551 uint start = position; 1427 1552 if(!(terminal(":").success)){ 1428 goto mismatch1 08;1429 } 1430 if(!(parse_ws().success)){ 1431 goto mismatch1 08;1553 goto mismatch116; 1554 } 1555 if(!(parse_ws().success)){ 1556 goto mismatch116; 1432 1557 } 1433 1558 {//OptionalExpr … … 1444 1569 } 1445 1570 if(!(parse_ws().success)){ 1446 goto mismatch1 08;1571 goto mismatch116; 1447 1572 } 1448 1573 if(!(parse_Identifier().assign!(String)(bind_name))){ 1449 goto mismatch1 08;1450 } 1451 goto match1 07;1452 mismatch1 08:1453 position = start; 1454 goto mismatch1 06;1455 match1 07:1456 clearErrors(); 1457 goto match1 05;1458 } 1459 match1 05:1574 goto mismatch116; 1575 } 1576 goto match115; 1577 mismatch116: 1578 position = start; 1579 goto mismatch114; 1580 match115: 1581 clearErrors(); 1582 goto match113; 1583 } 1584 match113: 1460 1585 debug writefln("parse_Binding() PASS"); 1461 1586 ResultT!(Binding) passed = ResultT!(Binding)(new Binding(bind_isConcat,bind_name)); 1462 1587 return passed; 1463 mismatch1 06:1588 mismatch114: 1464 1589 position = start; 1465 1590 ResultT!(Binding) failed = ResultT!(Binding)(); … … 1487 1612 uint start = position; 1488 1613 if(!(parse_IdentifierStartChar().success)){ 1489 goto mismatch1 14;1614 goto mismatch122; 1490 1615 } 1491 1616 {//ZeroOrMoreExpr 1492 1617 uint termPos; 1493 loop1 15:1618 loop123: 1494 1619 termPos = position; 1495 1620 {//Expression … … 1497 1622 if((parse_IdentifierChar().success)){ 1498 1623 clearErrors(); 1499 goto loop1 15;1624 goto loop123; 1500 1625 }else{ 1501 1626 setError("Expected IdentifierChar."); 1502 1627 position = start; 1503 goto loopend1 16;1628 goto loopend124; 1504 1629 } 1505 1630 } 1506 loopend1 16:1631 loopend124: 1507 1632 {} 1508 1633 } 1509 goto match1 13;1510 mismatch1 14:1634 goto match121; 1635 mismatch122: 1511 1636 setError("Expected IdentifierStartChar."); 1512 1637 position = start; 1513 goto mismatch1 12;1514 match1 13:1638 goto mismatch120; 1639 match121: 1515 1640 clearErrors(); 1516 1641 } 1517 1642 smartAssign!(String,String)(bind_value,sliceData(start,position)); 1518 1643 } 1519 goto match11 1;1520 mismatch1 12:1521 position = start; 1522 goto mismatch11 0;1523 match11 1:1524 clearErrors(); 1525 goto match1 09;1526 } 1527 match1 09:1644 goto match119; 1645 mismatch120: 1646 position = start; 1647 goto mismatch118; 1648 match119: 1649 clearErrors(); 1650 goto match117; 1651 } 1652 match117: 1528 1653 debug writefln("parse_Identifier() PASS"); 1529 1654 return ResultT!(String)(bind_value); 1530 mismatch11 0:1655 mismatch118: 1531 1656 position = start; 1532 1657 return ResultT!(String)(); … … 1557 1682 setError("Expected Letter."); 1558 1683 position = start; 1559 goto mismatch12 0;1684 goto mismatch128; 1560 1685 } 1561 1686 } 1562 1687 smartAssign!(String,String)(bind_text,sliceData(start,position)); 1563 1688 } 1564 goto match1 19;1565 mismatch12 0:1566 position = start; 1567 goto mismatch1 18;1568 match1 19:1569 clearErrors(); 1570 goto match1 17;1571 } 1572 match1 17:1689 goto match127; 1690 mismatch128: 1691 position = start; 1692 goto mismatch126; 1693 match127: 1694 clearErrors(); 1695 goto match125; 1696 } 1697 match125: 1573 1698 debug writefln("parse_IdentifierStartChar() PASS"); 1574 1699 return ResultT!(String)(bind_text); 1575 mismatch1 18:1700 mismatch126: 1576 1701 position = start; 1577 1702 return ResultT!(String)(); … … 1602 1727 setError("Expected Letter or Digit."); 1603 1728 position = start; 1604 goto mismatch1 24;1729 goto mismatch132; 1605 1730 } 1606 1731 } 1607 1732 smartAssign!(String,String)(bind_text,sliceData(start,position)); 1608 1733 } 1609 goto match1 23;1610 mismatch1 24:1611 position = start; 1612 goto mismatch1 22;1613 match1 23:1614 clearErrors(); 1615 goto match12 1;1616 } 1617 match12 1:1734 goto match131; 1735 mismatch132: 1736 position = start; 1737 goto mismatch130; 1738 match131: 1739 clearErrors(); 1740 goto match129; 1741 } 1742 match129: 1618 1743 debug writefln("parse_IdentifierChar() PASS"); 1619 1744 return ResultT!(String)(bind_text); 1620 mismatch1 22:1745 mismatch130: 1621 1746 position = start; 1622 1747 return ResultT!(String)(); … … 1639 1764 uint start = position; 1640 1765 if(!(terminal("\"").success)){ 1641 goto mismatch1 28;1766 goto mismatch136; 1642 1767 } 1643 1768 {//ZeroOrMoreExpr 1644 1769 uint start = position; 1645 1770 uint termPos; 1646 loop1 29:1771 loop137: 1647 1772 termPos = position; 1648 1773 {//Expression … … 1650 1775 if((terminal("\"").success)){ 1651 1776 clearErrors(); 1652 goto loopend13 0;1777 goto loopend138; 1653 1778 }else{ 1654 1779 position = start; … … 1659 1784 if((parse_AnyChar().success)){ 1660 1785 clearErrors(); 1661 goto loop1 29;1786 goto loop137; 1662 1787 }else{ 1663 1788 setError("Expected AnyChar."); 1664 1789 position = start; 1665 goto mismatch1 28;1666 } 1667 } 1668 loopend13 0:1790 goto mismatch136; 1791 } 1792 } 1793 loopend138: 1669 1794 smartAssign!(String,String)(bind_text,sliceData(start,termPos)); 1670 1795 {} 1671 1796 } 1672 goto match1 27;1673 mismatch1 28:1674 position = start; 1675 goto mismatch1 26;1676 match1 27:1677 clearErrors(); 1678 goto match1 25;1679 } 1680 match1 25:1797 goto match135; 1798 mismatch136: 1799 position = start; 1800 goto mismatch134; 1801 match135: 1802 clearErrors(); 1803 goto match133; 1804 } 1805 match133: 1681 1806 debug writefln("parse_String() PASS"); 1682 1807 return ResultT!(String)(bind_text); 1683 mismatch1 26:1808 mismatch134: 1684 1809 position = start; 1685 1810 return ResultT!(String)(); … … 1702 1827 uint start = position; 1703 1828 if(!(terminal("#").success)){ 1704 goto mismatch1 34;1829 goto mismatch142; 1705 1830 } 1706 1831 {//GroupExpr … … 1713 1838 setError("Expected Hexdigit."); 1714 1839 position = start; 1715 goto mismatch1 34;1840 goto mismatch142; 1716 1841 } 1717 1842 } 1718 1843 smartAssign!(String,String)(bind_text,sliceData(start,position)); 1719 1844 } 1720 goto match1 33;1721 mismatch1 34:1722 position = start; 1723 goto mismatch1 32;1724 match1 33:1725 clearErrors(); 1726 goto match13 1;1727 } 1728 match13 1:1845 goto match141; 1846 mismatch142: 1847 position = start; 1848 goto mismatch140; 1849 match141: 1850 clearErrors(); 1851 goto match139; 1852 } 1853 match139: 1729 1854 debug writefln("parse_HexChar() PASS"); 1730 1855 auto value = hexToChar(bind_text); 1731 1856 return ResultT!(String)(value); 1732 mismatch1 32:1857 mismatch140: 1733 1858 position = start; 1734 1859 return ResultT!(String)(); … … 1761 1886 } 1762 1887 if(!(parse_any().assignCat!(String)(bind_value))){ 1763 goto mismatch1 38;1764 } 1765 goto match1 37;1766 mismatch1 38:1767 position = start; 1768 goto mismatch1 36;1769 match1 37:1770 clearErrors(); 1771 goto match1 35;1772 } 1773 match1 35:1888 goto mismatch146; 1889 } 1890 goto match145; 1891 mismatch146: 1892 position = start; 1893 goto mismatch144; 1894 match145: 1895 clearErrors(); 1896 goto match143; 1897 } 1898 match143: 1774 1899 debug writefln("parse_AnyChar() PASS"); 1775 1900 return ResultT!(String)(bind_value); 1776 mismatch1 36:1901 mismatch144: 1777 1902 position = start; 1778 1903 return ResultT!(String)(); … … 1795 1920 uint start = position; 1796 1921 if(!(terminal("#").success)){ 1797 goto mismatch1 42;1922 goto mismatch150; 1798 1923 } 1799 1924 {//ZeroOrMoreExpr 1800 1925 uint start = position; 1801 1926 uint termPos; 1802 loop1 43:1927 loop151: 1803 1928 termPos = position; 1804 1929 {//Expression … … 1806 1931 if((parse_eol().success)){ 1807 1932 clearErrors(); 1808 goto loopend1 44;1933 goto loopend152; 1809 1934 }else{ 1810 1935 position = start; … … 1815 1940 if((parse_any().success)){ 1816 1941 clearErrors(); 1817 goto loop1 43;1942 goto loop151; 1818 1943 }else{ 1819 1944 setError("Expected any."); 1820 1945 position = start; 1821 goto mismatch1 42;1822 } 1823 } 1824 loopend1 44:1946 goto mismatch150; 1947 } 1948 } 1949 loopend152: 1825 1950 smartAssign!(String,String)(bind_text,sliceData(start,termPos)); 1826 1951 {} 1827 1952 } 1828 goto match14 1;1829 mismatch1 42:1830 position = start; 1831 goto mismatch14 0;1832 match14 1:1833 clearErrors(); 1834 goto match1 39;1835 } 1836 match1 39:1953 goto match149; 1954 mismatch150: 1955 position = start; 1956 goto mismatch148; 1957 match149: 1958 clearErrors(); 1959 goto match147; 1960 } 1961 match147: 1837 1962 debug writefln("parse_Comment() PASS"); 1838 1963 ResultT!(Comment) passed = ResultT!(Comment)(new Comment(bind_text)); 1839 1964 return passed; 1840 mismatch14 0:1965 mismatch148: 1841 1966 position = start; 1842 1967 ResultT!(Comment) failed = ResultT!(Comment)(); … … 1860 1985 uint start = position; 1861 1986 if(!(terminal(".").success)){ 1862 goto mismatch1 48;1987 goto mismatch156; 1863 1988 } 1864 1989 {//Expression … … 1869 1994 setError("Expected ImportDirective, BaseClassDirective, ClassnameDirective, DefineDirective, StartDirective, IncludeDirective, AliasDirective, ModuleDirective or CodeDirective."); 1870 1995 position = start; 1871 goto mismatch1 48;1872 } 1873 } 1874 goto match1 47;1875 mismatch1 48:1876 position = start; 1877 goto mismatch1 46;1878 match1 47:1879 clearErrors(); 1880 goto match1 45;1881 } 1882 match1 45:1996 goto mismatch156; 1997 } 1998 } 1999 goto match155; 2000 mismatch156: 2001 position = start; 2002 goto mismatch154; 2003 match155: 2004 clearErrors(); 2005 goto match153; 2006 } 2007 match153: 1883 2008 debug writefln("parse_Directive() PASS"); 1884 2009 return ResultT!(Directive)(bind_dir); 1885 mismatch1 46:2010 mismatch154: 1886 2011 position = start; 1887 2012 return ResultT!(Directive)(); … … 1905 2030 if((terminal("import").success && parse_ws().success && terminal("(").success && parse_ws().success && parse_DirectiveArg().assign!(String)(bind_imp) && parse_ws().success && terminal(")").success && parse_ws().success && terminal(";").success)){ 1906 2031 clearErrors(); 1907 goto match1 49;2032 goto match157; 1908 2033 }else{ 1909 2034 position = start; 1910 goto mismatch15 0;1911 } 1912 } 1913 match1 49:2035 goto mismatch158; 2036 } 2037 } 2038 match157: 1914 2039 debug writefln("parse_ImportDirective() PASS"); 1915 2040 ResultT!(ImportDirective) passed = ResultT!(ImportDirective)(new ImportDirective(bind_imp)); 1916 2041 return passed; 1917 mismatch15 0:2042 mismatch158: 1918 2043 position = start; 1919 2044 ResultT!(ImportDirective) failed = ResultT!(ImportDirective)(); … … 1937 2062 uint start = position; 1938 2063 if((terminal("baseclass").success && parse_ws().success && terminal("(").success && parse_ws().success && parse_DirectiveArg().assign!(String)(bind_name) && parse_ws().success && terminal(")").success && parse_ws().success && terminal(";").success)){ 1939 clearErrors();1940 goto match151;1941 }else{1942 position = start;1943 goto mismatch152;1944 }1945 }1946 match151:1947 debug writefln("parse_BaseClassDirective() PASS");1948 ResultT!(BaseClassDirective) passed = ResultT!(BaseClassDirective)(new BaseClassDirective(bind_name));1949 return passed;1950 mismatch152:1951 position = start;1952 ResultT!(BaseClassDirective) failed = ResultT!(BaseClassDirective)();1953 return failed;1954 }1955 1956 /*1957 1958 ClassnameDirective1959 = new ClassnameDirective(String name)1960 ::= "classname" ws "(" ws DirectiveArg:name ws ")" ws ";";1961 1962 */1963 public ResultT!(ClassnameDirective) parse_ClassnameDirective(){1964 debug writefln("parse_ClassnameDirective()");1965 uint start = position;1966 String bind_name;1967 1968 1969 {//Expression1970 uint start = position;1971 if((terminal("classname").success && parse_ws().success && terminal("(").success && parse_ws().success && parse_DirectiveArg().assign!(String)(bind_name) && parse_ws().success && terminal(")").success && parse_ws().success && terminal(";").success)){1972 clearErrors();1973 goto match153;1974 }else{1975 position = start;1976 goto mismatch154;1977 }1978 }1979 match153:1980 debug writefln("parse_ClassnameDirective() PASS");1981 ResultT!(ClassnameDirective) passed = ResultT!(ClassnameDirective)(new ClassnameDirective(bind_name));1982 return passed;1983 mismatch154:1984 position = start;1985 ResultT!(ClassnameDirective) failed = ResultT!(ClassnameDirective)();1986 return failed;1987 }1988 1989 /*1990 1991 DefineDirective1992 = new DefineDirective(String returnType,String name,bool isTerminal,String description)1993 ::= "define" ws "(" ws DirectiveArg:returnType ws "," ws DirectiveArg:name ws "," ws DirectiveArg:isTerminal ws [ "," ws DirectiveArg:description ws] ")" ws ";";1994 1995 */1996 public ResultT!(DefineDirective) parse_DefineDirective(){1997 debug writefln("parse_DefineDirective()");1998 uint start = position;1999 String bind_returnType;2000 String bind_name;2001 bool bind_isTerminal;2002 String bind_description;2003 2004 2005 {//Expression2006 uint start = position;2007 if(!(terminal("define").success)){2008 goto mismatch158;2009 }2010 if(!(parse_ws().success)){2011 goto mismatch158;2012 }2013 if(!(terminal("(").success)){2014 goto mismatch158;2015 }2016 if(!(parse_ws().success)){2017 goto mismatch158;2018 }2019 if(!(parse_DirectiveArg().assign!(String)(bind_returnType))){2020 goto mismatch158;2021 }2022 if(!(parse_ws().success)){2023 goto mismatch158;2024 }2025 if(!(terminal(",").success)){2026 goto mismatch158;2027 }2028 if(!(parse_ws().success)){2029 goto mismatch158;2030 }2031 if(!(parse_DirectiveArg().assign!(String)(bind_name))){2032 goto mismatch158;2033 }2034 if(!(parse_ws().success)){2035 goto mismatch158;2036 }2037 if(!(terminal(",").success)){2038 goto mismatch158;2039 }2040 if(!(parse_ws().success)){2041 goto mismatch158;2042 }2043 if(!(parse_DirectiveArg().assign!(bool)(bind_isTerminal))){2044 goto mismatch158;2045 }2046 if(!(parse_ws().success)){2047 goto mismatch158;2048 }2049 {//OptionalExpr2050 {//Expression2051 uint start = position;2052 if((terminal(",").success && parse_ws().success && parse_DirectiveArg().assign!(String)(bind_description) && parse_ws().success)){2053 clearErrors();2054 }else{2055 position = start;2056 }2057 }2058 }2059 if(!(terminal(")").success)){2060 goto mismatch158;2061 }2062 if(!(parse_ws().success)){2063 goto mismatch158;2064 }2065 if(!(terminal(";").success)){2066 goto mismatch158;2067 }2068 goto match157;2069 mismatch158:2070 position = start;2071 goto mismatch156;2072 match157:2073 clearErrors();2074 goto match155;2075 }2076 match155:2077 debug writefln("parse_DefineDirective() PASS");2078 ResultT!(DefineDirective) passed = ResultT!(DefineDirective)(new DefineDirective(bind_returnType,bind_name,bind_isTerminal,bind_description));2079 return passed;2080 mismatch156:2081 position = start;2082 ResultT!(DefineDirective) failed = ResultT!(DefineDirective)();2083 return failed;2084 }2085 2086 /*2087 2088 StartDirective2089 = new StartDirective(String production)2090 ::= "start" ws "(" ws DirectiveArg:production ws ")" ws ";";2091 2092 */2093 public ResultT!(StartDirective) parse_StartDirective(){2094 debug writefln("parse_StartDirective()");2095 uint start = position;2096 String bind_production;2097 2098 2099 {//Expression2100 uint start = position;2101 if((terminal("start").success && parse_ws().success && terminal("(").success && parse_ws().success && parse_DirectiveArg().assign!(String)(bind_production) && parse_ws().success && terminal(")").success && parse_ws().success && terminal(";").success)){2102 2064 clearErrors(); 2103 2065 goto match159; … … 2108 2070 } 2109 2071 match159: 2110 debug writefln("parse_ StartDirective() PASS");2111 ResultT!( StartDirective) passed = ResultT!(StartDirective)(new StartDirective(bind_production));2072 debug writefln("parse_BaseClassDirective() PASS"); 2073 ResultT!(BaseClassDirective) passed = ResultT!(BaseClassDirective)(new BaseClassDirective(bind_name)); 2112 2074 return passed; 2113 2075 mismatch160: 2114 2076 position = start; 2115 ResultT!( StartDirective) failed = ResultT!(StartDirective)();2116 return failed; 2117 } 2118 2119 /* 2120 2121 IncludeDirective2122 = new IncludeDirective(String filename)2123 ::= " include" ws "(" ws String:filename ws ")" ws ";";2124 2125 */ 2126 public ResultT!( IncludeDirective) parse_IncludeDirective(){2127 debug writefln("parse_ IncludeDirective()");2128 uint start = position; 2129 String bind_ filename;2130
