comparison trunk/src/main.d @ 391:33b566df6af4

Migrated project to Tango. Decremented the numbers of the format placeholders in the localized messages by one. Replaced all instances of writef/ln with Stdout. Added module common.d with string aliases and a global Layout!(char) instance. Replaced %s format specifiers with index placeholders in html/xml_tags. Changed member Information.arguments to string message. Copied std.metastring, std.uni and std.utf from Phobos.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 15 Sep 2007 17:12:26 +0200
parents 0bd21b746a04
children bb935c6f9b7a
comparison
equal deleted inserted replaced
390:4d36eea1bbc9 391:33b566df6af4
11 import dil.Declarations, dil.Expressions, dil.SyntaxTree; 11 import dil.Declarations, dil.Expressions, dil.SyntaxTree;
12 import dil.File; 12 import dil.File;
13 import cmd.Generate; 13 import cmd.Generate;
14 import cmd.Statistics; 14 import cmd.Statistics;
15 import cmd.ImportGraph; 15 import cmd.ImportGraph;
16 import std.stdio, std.conv; 16 import common;
17
18 import Integer = tango.text.convert.Integer;
17 19
18 void main(char[][] args) 20 void main(char[][] args)
19 { 21 {
20 GlobalSettings.load(); 22 GlobalSettings.load();
21 23
22 if (args.length <= 1) 24 if (args.length <= 1)
23 return writefln(helpMain()); 25 return Stdout(helpMain()).newline;
24 26
25 string command = args[1]; 27 string command = args[1];
26 switch (command) 28 switch (command)
27 { 29 {
28 case "gen", "generate": 30 case "gen", "generate":
57 if (strbeg(arg, "-I")) 59 if (strbeg(arg, "-I"))
58 includePaths ~= arg[2..$]; 60 includePaths ~= arg[2..$];
59 else if(strbeg(arg, "-r")) 61 else if(strbeg(arg, "-r"))
60 regexps ~= arg[2..$]; 62 regexps ~= arg[2..$];
61 else if(strbeg(arg, "-l")) 63 else if(strbeg(arg, "-l"))
62 levels = toUint(arg[2..$]); 64 levels = Integer.parse (arg[2..$]);
63 else 65 else
64 switch (arg) 66 switch (arg)
65 { 67 {
66 case "--dot": 68 case "--dot":
67 options |= IGraphOption.PrintDot; break; 69 options |= IGraphOption.PrintDot; break;
94 break; 96 break;
95 case "?", "help": 97 case "?", "help":
96 if (args.length == 3) 98 if (args.length == 3)
97 printHelp(args[2]); 99 printHelp(args[2]);
98 else 100 else
99 writefln(helpMain()); 101 Stdout(helpMain());
100 break; 102 break;
101 default: 103 default:
102 } 104 }
103 } 105 }
104 106
118 return false; 120 return false;
119 } 121 }
120 122
121 char[] helpMain() 123 char[] helpMain()
122 { 124 {
123 return format(MID.HelpMain, VERSION, COMMANDS, COMPILED_WITH, COMPILED_VERSION, COMPILED_DATE); 125 return FormatMsg(MID.HelpMain, VERSION, COMMANDS, COMPILED_WITH, COMPILED_VERSION, COMPILED_DATE);
124 } 126 }
125 127
126 void printHelp(char[] command) 128 void printHelp(char[] command)
127 { 129 {
128 char[] msg; 130 char[] msg;
135 msg = GetMsg(MID.HelpImportGraph); 137 msg = GetMsg(MID.HelpImportGraph);
136 break; 138 break;
137 default: 139 default:
138 msg = helpMain(); 140 msg = helpMain();
139 } 141 }
140 writefln(msg); 142 Stdout(msg).newline;
141 } 143 }
142 144
143 void parse(string fileName) 145 void parse(string fileName)
144 { 146 {
145 auto sourceText = loadFile(fileName); 147 auto sourceText = loadFile(fileName);
156 } 158 }
157 } 159 }
158 print(root.children, ""); 160 print(root.children, "");
159 foreach (error; parser.errors) 161 foreach (error; parser.errors)
160 { 162 {
161 writefln(`%s(%d)P: %s`, parser.lx.fileName, error.loc, error.getMsg); 163 Stdout.format(`{0}({1})P: {2}`, parser.lx.fileName, error.loc, error.getMsg);
162 } 164 }
163 } 165 }