Changeset 290 for trunk/enki
- Timestamp:
- 03/31/08 14:50:53 (9 months ago)
- Files:
-
- trunk/enki/BaseParser.d (modified) (1 diff)
- trunk/enki/enki.d (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/enki/BaseParser.d
r289 r290 80 80 /** error handling **/ 81 81 protected void setError(String text){ 82 debug writefln("[%d] Error: %s",pos,text);82 debug Stdout.formatln("[{}] Error: {}",pos,text); 83 83 ErrorData data; 84 84 data.pos = pos; trunk/enki/enki.d
r235 r290 1 1 /+ 2 Copyright (c) 2006 Eric Anderton2 Copyright (c) 2006 Eric Anderton 3 3 4 Permission is hereby granted, free of charge, to any person5 obtaining a copy of this software and associated documentation6 files (the "Software"), to deal in the Software without7 restriction, including without limitation the rights to use,8 copy, modify, merge, publish, distribute, sublicense, and/or9 sell copies of the Software, and to permit persons to whom the10 Software is furnished to do so, subject to the following11 conditions: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 12 13 The above copyright notice and this permission notice shall be14 included in all copies or substantial portions of the Software.13 The above copyright notice and this permission notice shall be 14 included in all copies or substantial portions of the Software. 15 15 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES18 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT20 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,21 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR23 OTHER DEALINGS IN THE SOFTWARE.16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 OTHER DEALINGS IN THE SOFTWARE. 24 24 +/ 25 25 module enki.enki; … … 31 31 private import utils.ArgParser; 32 32 33 private import std.stdio; 34 private import std.file; 33 private import tango.io.FilePath; 34 private import tango.io.File; 35 private import tango.io.Console; 36 private import tango.io.Stdout; 35 37 36 char[] helpText = 37 `Enki - Frontend Parser Generator - V1.2 Build %d38 char[] helpText = 39 `Enki - Frontend Parser Generator - V1.2 Build {} 38 40 Copyright(c) 2006 Eric Anderton 39 41 … … 42 44 43 45 Usage: 44 enki <source ebnf file> { -switch }45 46 -f<file> Specify output filename 46 enki <source ebnf file> {{ -switch } 47 48 -f<file> Specify output filename 47 49 -b<file> Specify output ebnf filename 48 -t Test Mode (output everything to console)49 50 -t Test Mode (output everything to console) 51 50 52 The -b option is used primarily as a sanity check of 51 53 enki's internal workings. The generated output is … … 59 61 void main(char[][] args){ 60 62 if(args.length == 1){ 61 writefln(helpText,auto_build_number);63 Stdout.format(helpText,auto_build_number); 62 64 return 0; 63 65 } … … 98 100 throw new Exception("No filename specified."); 99 101 } 100 101 if(!isfile(inputFilename)){ 102 103 auto fp=FilePath(inputFilename); 104 if(!fp.exists || fp.isFolder){ 102 105 throw new Exception("File '" ~ inputFilename ~ "' doesn't exist."); 103 106 } … … 115 118 // run the Enki Parser 116 119 auto parser = new EnkiParser(); 117 parser.initalize(cast(char[]) std.file.read(inputFilename));120 parser.initalize(cast(char[])File(inputFilename).read); 118 121 auto result = parser.parse_Syntax(); 119 122 … … 122 125 123 126 if(testMode){ 124 writefln("Parser:\n %s",parser.render());127 Cout("Parser:\n ")(parser.render()); 125 128 } 126 129 else{ 127 std.file.write(outputFilename,parser.render());130 File(outputFilename).write(parser.render()); 128 131 } 129 132 130 133 if(ebnfFilename){ 131 134 if(testMode){ 132 writefln("\nBNF:\n %s",parser.toBNF());135 Cout("\nBNF:\n ")(parser.toBNF()); 133 136 } 134 137 else{ 135 std.file.write(ebnfFilename,parser.toBNF());138 File(ebnfFilename).write(parser.toBNF()); 136 139 } 137 140 } 138 141 } 139 142 else{ 140 writefln("\nErrors:\n%s",parser.getErrorReport());143 Cout("\nErrors:\n")(parser.getErrorReport()); 141 144 } 142 145 }
