comparison trunk/src/main.d @ 513:6160ab7b1816

Refactored code related to settings.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Fri, 14 Dec 2007 19:08:21 +0100
parents bccca748d745
children f203c5248d0b
comparison
equal deleted inserted replaced
512:112c17300069 513:6160ab7b1816
1 /++ 1 /++
2 Author: Aziz Köksal 2 Author: Aziz Köksal
3 License: GPL3 3 License: GPL3
4 +/ 4 +/
5 module main; 5 module main;
6
6 import dil.Parser; 7 import dil.Parser;
7 import dil.Lexer; 8 import dil.Lexer;
8 import dil.Token; 9 import dil.Token;
9 import dil.Messages; 10 import dil.Messages;
10 import dil.Settings; 11 import dil.Settings;
12 import dil.SettingsLoader;
11 import dil.CompilerInfo; 13 import dil.CompilerInfo;
12 import dil.Declarations, dil.Expressions, dil.SyntaxTree; 14 import dil.Declarations, dil.Expressions, dil.SyntaxTree;
13 import dil.File; 15 import dil.File;
14 import cmd.Generate; 16 import cmd.Generate;
15 import cmd.Statistics; 17 import cmd.Statistics;
16 import cmd.ImportGraph; 18 import cmd.ImportGraph;
17 import common; 19 import common;
18 20
19 import Integer = tango.text.convert.Integer; 21 import Integer = tango.text.convert.Integer;
22 import tango.io.File;
23 import tango.text.Util;
24 import tango.util.time.StopWatch;
20 25
21 void main(char[][] args) 26 void main(char[][] args)
22 { 27 {
23 GlobalSettings.load(); 28 dil.SettingsLoader.loadSettings();
24 29
25 if (args.length <= 1) 30 if (args.length <= 1)
26 return Stdout(helpMain()).newline; 31 return Stdout(helpMain()).newline;
27 32
28 string command = args[1]; 33 string command = args[1];
128 if (printWS && token.ws) 133 if (printWS && token.ws)
129 Stdout(token.wsChars); 134 Stdout(token.wsChars);
130 Stdout(token.srcText)(separator); 135 Stdout(token.srcText)(separator);
131 } 136 }
132 break; 137 break;
138 case "profile":
139 if (args.length < 3)
140 break;
141 char[][] filePaths;
142 if (args[2] == "dstress")
143 {
144 auto text = cast(char[])(new File("dstress_files")).read();
145 filePaths = split(text, "\0");
146 }
147 else
148 filePaths = args[2..$];
149
150 StopWatch swatch;
151 swatch.start;
152
153 foreach (filePath; filePaths)
154 (new Lexer(loadFile(filePath), null)).scanAll();
155
156 Stdout.formatln("Scanned in {:f10}s.", swatch.stop);
157 break;
133 case "parse": 158 case "parse":
134 if (args.length == 3) 159 if (args.length == 3)
135 parse(args[2]); 160 parse(args[2]);
136 break; 161 break;
137 case "?", "help": 162 case "?", "help":
190 215
191 Example: 216 Example:
192 dil tok -t"module foo; void func(){}" 217 dil tok -t"module foo; void func(){}"
193 dil tok main.d | grep ^[0-9]`; 218 dil tok main.d | grep ^[0-9]`;
194 break; 219 break;
220 case "stats", "statistics":
221 msg = "Gather statistics about D source files.
222 Usage:
223 dil stat file.d [file2.d, ...]
224
225 Example:
226 dil stat src/dil/Parser.d src/dil/Lexer.d";
227 break;
195 default: 228 default:
196 msg = helpMain(); 229 msg = helpMain();
197 } 230 }
198 Stdout(msg).newline; 231 Stdout(msg).newline;
199 } 232 }