Changeset 235
- Timestamp:
- 08/11/06 11:12:17 (2 years ago)
- Files:
-
- trunk/enki/BaseParser.d (modified) (1 diff)
- trunk/enki/Directive.d (modified) (14 diffs)
- trunk/enki/EnkiBackend.d (modified) (8 diffs)
- trunk/enki/EnkiParser.d (modified) (6 diffs)
- trunk/enki/Expression.d (modified) (1 diff)
- trunk/enki/IParser.d (modified) (2 diffs)
- trunk/enki/bootstrap.d (modified) (4 diffs)
- trunk/enki/enki.bnf (modified) (4 diffs)
- trunk/enki/enki.d (modified) (2 diffs)
- trunk/enki/enki_bn.d (modified) (1 diff)
- trunk/enki/library/d/CharEntity.bnf (modified) (1 diff)
- trunk/enki/library/d/Character.bnf (modified) (1 diff)
- trunk/enki/library/d/Entity.d (added)
- trunk/enki/library/d/Keyword.bnf (added)
- trunk/enki/library/d/Keyword.d (modified) (1 diff)
- trunk/enki/library/d/Operator.d (modified) (1 diff)
- trunk/enki/library/d/OtherToken.bnf (added)
- trunk/enki/library/d/Parser.bnf (added)
- trunk/enki/library/d/ParserBackend.d (added)
- trunk/enki/library/d/Pragma.bnf (added)
- trunk/enki/library/d/Token.d (modified) (11 diffs)
- trunk/enki/library/d/Tokenizer.bnf (modified) (8 diffs)
- trunk/enki/library/d/TokenizerBase.d (modified) (5 diffs)
- trunk/enki/library/d/ddoc (added)
- trunk/enki/library/d/ddoc/DDocParser.d (added)
- trunk/enki/library/d/ddoc/Ddoc.bnf (added)
- trunk/enki/library/d/parser (added)
- trunk/enki/library/d/parser/Asm.bnf (added)
- trunk/enki/library/d/parser/Asm.d (added)
- trunk/enki/library/d/parser/Attribute.bnf (added)
- trunk/enki/library/d/parser/Attribute.d (added)
- trunk/enki/library/d/parser/Class.bnf (added)
- trunk/enki/library/d/parser/Class.d (added)
- trunk/enki/library/d/parser/Conditional.bnf (added)
- trunk/enki/library/d/parser/Conditional.d (added)
- trunk/enki/library/d/parser/Declaration.bnf (added)
- trunk/enki/library/d/parser/Declaration.d (added)
- trunk/enki/library/d/parser/Enum.bnf (added)
- trunk/enki/library/d/parser/Enum.d (added)
- trunk/enki/library/d/parser/Expression.bnf (added)
- trunk/enki/library/d/parser/Expression.d (added)
- trunk/enki/library/d/parser/Function.bnf (added)
- trunk/enki/library/d/parser/Function.d (added)
- trunk/enki/library/d/parser/Import.bnf (added)
- trunk/enki/library/d/parser/Import.d (added)
- trunk/enki/library/d/parser/Interface.bnf (added)
- trunk/enki/library/d/parser/Interface.d (added)
- trunk/enki/library/d/parser/Mixin.bnf (added)
- trunk/enki/library/d/parser/Mixin.d (added)
- trunk/enki/library/d/parser/Module.bnf (added)
- trunk/enki/library/d/parser/Module.d (added)
- trunk/enki/library/d/parser/Statement.d (added)
- trunk/enki/library/d/parser/Statements.bnf (added)
- trunk/enki/library/d/parser/Struct.bnf (added)
- trunk/enki/library/d/parser/Struct.d (added)
- trunk/enki/library/d/parser/Template.bnf (added)
- trunk/enki/library/d/parser/Template.d (added)
- trunk/enki/library/d/parser/x86 (added)
- trunk/enki/library/d/parser/x86/Opcode.bnf (added)
- trunk/enki/library/d/parser/x86/Opcode.d (added)
- trunk/enki/library/d/parser/x86/Register.bnf (added)
- trunk/enki/library/d/parser/x86/Register.d (added)
- trunk/enki/library/xml/Namespace.bnf (added)
- trunk/enki/library/xml/XMLParser.bnf (modified) (1 diff)
- trunk/enki/library/xpath/xpath10.bnf (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/enki/BaseParser.d
r231 r235 47 47 } 48 48 49 pr ivateString data;50 pr ivateuint pos;51 pr ivateErrorData[] errors;49 protected String data; 50 protected uint pos; 51 protected ErrorData[] errors; 52 52 53 53 public this(){ trunk/enki/Directive.d
r231 r235 31 31 debug private import std.stdio; 32 32 33 /* 34 RootOnly: 35 .baseclass 36 .classname 37 .module 38 .typelib 39 .parsetype 40 .utf 41 .boilerplate 42 43 FirstPass: 44 .import 45 .define 46 .include 47 .header 48 49 SecondPass: 50 .alias 51 .code 52 */ 53 54 33 55 abstract class Directive : SyntaxLine, IRenderable{ 56 enum: uint{ 57 RootOnly, 58 FirstPass, 59 SecondPass, 60 } 61 62 public uint type(){ 63 return Directive.SecondPass; 64 } 65 34 66 public void semanticPass(BaseEnkiParser root){ 35 67 //do nothing … … 48 80 public void render(CodeGenerator generator,Statement passterm,Statement failterm){ 49 81 // do nothing 50 } 82 } 51 83 } 52 84 … … 54 86 String imp; 55 87 88 public uint type(){ 89 return Directive.FirstPass; 90 } 91 56 92 public this(String imp){ 57 93 this.imp = imp; … … 69 105 return "Import Directive"; 70 106 } 107 71 108 } 72 109 … … 74 111 String name; 75 112 113 public uint type(){ 114 return Directive.RootOnly; 115 } 116 76 117 public this(String name){ 77 118 this.name = name; … … 93 134 class ClassnameDirective : Directive{ 94 135 String name; 136 137 public uint type(){ 138 return Directive.RootOnly; 139 } 95 140 96 141 public this(String name){ … … 116 161 String description; 117 162 bool isTerminal; 163 164 public uint type(){ 165 return Directive.FirstPass; 166 } 118 167 119 168 public this(String returnType,String name,bool isTerminal,String description){ … … 153 202 class IncludeDirective : Directive{ 154 203 String filename; 204 205 public uint type(){ 206 return Directive.FirstPass; 207 } 155 208 156 209 public this(String filename){ … … 195 248 String rule; 196 249 String ruleAlias; 197 250 251 public uint type(){ 252 return Directive.SecondPass; 253 } 254 198 255 public this(String rule,String ruleAlias){ 199 256 this.rule = rule; … … 216 273 class ModuleDirective : Directive{ 217 274 String moduleName; 218 275 276 public uint type(){ 277 return Directive.RootOnly; 278 } 279 219 280 public this(String moduleName){ 220 281 this.moduleName = moduleName; … … 237 298 class CodeDirective : Directive{ 238 299 String code; 300 301 public uint type(){ 302 return Directive.SecondPass; 303 } 239 304 240 305 public this(String code){ … … 261 326 class TypelibDirective : Directive{ 262 327 String moduleName; 263 328 329 public uint type(){ 330 return Directive.RootOnly; 331 } 332 264 333 public this(String moduleName){ 265 334 this.moduleName = moduleName; … … 281 350 class ParseTypeDirective : Directive{ 282 351 String typeName; 283 352 353 public uint type(){ 354 return Directive.RootOnly; 355 } 356 284 357 public this(String typeName){ 285 358 this.typeName = typeName; … … 298 371 } 299 372 } 373 374 375 class BoilerplateDirective : Directive{ 376 String code; 377 378 public uint type(){ 379 return Directive.RootOnly; 380 } 381 382 public this(String code){ 383 this.code = code; 384 } 385 386 public void semanticPass(BaseEnkiParser root){ 387 root.setBoilerplate(code); 388 } 389 390 public String toBNF(){ 391 return ".boilerplate{{{" ~ code ~ "}}}\n"; 392 } 393 394 public String toString(){ 395 return "Boilerplate Directive"; 396 } 397 } 398 399 class HeaderDirective : Directive{ 400 String code; 401 402 public uint type(){ 403 return Directive.FirstPass; 404 } 405 406 public this(String code){ 407 this.code = code; 408 } 409 410 public void semanticPass(BaseEnkiParser root){ 411 root.setHeader(code); 412 } 413 414 public String toBNF(){ 415 return ".header{{{" ~ code ~ "}}}\n"; 416 } 417 418 public String toString(){ 419 return "Header Directive"; 420 } 421 } 422 423 class UTFDirective : Directive{ 424 String value; 425 426 public uint type(){ 427 return Directive.RootOnly; 428 } 429 430 public this(String value){ 431 this.value = value; 432 } 433 434 public void semanticPass(BaseEnkiParser root){ 435 switch(value){ 436 case "8": 437 case "32": 438 case "16": 439 break; 440 default: 441 throw new Exception("The value '" ~ value ~ "' is not a valid UTF parameter. Expected '8', '16' or '32'"); 442 } 443 root.setUTF(value); 444 } 445 446 public String toBNF(){ 447 return ".utf(\"" ~ value ~ "\");\n"; 448 } 449 450 public String toString(){ 451 return "UTF Directive"; 452 } 453 } trunk/enki/EnkiBackend.d
r203 r235 64 64 String typelib; 65 65 String parseType; 66 String boilerplate; 67 String header; 68 String utf; 66 69 UserProduction[] userProductions; 67 70 … … 71 74 this.typelib = "enki.types"; 72 75 this.parseType = "String"; 76 this.utf = "8"; 73 77 } 74 78 … … 78 82 79 83 public void add(BaseEnkiParser other){ 80 debug writefln("Aggregating included rules - %d total",other.rules.length); 81 foreach(name,rule; other.rules){ 82 debug writefln("\t%s included",name); 83 this.rules[name] = rule; 84 } 85 86 debug writefln("Aggregating included lines - %d total",other.lines.length); 87 this.lines ~= other.lines; 84 // aggregate and perform nested semantic pass on directives 85 debug writefln("Running Non-Root Semantic Pass on aggregated lines."); 86 87 foreach(line; other.lines){ 88 Directive directive = cast(Directive)line; 89 if(directive && directive.type == Directive.FirstPass){ 90 directive.semanticPass(this); 91 } 92 else{ 93 this.lines ~= line; 94 } 95 } 88 96 } 89 97 … … 104 112 } 105 113 114 public void setBoilerplate(String value){ 115 boilerplate ~= value; 116 } 117 118 public void setHeader(String value){ 119 header ~= value; 120 } 121 106 122 public void defineUserProduction(String returnType,String name,String description){ 107 123 userProductions ~= UserProduction(returnType,name,description); … … 119 135 public String getParseType(){ 120 136 return parseType; 137 } 138 139 public void setUTF(String value){ 140 utf = value; 121 141 } 122 142 … … 177 197 178 198 public void semanticPass(){ 179 // first pass - gather all production names 199 // first/root pass 200 debug writefln("-- Root/First Semantic Pass --"); 201 foreach(line; lines){ 202 Directive directive = cast(Directive)line; 203 if(directive && (directive.type == Directive.FirstPass || directive.type == Directive.RootOnly)){ 204 directive.semanticPass(this); 205 } 206 } 207 208 // gather production names 180 209 foreach(line; lines){ 181 210 Rule rule = cast(Rule)line; 182 211 if(rule){ 183 this.rules[rule.name] = rule; 184 } 185 } 186 187 // resolve all lines 188 foreach(line; lines){ 189 line.semanticPass(this); 190 } 212 rules[rule.name] = rule; 213 } 214 } 215 216 // second pass - realize all other directives 217 debug writefln("-- Second Semantic Pass --"); 218 foreach(line; lines){ 219 Directive directive = cast(Directive)line; 220 if(directive && (directive.type == Directive.SecondPass)){ 221 directive.semanticPass(this); 222 } 223 } 224 225 // resolve all rules last 226 debug writefln("-- Final Semantic Pass --"); 227 foreach(name,rule; rules){ 228 debug writefln("-- Semantic Pass for rule %s --",name); 229 rule.semanticPass(this); 230 } 231 191 232 } 192 233 … … 194 235 auto CodeGenerator generator = new CodeGenerator(this.parseType); 195 236 with(generator){ 196 emit("//auto-generated parser"); 237 // boilerplate section 238 emit("//Generated by Enki v1.2"); 239 emit(""); 240 emit(boilerplate); 241 242 // module and imports section 243 emit(""); 197 244 if(moduleName){ 198 245 emit("module " ~ moduleName ~ ";"); 199 246 } 247 emit("version(build) pragma(export_version,EnkiUTF" ~ utf ~ ");"); 248 emit(""); 200 249 emit("debug private import std.stdio;"); 201 250 … … 207 256 } 208 257 emit(""); 258 259 // header section 260 emit(header); 261 emit(""); 262 263 // parser class definition 209 264 if(baseclass){ 210 265 emit("class " ~ classname ~ " : " ~ baseclass ~ "{"); trunk/enki/EnkiParser.d
r231 r235 1 //auto-generated parser 2 module enki.EnkiParser; 3 debug private import std.stdio; 4 private import enki.types; 5 private import enki.EnkiBackend; 6 private import enki.Rule; 7 private import enki.Expression; 8 private import enki.Directive; 9 10 class EnkiParser : BaseEnkiParser{ 1 //Generated by Enki v1.2 11 2 12 3 /+ 13 Copyright (c) 2006 Eric Anderton , BCS4 Copyright (c) 2006 Eric Anderton 14 5 15 6 Permission is hereby granted, free of charge, to any person … … 34 25 OTHER DEALINGS IN THE SOFTWARE. 35 26 +/ 27 28 module enki.EnkiParser; 29 version(build) pragma(export_version,EnkiUTF8); 30 31 debug private import std.stdio; 32 private import enki.types; 33 private import enki.EnkiBackend; 34 private import enki.Rule; 35 private import enki.Expression; 36 private import enki.Directive; 37 38 39 40 class EnkiParser : BaseEnkiParser{ 41 36 42 /* 37 43 … … 2124 2130 Directive 2125 2131 = Directive dir 2126 ::= "." ( ImportDirective:~dir | BaseClassDirective:~dir | ClassnameDirective:~dir | DefineDirective:~dir | IncludeDirective:~dir | AliasDirective:~dir | ModuleDirective:~dir | CodeDirective:~dir | TypelibDirective:~dir | ParseTypeDirective:~dir ) ;2132 ::= "." ( ImportDirective:~dir | BaseClassDirective:~dir | ClassnameDirective:~dir | DefineDirective:~dir | IncludeDirective:~dir | AliasDirective:~dir | ModuleDirective:~dir | CodeDirective:~dir | TypelibDirective:~dir | ParseTypeDirective:~dir | BoilerplateDirective:~dir | HeaderDirective:~dir | UTFDirective:~dir ) ; 2127 2133 2128 2134 */ … … 2140 2146 {//Expression 2141 2147 uint start158 = position; 2142 if((parse_ImportDirective().assignCat!(Directive)(bind_dir)) || (parse_BaseClassDirective().assignCat!(Directive)(bind_dir)) || (parse_ClassnameDirective().assignCat!(Directive)(bind_dir)) || (parse_DefineDirective().assignCat!(Directive)(bind_dir)) || (parse_IncludeDirective().assignCat!(Directive)(bind_dir)) || (parse_AliasDirective().assignCat!(Directive)(bind_dir)) || (parse_ModuleDirective().assignCat!(Directive)(bind_dir)) || (parse_CodeDirective().assignCat!(Directive)(bind_dir)) || (parse_TypelibDirective().assignCat!(Directive)(bind_dir)) || (parse_ParseTypeDirective().assignCat!(Directive)(bind_dir)) ){2148 if((parse_ImportDirective().assignCat!(Directive)(bind_dir)) || (parse_BaseClassDirective().assignCat!(Directive)(bind_dir)) || (parse_ClassnameDirective().assignCat!(Directive)(bind_dir)) || (parse_DefineDirective().assignCat!(Directive)(bind_dir)) || (parse_IncludeDirective().assignCat!(Directive)(bind_dir)) || (parse_AliasDirective().assignCat!(Directive)(bind_dir)) || (parse_ModuleDirective().assignCat!(Directive)(bind_dir)) || (parse_CodeDirective().assignCat!(Directive)(bind_dir)) || (parse_TypelibDirective().assignCat!(Directive)(bind_dir)) || (parse_ParseTypeDirective().assignCat!(Directive)(bind_dir)) || (parse_BoilerplateDirective().assignCat!(Directive)(bind_dir)) || (parse_HeaderDirective().assignCat!(Directive)(bind_dir)) || (parse_UTFDirective().assignCat!(Directive)(bind_dir))){ 2143 2149 clearErrors(); 2144 2150 }else{ 2145 setError("Expected ImportDirective, BaseClassDirective, ClassnameDirective, DefineDirective, IncludeDirective, AliasDirective, ModuleDirective, CodeDirective, TypelibDirective or ParseTypeDirective.");2151 setError("Expected ImportDirective, BaseClassDirective, ClassnameDirective, DefineDirective, IncludeDirective, AliasDirective, ModuleDirective, CodeDirective, TypelibDirective, ParseTypeDirective, BoilerplateDirective, HeaderDirective or UTFDirective."); 2146 2152 position = start158; 2147 2153 goto mismatch170; … … 2596 2602 /* 2597 2603 2604 BoilerplateDirective 2605 = new BoilerplateDirective(String code) 2606 ::= "boilerplate" ws "{{{" { any}:code "}}}"; 2607 2608 */ 2609 public ResultT!(BoilerplateDirective) parse_BoilerplateDirective(){ 2610 debug writefln("parse_BoilerplateDirective()"); 2611 uint start183 = position; 2612 String bind_code; 2613 2614 2615 {//Expression 2616 uint start184 = position; 2617 if(!(terminal("boilerplate").success)){ 2618 goto mismatch200; 2619 } 2620 if(!(parse_ws().success)){ 2621 goto mismatch200; 2622 } 2623 if(!(terminal("{{{").success)){ 2624 goto mismatch200; 2625 } 2626 {//ZeroOrMoreExpr 2627 uint start185 = position; 2628 uint termPos; 2629 loop201: 2630 termPos = position; 2631 if(terminal("}}}").success){ 2632 goto loopend202; 2633 } 2634 {//Expression 2635 uint start186 = position; 2636 if((parse_any().success)){ 2637 clearErrors(); 2638 goto loop201; 2639 }else{ 2640 setError("Expected any."); 2641 position = start186; 2642 goto mismatch200; 2643 } 2644 } 2645 loopend202: 2646 smartAssign!(String,String)(bind_code,sliceData(start185,termPos)); 2647 {/*do nothing*/} 2648 } 2649 goto match199; 2650 mismatch200: 2651 {/*do nothing*/} 2652 position = start184; 2653 goto mismatch198; 2654 match199: 2655 clearErrors(); 2656 goto match197; 2657 } 2658 match197: 2659 debug writefln("parse_BoilerplateDirective() PASS"); 2660 ResultT!(BoilerplateDirective) passed = ResultT!(BoilerplateDirective)(new BoilerplateDirective(bind_code)); 2661 return passed; 2662 mismatch198: 2663 position = start183; 2664 ResultT!(BoilerplateDirective) failed = ResultT!(BoilerplateDirective)(); 2665 return failed; 2666 } 2667 2668 /* 2669 2670 HeaderDirective 2671 = new HeaderDirective(String code) 2672 ::= "header" ws "{{{" { any}:code "}}}"; 2673 2674 */ 2675 public ResultT!(HeaderDirective) parse_HeaderDirective(){ 2676 debug writefln("parse_HeaderDirective()"); 2677 uint start187 = position; 2678 String bind_code; 2679 2680 2681 {//Expression 2682 uint start188 = position; 2683 if(!(terminal("header").success)){ 2684 goto mismatch206; 2685 } 2686 if(!(parse_ws().success)){ 2687 goto mismatch206; 2688 } 2689 if(!(terminal("{{{").success)){ 2690 goto mismatch206; 2691 } 2692 {//ZeroOrMoreExpr 2693 uint start189 = position; 2694 uint termPos; 2695 loop207: 2696 termPos = position; 2697 if(terminal("}}}").success){ 2698 goto loopend208; 2699 } 2700 {//Expression 2701 uint start190 = position; 2702 if((parse_any().success)){ 2703 clearErrors(); 2704 goto loop207; 2705 }else{ 2706 setError("Expected any."); 2707 position = start190; 2708 goto mismatch206; 2709 } 2710 } 2711 loopend208: 2712 smartAssign!(String,String)(bind_code,sliceData(start189,termPos)); 2713 {/*do nothing*/} 2714 } 2715 goto match205; 2716 mismatch206: 2717 {/*do nothing*/} 2718 position = start188; 2719 goto mismatch204; 2720 match205: 2721 clearErrors(); 2722 goto match203; 2723 } 2724 match203: 2725 debug writefln("parse_HeaderDirective() PASS"); 2726 ResultT!(HeaderDirective) passed = ResultT!(HeaderDirective)(new HeaderDirective(bind_code)); 2727 return passed; 2728 mismatch204: 2729 position = start187; 2730 ResultT!(HeaderDirective) failed = ResultT!(HeaderDirective)(); 2731 return failed; 2732 } 2733 2734 /* 2735 2736 UTFDirective 2737 = new UTFDirective(String value) 2738 ::= "utf" ws "(" ws DirectiveArg:value ws ")" ws ";"; 2739 2740 */ 2741 public ResultT!(UTFDirective) parse_UTFDirective(){ 2742 debug writefln("parse_UTFDirective()"); 2743 uint start191 = position; 2744 String bind_value; 2745 2746 2747 {//Expression 2748 uint start192 = position; 2749 if((terminal("utf").success && parse_ws().success && terminal("(").success && parse_ws().success && parse_DirectiveArg().assign!(String)(bind_value) && parse_ws().success && terminal(")").success && parse_ws().success && terminal(";").success)){ 2750 clearErrors(); 2751 goto match209; 2752 }else{ 2753 position = start192; 2754 goto mismatch210; 2755 } 2756 } 2757 match209: 2758 debug writefln("parse_UTFDirective() PASS"); 2759 ResultT!(UTFDirective) passed = ResultT!(UTFDirective)(new UTFDirective(bind_value)); 2760 return passed; 2761 mismatch210: 2762 position = start191; 2763 ResultT!(UTFDirective) failed = ResultT!(UTFDirective)(); 2764 return failed; 2765 } 2766 2767 /* 2768 2598 2769 DirectiveArg 2599 2770 = String arg … … 2603 2774 public ResultT!(String) parse_DirectiveArg(){ 2604 2775 debug writefln("parse_DirectiveArg()"); 2605 uint start1 83 = position;2776 uint start193 = position; 2606 2777 String bind_arg; 2607 2778 2608 2779 2609 2780 {//Expression 2610 uint start1 84 = position;2781 uint start194 = position; 2611 2782 if((parse_Identifier().assign!(String)(bind_arg)) || (parse_String().assign!(String)(bind_arg))){ 2612 2783 clearErrors(); 2613 goto match 197;2784 goto match211; 2614 2785 }else{ 2615 2786 setError("Expected Identifier or String."); 2616 position = start1 84;2617 goto mismatch 198;2618 } 2619 } 2620 match 197:2787 position = start194; 2788 goto mismatch212; 2789 } 2790 } 2791 match211: 2621 2792 debug writefln("parse_DirectiveArg() PASS"); 2622 2793 return ResultT!(String)(bind_arg); 2623 mismatch 198:2624 position = start1 83;2794 mismatch212: 2795 position = start193; 2625 2796 return ResultT!(String)(); 2626 2797 } trunk/enki/Expression.d
r231 r235 169 169 } 170 170 else{ 171 debug writefln("isShort.length %d terms.length",isShort.length,terms.length); 171 172 assert(isShort.length == terms.length); 172 173 with(generator){ trunk/enki/IParser.d
r231 r235 40 40 public void clearErrors(); 41 41 public String getErrorReport(); 42 public bool hasErrors(); 42 43 43 44 protected ResultString regexp(String str); … … 46 47 protected void position(uint newPos); 47 48 protected String sliceData(uint start,uint end); 49 public ResultString terminal(uint ch); 50 public ResultString range(uint start,uint end); 48 51 } trunk/enki/bootstrap.d
r231 r235 71 71 SyntaxLine[] lines; 72 72 73 lines ~= new CodeDirective(`/+73 lines ~= new BoilerplateDirective(`/+ 74 74 Copyright (c) 2006 Eric Anderton 75 75 … … 116 116 lines ~= new DefineDirective("String","sp",true,"Space(s)"); 117 117 lines ~= new DefineDirective("String","ws",false,"Whitespace"); 118 119 lines ~= empty; 120 lines ~= new ParseTypeDirective("String"); 121 lines ~= new UTFDirective("8"); 118 122 119 123 lines ~= empty; … … 877 881 makeTerm(new Production("CodeDirective",new Binding(true,"dir"))), 878 882 makeTerm(new Production("TypelibDirective",new Binding(true,"dir"))), 879 makeTerm(new Production("ParseTypeDirective",new Binding(true,"dir"))) 883 makeTerm(new Production("ParseTypeDirective",new Binding(true,"dir"))), 884 makeTerm(new Production("BoilerplateDirective",new Binding(true,"dir"))), 885 makeTerm(new Production("HeaderDirective",new Binding(true,"dir"))), 886 makeTerm(new Production("UTFDirective",new Binding(true,"dir"))) 880 887 ) 881 888 ), … … 1067 1074 ) 1068 1075 ); 1076 1077 lines ~= new Rule("BoilerplateDirective", 1078 new ClassPredicate("BoilerplateDirective", new Param("code")), 1079 new Expression( 1080 new Terminal("boilerplate",null), 1081 new Production("ws",null), 1082 new Terminal("{{{",null), 1083 new ZeroOrMoreExpr( 1084 new Expression( 1085 new Production("any",null) 1086 ), 1087 new Binding(false,"code"), 1088 new Terminal("}}}",null) 1089 ) 1090 ) 1091 ); 1092 1093 lines ~= new Rule("HeaderDirective", 1094 new ClassPredicate("HeaderDirective", new Param("code")), 1095 new Expression( 1096 new Terminal("header",null), 1097 new Production("ws",null), 1098 new Terminal("{{{",null), 1099 new ZeroOrMoreExpr( 1100 new Expression( 1101 new Production("any",null) 1102 ), 1103 new Binding(false,"code"), 1104 new Terminal("}}}",null) 1105 ) 1106 ) 1107 ); 1108 1109 lines ~= new Rule("UTFDirective", 1110 new ClassPredicate("UTFDirective", new Param("value")), 1111 new Expression( 1112 new Terminal("utf",null), 1113 new Production("ws",null), 1114 new Terminal("(",null), 1115 new Production("ws",null), 1116 new Production("DirectiveArg",new Binding(false,"value")), 1117 new Production("ws",null), 1118 new Terminal(")",null), 1119 new Production("ws",null), 1120 new Terminal(";",null) 1121 ) 1122 ); 1069 1123 1070 1124 lines ~= new Rule("DirectiveArg", trunk/enki/enki.bnf
r231 r235 1 . code{{{/+2 Copyright (c) 2006 Eric Anderton , BCS1 .boilerplate{{{/+ 2 Copyright (c) 2006 Eric Anderton 3 3 4 4 Permission is hereby granted, free of charge, to any person … … 43 43 .define("String","ws","false","Whitespace"); 44 44 45 .parsetype("String"); 46 .utf("8"); 47 45 48 .baseclass("BaseEnkiParser"); 46 49 .classname("EnkiParser"); … … 215 218 Directive 216 219 = Directive dir 217 ::= "." ( ImportDirective:~dir | BaseClassDirective:~dir | ClassnameDirective:~dir | DefineDirective:~dir | IncludeDirective:~dir | AliasDirective:~dir | ModuleDirective:~dir | CodeDirective:~dir | TypelibDirective:~dir | ParseTypeDirective:~dir ) ;220 ::= "." ( ImportDirective:~dir | BaseClassDirective:~dir | ClassnameDirective:~dir | DefineDirective:~dir | IncludeDirective:~dir | AliasDirective:~dir | ModuleDirective:~dir | CodeDirective:~dir | TypelibDirective:~dir | ParseTypeDirective:~dir | BoilerplateDirective:~dir | HeaderDirective:~dir | UTFDirective:~dir ) ; 218 221 219 222 ImportDirective … … 257 260 ::= "parsetype" ws "(" ws DirectiveArg:typeName ws ")" ws ";"; 258 261 262 BoilerplateDirective 263 = new BoilerplateDirective(String code) 264 ::= "boilerplate" ws "{{{" { any}:code "}}}"; 265 266 HeaderDirective 267 = new HeaderDirective(String code) 268 ::= "header" ws "{{{" { any}:code "}}}"; 269 270 UTFDirective 271 = new UTFDirective(String value) 272 ::= "utf" ws "(" ws DirectiveArg:value ws ")" ws ";"; 273 259 274 DirectiveArg 260 275 = String arg trunk/enki/enki.d
r202 r235 35 35 36 36 char[] helpText = 37 `Enki - Frontend Parser Generator - V1. 0Build %d37 `Enki - Frontend Parser Generator - V1.2 Build %d 38 38 Copyright(c) 2006 Eric Anderton 39 39 … … 46 46 -f<file> Specify output filename 47 47 -b<file> Specify output ebnf filename 48 -t Test Mode 48 -t Test Mode (output everything to console) 49 49 50 50 The -b option is used primarily as a sanity check of trunk/enki/enki_bn.d
r233 r235 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 1 56;4 long auto_build_number = 177; trunk/enki/library/d/CharEntity.bnf
r234 r235 1 .boilerplate{{{/+ 2 Copyright (c) 2006 Eric Anderton 3 4 Permission is hereby granted, free of charge, to any person 5 obtaining a copy of this software and associated documentation 6 files (the "Software"), to deal in the Software without 7 restriction, including without limitation the rights to use, 8 copy, modify, merge, publish, distribute, sublicense, and/or 9 sell copies of the Software, and to permit persons to whom the 10 Software is furnished to do so, subject to the following 11 conditions: 12 13 The above copyright notice and this permission notice shall be 14 included in all copies or substantial portions of the Software. 15 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17
