Changeset 289
- Timestamp:
- 03/01/08 19:32:14 (4 years ago)
- Files:
-
- trunk/enki/BaseParser.d (modified) (3 diffs)
- trunk/enki/CodeGenerator.d (modified) (3 diffs)
- trunk/enki/Directive.d (modified) (3 diffs)
- trunk/enki/EnkiBackend.d (modified) (2 diffs)
- trunk/enki/EnkiParser.d (modified) (115 diffs)
- trunk/enki/Expression.d (modified) (1 diff)
- trunk/enki/Rule.d (modified) (3 diffs)
- trunk/enki/bootstrap.d (modified) (2 diffs)
- trunk/enki/enki_bn.d (modified) (1 diff)
- trunk/enki/types.d (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/enki/BaseParser.d
r245 r289 33 33 private import enki.IParser; 34 34 35 private import std.string; 36 private import std.stdio; 37 private import std.regexp; 38 private import std.utf; 35 import tango.text.Util; 36 import tango.text.Unicode; 37 import tango.io.Stdout; 38 import tango.text.Regex; 39 import tango.text.convert.Format; 39 40 40 41 alias ResultT!(bool) ResultBool; … … 108 109 } 109 110 } 110 result ~= transcodeToString( std.string.format("(%d,%d) %s\n",line,err.pos-startOfLine+1,err.text));111 result ~= transcodeToString(Format("({},{}) {}\n",line,err.pos-startOfLine+1,err.text)); 111 112 } 112 113 return result; … … 292 293 293 294 public ResultBool parse_err(){ 294 throw new Exception( toUTF8(getErrorReport()));295 throw new Exception(.toString(getErrorReport())); 295 296 return ResultBool(false); 296 297 } trunk/enki/CodeGenerator.d
r231 r289 27 27 private import enki.types; 28 28 29 private import std.string;29 private import tango.io.Stdout; 30 30 31 31 interface IRenderable{ … … 67 67 public this(String name){ 68 68 counter++; 69 this.name = name ~ std.string.toString(counter);69 this.name = name ~ .toString(counter); 70 70 } 71 71 … … 170 170 public String getUniqueLabel(String label){ 171 171 counter++; 172 return label ~ std.string.toString(counter);172 return label ~ .toString(counter); 173 173 } 174 174 trunk/enki/Directive.d
r239 r289 29 29 private import enki.CodeGenerator; 30 30 31 debug private import std.stdio;31 debug private import tango.io.Stdout; 32 32 33 33 /* … … 197 197 else{ 198 198 private import enki.EnkiParser; 199 private import std.file; 199 private import tango.io.FilePath; 200 private import tango.io.File; 200 201 } 201 202 … … 217 218 } 218 219 else{ 219 if(! std.file.isfile(filename)){220 if(!FilePath(filename).exists){ 220 221 throw new Exception("Cannot include '" ~ filename ~ "'; file doesn't exist."); 221 222 } 222 223 223 224 auto parser = new EnkiParser(); 224 parser.initalize(cast(char[]) std.file.read(filename));225 parser.initalize(cast(char[])File(filename).read()); 225 226 auto result = parser.parse_Syntax(); 226 227 trunk/enki/EnkiBackend.d
r277 r289 32 32 private import enki.Rule; 33 33 34 debug private import std.stdio;34 debug private import tango.io.Stdout; 35 35 36 36 interface SyntaxLine{ … … 253 253 emit("version(build) pragma(export_version,EnkiUTF" ~ utf ~ ");"); 254 254 emit(""); 255 emit("debug private import std.stdio;");255 emit("debug private import tango.io.Stdout;"); 256 256 257 257 if(typelib != ""){ trunk/enki/EnkiParser.d
r277 r289 29 29 version(build) pragma(export_version,EnkiUTF8); 30 30 31 debug private import std.stdio;31 debug private import tango.io.Stdout; 32 32 private import enki.types; 33 33 private import enki.EnkiBackend; … … 47 47 */ 48 48 public ResultT!(bool) parse_WS(){ 49 debug writefln("parse_WS()");49 debug Stdout.formatln("parse_WS()"); 50 50 uint start1 = position; 51 51 //no declarations … … 93 93 } 94 94 match1: 95 debug writefln("parse_WS() PASS");95 debug Stdout.formatln("parse_WS() PASS"); 96 96 return ResultT!(bool)(true); 97 97 mismatch2: … … 108 108 */ 109 109 public ResultT!(String) parse_Syntax(){ 110 debug writefln("parse_Syntax()");110 debug Stdout.formatln("parse_Syntax()"); 111 111 uint start6 = position; 112 112 SyntaxLine[] bind_lines; … … 166 166 } 167 167 match7: 168 debug writefln("parse_Syntax() PASS");168 debug Stdout.formatln("parse_Syntax() PASS"); 169 169 createSyntax(bind_lines); 170 170 return ResultT!(String)(sliceData(start6,position)); … … 182 182 */ 183 183 public ResultT!(Rule) parse_Rule(){ 184 debug writefln("parse_Rule()");184 debug Stdout.formatln("parse_Rule()"); 185 185 uint start12 = position; 186 186 String bind_name; … … 246 246 } 247 247 match16: 248 debug writefln("parse_Rule() PASS");248 debug Stdout.formatln("parse_Rule() PASS"); 249 249 ResultT!(Rule) passed = ResultT!(Rule)(new Rule(bind_name,bind_pred,bind_expr,bind_decl)); 250 250 return passed; … … 263 263 */ 264 264 public ResultT!(RuleDecl) parse_RuleDecl(){ 265 debug writefln("parse_RuleDecl()");265 debug Stdout.formatln("parse_RuleDecl()"); 266 266 uint start18 = position; 267 267 Param[] bind_params; … … 280 280 } 281 281 match20: 282 debug writefln("parse_RuleDecl() PASS");282 debug Stdout.formatln("parse_RuleDecl() PASS"); 283 283 ResultT!(RuleDecl) passed = ResultT!(RuleDecl)(new RuleDecl(bind_params)); 284 284 return passed; … … 297 297 */ 298 298 public ResultT!(RulePredicate) parse_RulePredicate(){ 299 debug writefln("parse_RulePredicate()");299 debug Stdout.formatln("parse_RulePredicate()"); 300 300 uint start20 = position; 301 301 RulePredicate bind_pred; … … 330 330 } 331 331 match22: 332 debug writefln("parse_RulePredicate() PASS");332 debug Stdout.formatln("parse_RulePredicate() PASS"); 333 333 return ResultT!(RulePredicate)(bind_pred); 334 334 mismatch23: … … 345 345 */ 346 346 public ResultT!(ClassPredicate) parse_ClassPredicate(){ 347 debug writefln("parse_ClassPredicate()");347 debug Stdout.formatln("parse_ClassPredicate()"); 348 348 uint start23 = position; 349 349 String bind_name; … … 362 362 } 363 363 match26: 364 debug writefln("parse_ClassPredicate() PASS");364 debug Stdout.formatln("parse_ClassPredicate() PASS"); 365 365 ResultT!(ClassPredicate) passed = ResultT!(ClassPredicate)(new ClassPredicate(bind_name,bind_params)); 366 366 return passed; … … 379 379 */ 380 380 public ResultT!(FunctionPredicate) parse_FunctionPredicate(){ 381 debug writefln("parse_FunctionPredicate()");381 debug Stdout.formatln("parse_FunctionPredicate()"); 382 382 uint start25 = position; 383 383 Param bind_decl; … … 397 397 } 398 398 match28: 399 debug writefln("parse_FunctionPredicate() PASS");399 debug Stdout.formatln("parse_FunctionPredicate() PASS"); 400 400 ResultT!(FunctionPredicate) passed = ResultT!(FunctionPredicate)(new FunctionPredicate(bind_decl,bind_params)); 401 401 return passed; … … 414 414 */ 415 415 public ResultT!(BindingPredicate) parse_BindingPredicate(){ 416 debug writefln("parse_BindingPredicate()");416 debug Stdout.formatln("parse_BindingPredicate()"); 417 417 uint start27 = position; 418 418 Param bind_param; … … 431 431 } 432 432 match30: 433 debug writefln("parse_BindingPredicate() PASS");433 debug Stdout.formatln("parse_BindingPredicate() PASS"); 434 434 ResultT!(BindingPredicate) passed = ResultT!(BindingPredicate)(new BindingPredicate(bind_param)); 435 435 return passed; … … 448 448 */ 449 449 public ResultT!(Param[]) parse_ParamsExpr(){ 450 debug writefln("parse_ParamsExpr()");450 debug Stdout.formatln("parse_ParamsExpr()"); 451 451 uint start29 = position; 452 452 Param[] bind_params; … … 511 511 } 512 512 match32: 513 debug writefln("parse_ParamsExpr() PASS");513 debug Stdout.formatln("parse_ParamsExpr() PASS"); 514 514 return ResultT!(Param[])(bind_params); 515 515 mismatch33: … … 526 526 */ 527 527 public ResultT!(Param) parse_Param(){ 528 debug writefln("parse_Param()");528 debug Stdout.formatln("parse_Param()"); 529 529 uint start36 = position; 530 530 Param bind_param; … … 543 543 } 544 544 match41: 545 debug writefln("parse_Param() PASS");545 debug Stdout.formatln("parse_Param() PASS"); 546 546 return ResultT!(Param)(bind_param); 547 547 mismatch42: … … 558 558 */ 559 559 public ResultT!(Param) parse_WeakParam(){ 560 debug writefln("parse_WeakParam()");560 debug Stdout.formatln("parse_WeakParam()"); 561 561 uint start38 = position; 562 562 String bind_name; … … 575 575 } 576 576 match43: 577 debug writefln("parse_WeakParam() PASS");577 debug Stdout.formatln("parse_WeakParam() PASS"); 578 578 ResultT!(Param) passed = ResultT!(Param)(new Param(bind_name)); 579 579 return passed; … … 592 592 */ 593 593 public ResultT!(Param) parse_ExplicitParam(){ 594 debug writefln("parse_ExplicitParam()");594 debug Stdout.formatln("parse_ExplicitParam()"); 595 595 uint start40 = position; 596 596 bool bind_isArray; … … 630 630 } 631 631 match45: 632 debug writefln("parse_ExplicitParam() PASS");632 debug Stdout.formatln("parse_ExplicitParam() PASS"); 633 633 ResultT!(Param) passed = ResultT!(Param)(new Param(bind_isArray,bind_type,bind_name)); 634 634 return passed; … … 646 646 */ 647 647 public ResultT!(bool) parse_Brackets(){ 648 debug writefln("parse_Brackets()");648 debug Stdout.formatln("parse_Brackets()"); 649 649 uint start44 = position; 650 650 //no declarations … … 673 673 } 674 674 match49: 675 debug writefln("parse_Brackets() PASS");675 debug Stdout.formatln("parse_Brackets() PASS"); 676 676 return ResultT!(bool)(true); 677 677 mismatch50: … … 688 688 */ 689 689 public ResultT!(Expression) parse_Expression(){ 690 debug writefln("parse_Expression()");690 debug Stdout.formatln("parse_Expression()"); 691 691 uint start48 = position; 692 692 Term[] bind_terms; … … 729 729 } 730 730 match53: 731 debug writefln("parse_Expression() PASS");731 debug Stdout.formatln("parse_Expression() PASS"); 732 732 ResultT!(Expression) passed = ResultT!(Expression)(new Expression(bind_terms)); 733 733 return passed; … … 746 746 */ 747 747 public ResultT!(SubExpression[]) parse_Term(){ 748 debug writefln("parse_Term()");748 debug Stdout.formatln("parse_Term()"); 749 749 uint start53 = position; 750 750 SubExpression[] bind_factors; … … 788 788 } 789 789 match60: 790 debug writefln("parse_Term() PASS");790 debug Stdout.formatln("parse_Term() PASS"); 791 791 return ResultT!(SubExpression[])(bind_factors); 792 792 mismatch61: … … 803 803 */ 804 804 public ResultT!(SubExpression) parse_SubExpression(){ 805 debug writefln("parse_SubExpression()");805 debug Stdout.formatln("parse_SubExpression()"); 806 806 uint start58 = position; 807 807 SubExpression bind_expr; … … 820 820 } 821 821 match67: 822 debug writefln("parse_SubExpression() PASS");822 debug Stdout.formatln("parse_SubExpression() PASS"); 823 823 return ResultT!(SubExpression)(bind_expr); 824 824 mismatch68: … … 835 835 */ 836 836 public ResultT!(Production) parse_Production(){ 837 debug writefln("parse_Production()");837 debug Stdout.formatln("parse_Production()"); 838 838 uint start60 = position; 839 839 String bind_name; … … 917 917 } 918 918 match69: 919 debug writefln("parse_Production() PASS");919 debug Stdout.formatln("parse_Production() PASS"); 920 920 ResultT!(Production) passed = ResultT!(Production)(new Production(bind_name,bind_binding,bind_args)); 921 921 return passed; … … 934 934 */ 935 935 public ResultT!(ProductionArg) parse_ProductionArg(){ 936 debug writefln("parse_ProductionArg()");936 debug Stdout.formatln("parse_ProductionArg()"); 937 937 uint start69 = position; 938 938 ProductionArg bind_arg; … … 951 951 } 952 952 match78: 953 debug writefln("parse_ProductionArg() PASS");953 debug Stdout.formatln("parse_ProductionArg() PASS"); 954 954 return ResultT!(ProductionArg)(bind_arg); 955 955 mismatch79: … … 966 966 */ 967 967 public ResultT!(StringProductionArg) parse_StringProductionArg(){ 968 debug writefln("parse_StringProductionArg()");968 debug Stdout.formatln("parse_StringProductionArg()"); 969 969 uint start71 = position; 970 970 String bind_value; … … 983 983 } 984 984 match80: 985 debug writefln("parse_StringProductionArg() PASS");985 debug Stdout.formatln("parse_StringProductionArg() PASS"); 986 986 ResultT!(StringProductionArg) passed = ResultT!(StringProductionArg)(new StringProductionArg(bind_value)); 987 987 return passed; … … 1000 1000 */ 1001 1001 public ResultT!(BindingProductionArg) parse_BindingProductionArg(){ 1002 debug writefln("parse_BindingProductionArg()");1002 debug Stdout.formatln("parse_BindingProductionArg()"); 1003 1003 uint start73 = position; 1004 1004 String bind_value; … … 1017 1017 } 1018 1018 match82: 1019 debug writefln("parse_BindingProductionArg() PASS");1019 debug Stdout.formatln("parse_BindingProductionArg() PASS"); 1020 1020 ResultT!(BindingProductionArg) passed = ResultT!(BindingProductionArg)(new BindingProductionArg(bind_value)); 1021 1021 return passed; … … 1034 1034 */ 1035 1035 public ResultT!(Substitution) parse_Substitution(){ 1036 debug writefln("parse_Substitution()");1036 debug Stdout.formatln("parse_Substitution()"); 1037 1037 uint start75 = position; 1038 1038 String bind_name; … … 1071 1071 } 1072 1072 match84: 1073 debug writefln("parse_Substitution() PASS");1073 debug Stdout.formatln("parse_Substitution() PASS"); 1074 1074 ResultT!(Substitution) passed = ResultT!(Substitution)(new Substitution(bind_name,bind_binding)); 1075 1075 return passed; … … 1088 1088 */ 1089 1089 public ResultT!(GroupExpr) parse_GroupExpr(){ 1090 debug writefln("parse_GroupExpr()");1090 debug Stdout.formatln("parse_GroupExpr()"); 1091 1091 uint start79 = position; 1092 1092 Expression bind_expr; … … 1134 1134 } 1135 1135 match88: 1136 debug writefln("parse_GroupExpr() PASS");1136 debug Stdout.formatln("parse_GroupExpr() PASS"); 1137 1137 ResultT!(GroupExpr) passed = ResultT!(GroupExpr)(new GroupExpr(bind_expr,bind_binding)); 1138 1138 return passed; … … 1151 1151 */ 1152 1152 public ResultT!(OptionalExpr) parse_OptionalExpr(){ 1153 debug writefln("parse_OptionalExpr()");1153 debug Stdout.formatln("parse_OptionalExpr()"); 1154 1154 uint start83 = position; 1155 1155 Expression bind_expr; … … 1197 1197 } 1198 1198 match92: 1199 debug writefln("parse_OptionalExpr() PASS");1199 debug Stdout.formatln("parse_OptionalExpr() PASS"); 1200 1200 ResultT!(OptionalExpr) passed = ResultT!(OptionalExpr)(new OptionalExpr(bind_expr,bind_binding)); 1201 1201 return passed; … … 1214 1214 */ 1215 1215 public ResultT!(ZeroOrMoreExpr) parse_ZeroOrMoreExpr(){ 1216 debug writefln("parse_ZeroOrMoreExpr()");1216 debug Stdout.formatln("parse_ZeroOrMoreExpr()"); 1217 1217 uint start87 = position; 1218 1218 Expression bind_expr; … … 1271 1271 } 1272 1272 match96: 1273 debug writefln("parse_ZeroOrMoreExpr() PASS");1273 debug Stdout.formatln("parse_ZeroOrMoreExpr() PASS"); 1274 1274 ResultT!(ZeroOrMoreExpr) passed = ResultT!(ZeroOrMoreExpr)(new ZeroOrMoreExpr(bind_expr,bind_binding,bind_term)); 1275 1275 return passed; … … 1288 1288 */ 1289 1289 public ResultT!(Terminal) parse_Terminal(){ 1290 debug writefln("parse_Terminal()");1290 debug Stdout.formatln("parse_Terminal()"); 1291 1291 uint start93 = position; 1292 1292 String bind_text; … … 1322 1322 } 1323 1323 match100: 1324 debug writefln("parse_Terminal() PASS");1324 debug Stdout.formatln("parse_Terminal() PASS"); 1325 1325 ResultT!(Terminal) passed = ResultT!(Terminal)(new Terminal(bind_text,bind_binding)); 1326 1326 return passed; … … 1339 1339 */ 1340 1340 public ResultT!(Range) parse_Range(){ 1341 debug writefln("parse_Range()");1341 debug Stdout.formatln("parse_Range()"); 1342 1342 uint start97 = position; 1343 1343 String bind_start; … … 1384 1384 } 1385 1385 match104: 1386 debug writefln("parse_Range() PASS");1386 debug Stdout.formatln("parse_Range() PASS"); 1387 1387 ResultT!(Range) passed = ResultT!(Range)(new Range(bind_start,bind_end,bind_binding)); 1388 1388 return passed; … … 1401 1401 */ 1402 1402 public ResultT!(Regexp) parse_Regexp(){ 1403 debug writefln("parse_Regexp()");1403 debug Stdout.formatln("parse_Regexp()"); 1404 1404 uint start103 = position; 1405 1405 String bind_text; … … 1475 1475 } 1476 1476 match108: 1477 debug writefln("parse_Regexp() PASS");1477 debug Stdout.formatln("parse_Regexp() PASS"); 1478 1478 ResultT!(Regexp) passed = ResultT!(Regexp)(new Regexp(bind_text,bind_binding)); 1479 1479 return passed; … … 1492 1492 */ 1493 1493 public ResultT!(Negate) parse_NegateExpr(){ 1494 debug writefln("parse_NegateExpr()");1494 debug Stdout.formatln("parse_NegateExpr()"); 1495 1495 uint start111 = position; 1496 1496 SubExpression bind_expr; … … 1508 1508 } 1509 1509 match117: 1510 debug writefln("parse_NegateExpr() PASS");1510 debug Stdout.formatln("parse_NegateExpr() PASS"); 1511 1511 ResultT!(Negate) passed = ResultT!(Negate)(new Negate(bind_expr)); 1512 1512 return passed; … … 1525 1525 */ 1526 1526 public ResultT!(Test) parse_TestExpr(){ 1527 debug writefln("parse_TestExpr()");1527 debug Stdout.formatln("parse_TestExpr()"); 1528 1528 uint start113 = position; 1529 1529 SubExpression bind_expr; … … 1541 1541 } 1542 1542 match119: 1543 debug writefln("parse_TestExpr() PASS");1543 debug Stdout.formatln("parse_TestExpr() PASS"); 1544 1544 ResultT!(Test) passed = ResultT!(Test)(new Test(bind_expr)); 1545 1545 return passed; … … 1558 1558 */ 1559 1559 public ResultT!(LiteralExpr) parse_LiteralExpr(){ 1560 debug writefln("parse_LiteralExpr()");1560 debug Stdout.formatln("parse_LiteralExpr()"); 1561 1561 uint start115 = position; 1562 1562 String bind_name; … … 1643 1643 } 1644 1644 match121: 1645 debug writefln("parse_LiteralExpr() PASS");1645 debug Stdout.formatln("parse_LiteralExpr() PASS"); 1646 1646 ResultT!(LiteralExpr) passed = ResultT!(LiteralExpr)(new LiteralExpr(bind_name,bind_binding,bind_args)); 1647 1647 return passed; … … 1660 1660 */ 1661 1661 public ResultT!(CustomTerminal) parse_CustomTerminal(){ 1662 debug writefln("parse_CustomTerminal()");1662 debug Stdout.formatln("parse_CustomTerminal()"); 1663 1663 uint start124 = position; 1664 1664 String bind_name; … … 1697 1697 } 1698 1698 match130: 1699 debug writefln("parse_CustomTerminal() PASS");1699 debug Stdout.formatln("parse_CustomTerminal() PASS"); 1700 1700 ResultT!(CustomTerminal) passed = ResultT!(CustomTerminal)(new CustomTerminal(bind_name,bind_binding)); 1701 1701 return passed; … … 1714 1714 */ 1715 1715 public ResultT!(Binding) parse_Binding(){ 1716 debug writefln("parse_Binding()");1716 debug Stdout.formatln("parse_Binding()"); 1717 1717 uint start128 = position; 1718 1718 bool bind_isConcat; … … 1756 1756 } 1757 1757 match134: 1758 debug writefln("parse_Binding() PASS");1758 debug Stdout.formatln("parse_Binding() PASS"); 1759 1759 ResultT!(Binding) passed = ResultT!(Binding)(new Binding(bind_isConcat,bind_name)); 1760 1760 return passed; … … 1773 1773 */ 1774 1774 public ResultT!(String) parse_Identifier(){ 1775 debug writefln("parse_Identifier()");1775 debug Stdout.formatln("parse_Identifier()"); 1776 1776 uint start132 = position; 1777 1777 String bind_value; … … 1827 1827 } 1828 1828 match138: 1829 debug writefln("parse_Identifier() PASS");1829 debug Stdout.formatln("parse_Identifier() PASS"); 1830 1830 return ResultT!(String)(bind_value); 1831 1831 mismatch139: … … 1842 1842 */ 1843 1843 public ResultT!(String) parse_IdentifierStartChar(){ 1844 debug writefln("parse_IdentifierStartChar()");1844 debug Stdout.formatln("parse_IdentifierStartChar()"); 1845 1845 uint start139 = position; 1846 1846 String bind_text; … … 1873 1873 } 1874 1874 match147: 1875 debug writefln("parse_IdentifierStartChar() PASS");1875 debug Stdout.formatln("parse_IdentifierStartChar() PASS"); 1876 1876 return ResultT!(String)(bind_text); 1877 1877 mismatch148: … … 1888 1888 */ 1889 1889 public ResultT!(String) parse_IdentifierChar(){ 1890 debug writefln("parse_IdentifierChar()");1890 debug Stdout.formatln("parse_IdentifierChar()"); 1891 1891 uint start143 = position; 1892 1892 String bind_text; … … 1919 1919 } 1920 1920 match151: 1921 debug writefln("parse_IdentifierChar() PASS");1921 debug Stdout.formatln("parse_IdentifierChar() PASS"); 1922 1922 return ResultT!(String)(bind_text); 1923 1923 mismatch152: … … 1934 1934 */ 1935 1935 public ResultT!(String) parse_String(){ 1936 debug writefln("parse_String()");1936 debug Stdout.formatln("parse_String()"); 1937 1937 uint start147 = position; 1938 1938 String bind_text; … … 1991 1991 } 1992 1992 match155: 1993 debug writefln("parse_String() PASS");1993 debug Stdout.formatln("parse_String() PASS"); 1994 1994 return ResultT!(String)(bind_text); 1995 1995 mismatch156: … … 2006 2006 */ 2007 2007 public ResultT!(String) parse_HexExpr(){ 2008 debug writefln("parse_HexExpr()");2008 debug Stdout.formatln("parse_HexExpr()"); 2009 2009 uint start154 = position; 2010 2010 String bind_text; … … 2101 2101 } 2102 2102 match162: 2103 debug writefln("parse_HexExpr() PASS");2103 debug Stdout.formatln("parse_HexExpr() PASS"); 2104 2104 return ResultT!(String)(bind_text); 2105 2105 mismatch163: … … 2116 2116 */ 2117 2117 public ResultT!(String) parse_AnyChar(){ 2118 debug writefln("parse_AnyChar()");2118 debug Stdout.formatln("parse_AnyChar()"); 2119 2119 uint start164 = position; 2120 2120 String bind_value; … … 2146 2146 } 2147 2147 match172: 2148 debug writefln("parse_AnyChar() PASS");2148 debug Stdout.formatln("parse_AnyChar() PASS"); 2149 2149 return ResultT!(String)(bind_value); 2150 2150 mismatch173: … … 2161 2161 */ 2162 2162 public ResultT!(Comment) parse_Comment(){ 2163 debug writefln("parse_Comment()");2163 debug Stdout.formatln("parse_Comment()"); 2164 2164 uint start168 = position; 2165 2165 String bind_text; … … 2178 2178 } 2179 2179 match176: 2180 debug writefln("parse_Comment() PASS");2180 debug Stdout.formatln("parse_Comment() PASS"); 2181 2181 ResultT!(Comment) passed = ResultT!(Comment)(new Comment(bind_text)); 2182 2182 return passed; … … 2195 2195 */ 2196 2196 public ResultT!(String) parse_PoundComment(){ 2197 debug writefln("parse_PoundComment()");2197 debug Stdout.formatln("parse_PoundComment()"); 2198 2198 uint start170 = position; 2199 2199 String bind_text; … … 2241 2241 } 2242 2242 match178: 2243 debug writefln("parse_PoundComment() PASS");2243 debug Stdout.formatln("parse_PoundComment() PASS"); 2244 2244 return ResultT!(String)(bind_text); 2245 2245 mismatch179: … … 2256 2256 */ 2257 2257 public ResultT!(String) parse_SlashSlashComment(){ 2258 debug writefln("parse_SlashSlashComment()");2258 debug Stdout.formatln("parse_SlashSlashComment()"); 2259 2259 uint start175 = position; 2260 2260 String bind_text; … … 2302 2302 } 2303 2303 match185: 2304 debug writefln("parse_SlashSlashComment() PASS");2304 debug Stdout.formatln("parse_SlashSlashComment() PASS"); 2305 2305 return ResultT!(String)(bind_text); 2306 2306 mismatch186: … … 2317 2317 */ 2318 2318 public ResultT!(String) parse_SlashStarComment(){ 2319 debug writefln("parse_SlashStarComment()");2319 debug Stdout.formatln("parse_SlashStarComment()"); 2320 2320 uint start180 = position; 2321 2321 String bind_text; … … 2363 2363 } 2364 2364 match192: 2365 debug writefln("parse_SlashStarComment() PASS");2365 debug Stdout.formatln("parse_SlashStarComment() PASS"); 2366 2366 return ResultT!(String)(bind_text); 2367 2367 mismatch193: … … 2378 2378 */ 2379 2379 public ResultT!(Directive) parse_Directive(){ 2380 debug writefln("parse_Directive()");2380 debug Stdout.formatln("parse_Directive()"); 2381 2381 uint start185 = position; 2382 2382 Directive bind_dir; … … 2408 2408 } 2409 2409 match199: 2410 debug writefln("parse_Directive() PASS");2410 debug Stdout.formatln("parse_Directive() PASS"); 2411 2411 return ResultT!(Directive)(bind_dir); 2412 2412 mismatch200: … … 2423 2423 */ 2424 2424 public ResultT!(ImportDirective) parse_ImportDirective(){ 2425 debug writefln("parse_ImportDirective()");2425 debug Stdout.formatln("parse_ImportDirective()"); 2426 2426 uint start188 = position; 2427 2427 String bind_imp; … … 2439 2439 } 2440 2440 match203: 2441 debug writefln("parse_ImportDirective() PASS");2441 debug Stdout.formatln("parse_ImportDirective() PASS"); 2442 2442 ResultT!(ImportDirective) passed = ResultT!(ImportDirective)(new ImportDirective(bind_imp)); 2443 2443 return passed; … … 2456 2456 */ 2457 2457 public ResultT!(BaseClassDirective) parse_BaseClassDirective(){ 2458 debug writefln("parse_BaseClassDirective()");2458 debug Stdout.formatln("parse_BaseClassDirective()"); 2459 2459 uint start190 = position; 2460 2460 String bind_name; … … 2472 2472 } 2473 2473 match205: 2474 debug writefln("parse_BaseClassDirective() PASS");2474 debug Stdout.formatln("parse_BaseClassDirective() PASS"); 2475 2475 ResultT!(BaseClassDirective) passed = ResultT!(BaseClassDirective)(new BaseClassDirective(bind_name)); 2476 2476 return passed; … … 2489 2489 */ 2490 2490 public ResultT!(ClassnameDirective) parse_ClassnameDirective(){ 2491 debug writefln("parse_ClassnameDirective()");2491 debug Stdout.formatln("parse_ClassnameDirective()"); 2492 2492 uint start192 = position; 2493 2493 String bind_name; … … 2505 2505 } 2506 2506 match207: 2507 debug writefln("parse_ClassnameDirective() PASS");2507 debug Stdout.formatln("parse_ClassnameDirective() PASS"); 2508 2508 ResultT!(ClassnameDirective) passed = ResultT!(ClassnameDirective)(new ClassnameDirective(bind_name)); 2509 2509 return passed; … … 2522 2522 */ 2523 2523 public ResultT!(DefineDirective) parse_DefineDirective(){ 2524 debug writefln("parse_DefineDirective()");2524 debug Stdout.formatln("parse_DefineDirective()"); 2525 2525 uint start194 = position; 2526 2526 String bind_returnType; … … 2603 2603 } 2604 2604 match209: 2605 debug writefln("parse_DefineDirective() PASS");2605 debug Stdout.formatln("parse_DefineDirective() PASS"); 2606 2606 ResultT!(DefineDirective) passed = ResultT!(DefineDirective)(new DefineDirective(bind_returnType,bind_name,bind_isTerminal,bind_description)); 2607 2607 return passed; … … 2620 2620 */ 2621 2621 public ResultT!(IncludeDirective) parse_IncludeDirective(){ 2622 debug writefln("parse_IncludeDirective()");2622 debug Stdout.formatln("parse_IncludeDirective()"); 2623 2623 uint start198 = position; 2624 2624 String bind_filename; … … 2636 2636 } 2637 2637 match213: 2638 debug writefln("parse_IncludeDirective() PASS");2638 debug Stdout.formatln("parse_IncludeDirective() PASS"); 2639 2639 ResultT!(IncludeDirective) passed = ResultT!(IncludeDirective)(new IncludeDirective(bind_filename)); 2640 2640 return passed; … … 2653 2653 */ 2654 2654 public ResultT!(AliasDirective) parse_AliasDirective(){ 2655 debug writefln("parse_AliasDirective()");2655 debug Stdout.formatln("parse_AliasDirective()"); 2656 2656 uint start200 = position; 2657 2657 String bind_rule; … … 2670 2670 } 2671 2671 match215: 2672 debug writefln("parse_AliasDirective() PASS");2672 debug Stdout.formatln("parse_AliasDirective() PASS"); 2673 2673 ResultT!(AliasDirective) passed = ResultT!(AliasDirective)(new AliasDirective(bind_rule,bind_ruleAlias)); 2674 2674 return passed; … … 2687 2687 */ 2688 2688 public ResultT!(ModuleDirective) parse_ModuleDirective(){ 2689 debug writefln("parse_ModuleDirective()");2689 debug Stdout.formatln("parse_ModuleDirective()"); 2690 2690 uint start202 = position; 2691 2691 String bind_moduleName; … … 2703 2703 } 2704 2704 match217: 2705 debug writefln("parse_ModuleDirective() PASS");2705 debug Stdout.formatln("parse_ModuleDirective() PASS"); 2706 2706 ResultT!(ModuleDirective) passed = ResultT!(ModuleDirective)(new ModuleDirective(bind_moduleName)); 2707 2707 return passed; … … 2720 2720 */ 2721 2721 public ResultT!(CodeDirective) parse_CodeDirective(){ 2722 debug writefln("parse_CodeDirective()");2722 debug Stdout.formatln("parse_CodeDirective()"); 2723 2723 uint start204 = position; 2724 2724 String bind_code; … … 2772 2772 } 2773 2773 match219: 2774 debug writefln("parse_CodeDirective() PASS");2774 debug Stdout.formatln("parse_CodeDirective() PASS"); 2775 2775 ResultT!(CodeDirective) passed = ResultT!(CodeDirective)(new CodeDirective(bind_code)); 2776 2776 return passed; … … 2789 2789 */ 2790 2790 public ResultT!(TypelibDirective) parse_TypelibDirective(){ 2791 debug writefln("parse_TypelibDirective()");2791 debug Stdout.formatln("parse_TypelibDirective()"); 2792 2792 uint start209 = position; 2793 2793 String bind_importName; … … 2805 2805 } 2806 2806 match226: 2807 debug writefln("parse_TypelibDirective() PASS");2807 debug Stdout.formatln("parse_TypelibDirective() PASS"); 2808 2808 ResultT!(TypelibDirective) passed = ResultT!(TypelibDirective)(new TypelibDirective(bind_importName)); 2809 2809 return passed; … … 2822 2822 */ 2823 2823 public ResultT!(ParseTypeDirective) parse_ParseTypeDirective(){ 2824 debug writefln("parse_ParseTypeDirective()");2824 debug Stdout.formatln("parse_ParseTypeDirective()"); 2825 2825 uint start211 = position; 2826 2826 String bind_typeName; … … 2838 2838 } 2839 2839 match228: 2840 debug writefln("parse_ParseTypeDirective() PASS");2840 debug Stdout.formatln("parse_ParseTypeDirective() PASS"); 2841 2841 ResultT!(ParseTypeDirective) passed = ResultT!(ParseTypeDirective)(new ParseTypeDirective(bind_typeName)); 2842 2842 return passed; … … 2855 2855 */ 2856 2856 public ResultT!(BoilerplateDirective) parse_BoilerplateDirective(){ 2857 debug writefln("parse_BoilerplateDirective()");2857 debug Stdout.formatln("parse_BoilerplateDirective()"); 2858 2858 uint start213 = position; 2859 2859 String bind_code; … … 2907 2907 } 2908 2908 match230: 2909 debug writefln("parse_BoilerplateDirective() PASS");2909 debug Stdout.formatln("parse_BoilerplateDirective() PASS"); 2910 2910 ResultT!(BoilerplateDirective) passed = ResultT!(BoilerplateDirective)(new BoilerplateDirective(bind_code)); 2911 2911 return passed; … … 2924 2924 */ 2925 2925 public ResultT!(HeaderDirective) parse_HeaderDirective(){ 2926 debug writefln("parse_HeaderDirective()");2926 debug Stdout.formatln("parse_HeaderDirective()"); 2927 2927 uint start218 = position; 2928 2928 String bind_code; … … 2976 2976 } 2977 2977 match237: 2978 debug writefln("parse_HeaderDirective() PASS");2978 debug Stdout.formatln("parse_HeaderDirective() PASS"); 2979 2979 ResultT!(HeaderDirective) passed = ResultT!(HeaderDirective)(new HeaderDirective(bind_code)); 2980 2980 return passed; … … 2993 2993 */ 2994 2994 public ResultT!(UTFDirective) parse_UTFDirective(){ 2995 debug writefln("parse_UTFDirective()");2995 debug Stdout.formatln("parse_UTFDirective()"); 2996 2996 uint start223 = position; 2997 2997 String bind_value; … … 3009 3009 } 3010 3010 match244: 3011 debug writefln("parse_UTFDirective() PASS");3011 debug Stdout.formatln("parse_UTFDirective() PASS"); 3012 3012 ResultT!(UTFDirective) passed = ResultT!(UTFDirective)(new UTFDirective(bind_value)); 3013 3013 return passed; … … 3026 3026 */ 3027 3027 public ResultT!(String) parse_DirectiveArg(){ 3028 debug writefln("parse_DirectiveArg()");3028 debug Stdout.formatln("parse_DirectiveArg()"); 3029 3029 uint start225 = position; 3030 3030 String bind_arg; … … 3043 3043 } 3044 3044 match246: 3045 debug writefln("parse_DirectiveArg() PASS");3045 debug Stdout.formatln("parse_DirectiveArg() PASS"); 3046 3046 return ResultT!(String)(bind_arg); 3047 3047 mismatch247: trunk/enki/Expression.d
r276 r289 30 30 private import enki.Rule; 31 31 32 private import std.stdio;32 private import tango.io.Stdout; 33 33 34 34 class Expression : IRenderable{ trunk/enki/Rule.d
r239 r289 30 30 private import enki.CodeGenerator; 31 31 32 private import std.stdio;32 private import tango.io.Stdout; 33 33 34 34 class Rule : SyntaxLine, IRenderable{ … … 130 130 emit("public ResultT!(" ~ type ~ ") parse_" ~ name ~ "(" ~ decl.renderDeclaration() ~ "){"); 131 131 indent(); 132 emit("debug writefln(\"parse_" ~ name ~ "()\");");132 emit("debug Stdout.formatln(\"parse_" ~ name ~ "()\");"); 133 133 emit("uint " ~ startLabel ~ " = position;"); 134 134 pred.renderDeclarations(generator,decl.paramXRef); … … 141 141 142 142 render(matchLabel); 143 emit("debug writefln(\"parse_" ~ name ~ "() PASS\");");143 emit("debug Stdout.formatln(\"parse_" ~ name ~ "() PASS\");"); 144 144 pred.renderPass(generator,startLabel); 145 145 trunk/enki/bootstrap.d
r277 r289 40 40 private import enki.Rule; 41 41 42 private import std.string; 43 private import std.stdio; 44 private import std.file; 42 import tango.text.Util; 43 import tango.text.Unicode; 44 import tango.io.Stdout; 45 import tango.io.File; 45 46 46 47 // helper functions … … 1210 1211 1211 1212 // create bnf file 1212 std.file.write("enki/enki.bnf",syntax.toBNF());1213 File("enki/enki.bnf").write(syntax.toBNF()); 1213 1214 1214 1215 // emit the code 1215 std.file.write("enki/EnkiParser.d",syntax.render());1216 File("enki/EnkiParser.d").write(syntax.render()); 1216 1217 } trunk/enki/enki_bn.d
r277 r289 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 2 04;4 long auto_build_number = 236; trunk/enki/types.d
r277 r289 25 25 module enki.types; 26 26 27 private import std.string;27 /+private import std.string; 28 28 private import std.utf; 29 private import std.conv; 29 private import std.conv;+/ 30 import tango.text.Util; 31 import tango.text.Unicode; 32 import tango.util.Convert; 33 static import tango.text.convert.Utf; 30 34 31 35 version(EnkiUTF32){ 32 36 alias dchar[] String; 33 37 alias dchar Char; 34 alias to UTF32transcodeToString;35 alias to UTF8transcodeToUTF8;38 alias to!(dchar[]) transcodeToString; 39 alias to!(char[]) transcodeToUTF8; 36 40 } 37 41 else version(EnkiUTF16){ 38 42 alias wchar[] String; 39 43 alias wchar Char; 40 alias to UTF16transcodeToString;41 alias to UTF8transcodeToUTF8;44 alias to!(wchar[]) transcodeToString; 45 alias to!(char[]) transcodeToUTF8; 42 46 } 43 47 else{ 44 48 alias char[] String; 45 49 alias char Char; 46 alias to UTF8transcodeToString;50 alias to!(char[]) transcodeToString; 47 51 char[] transcodeToUTF8(char[] value){ return value; } 48 52 } 53 54 alias to!(char[]) toString; 55 49 56 50 57 // implicitly converable … … 72 79 } 73 80 else{ 74 return transcodeToString( std.string.toString(value));81 return transcodeToString(to!(char[])(value)); 75 82 } 76 83 } … … 83 90 U convert(V value){ 84 91 static if(is(U == int)){ 85 return std.conv.toInt(value);86 } 87 else static if(is(U == int)){88 return std.conv.toUint(value);92 return to!(U)(value); 93 } 94 else static if(is(U == uint)){ 95 return to!(U)(value); 89 96 } 90 97 else static if(is(U == long)){ 91 return std.conv.toLong(value);98 return to!(U)(value); 92 99 } 93 100 else static if(is(U == ulong)){ 94 return std.conv.toUlong(value);101 return to!(U)(value); 95 102 } 96 103 else static if(is(U == short)){ 97 return std.conv.toShort(value);104 return to!(U)(value); 98 105 } 99 106 else static if(is(U == ushort)){ 100 return std.conv.toUshort(value);107 return to!(U)(value); 101 108 } 102 109 else static if(is(U == byte)){ 103 return std.conv.toByte(value);110 return to!(U)(value); 104 111 } 105 112 else static if(is(U == ubyte)){ 106 return std.conv.toUbyte(value);113 return to!(U)(value); 107 114 } 108 115 else static if(is(U == float)){ 109 return std.conv.toFloat(value);116 return to!(U)(value); 110 117 } 111 118 else static if(is(U == double)){ 112 return std.conv.toDouble(value);119 return to!(U)(value); 113 120 } 114 121 else static if(is(U == real)){ 115 return std.conv.toReal(value);122 return to!(U)(value); 116 123 } 117 124 else static if(is(U == bool)){ … … 194 201 195 202 alias T Type; 196 alias Result!(T) ThisType;203 alias typeof(*this) ThisType; 197 204 198 205 public static ThisType opCall(T result){
