annotate trunk/src/main.d @ 631:2feb88f5c867

Added dil.parser.ExpressionParser and dil.parser.Factory.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 12 Jan 2008 01:56:04 +0100
parents 07946b379006
children b2fc028d8b55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8ba2570de175 Initial import.
aziz
parents:
diff changeset
1 /++
8ba2570de175 Initial import.
aziz
parents:
diff changeset
2 Author: Aziz Köksal
249
32d354584b28 - Upgraded license notices to GPL3.
aziz
parents: 213
diff changeset
3 License: GPL3
0
8ba2570de175 Initial import.
aziz
parents:
diff changeset
4 +/
347
73f81f21f870 - Changed module name of main.d from dparser to main.
aziz
parents: 343
diff changeset
5 module main;
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
6
578
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 576
diff changeset
7 import dil.parser.Parser;
631
2feb88f5c867 Added dil.parser.ExpressionParser and dil.parser.Factory.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 618
diff changeset
8 import dil.parser.Factory;
618
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
9 import dil.lexer.Lexer,
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
10 dil.lexer.Token;
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
11 import dil.ast.Declarations,
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
12 dil.ast.Expressions,
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
13 dil.ast.Node;
327
a48a987f7515 - Added package dil to import declarations.
aziz
parents: 323
diff changeset
14 import dil.Messages;
a48a987f7515 - Added package dil to import declarations.
aziz
parents: 323
diff changeset
15 import dil.Settings;
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
16 import dil.SettingsLoader;
464
325714d8aa6c Added new module with compiler constants to resolve import cycle.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 445
diff changeset
17 import dil.CompilerInfo;
593
2848ce3becf5 Moved dil.Module to dil.semantic.Module.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 586
diff changeset
18 import dil.semantic.Module;
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
19 import dil.Information;
351
97a9a2d7d46d - Added module File.
aziz
parents: 347
diff changeset
20 import dil.File;
618
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
21 import dil.semantic.Symbols;
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
22
363
2b387a3c6b58 - Added package cmd.
aziz
parents: 358
diff changeset
23 import cmd.Generate;
2b387a3c6b58 - Added package cmd.
aziz
parents: 358
diff changeset
24 import cmd.Statistics;
364
1059295c2727 - Every command module has an execute method now.
aziz
parents: 363
diff changeset
25 import cmd.ImportGraph;
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
26 import common;
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
27
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
28 import Integer = tango.text.convert.Integer;
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
29 import tango.io.File;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
30 import tango.text.Util;
575
dd3fe62c8a96 Compiles with Tango 0.99.4 now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 564
diff changeset
31 import tango.time.StopWatch;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
32
0
8ba2570de175 Initial import.
aziz
parents:
diff changeset
33 void main(char[][] args)
8ba2570de175 Initial import.
aziz
parents:
diff changeset
34 {
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
35 dil.SettingsLoader.loadSettings();
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 308
diff changeset
36
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
37 if (args.length <= 1)
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
38 return Stdout(helpMain()).newline;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
39
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
40 string command = args[1];
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
41 switch (command)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
42 {
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
43 case "c", "compile":
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
44 if (args.length < 2)
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
45 return printHelp("compile");
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
46
532
50e64bab9c7a Renamed InformationManager to InfoManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 520
diff changeset
47 auto infoMan = new InfoManager();
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
48 auto filePaths = args[2..$];
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
49 foreach (filePath; filePaths)
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
50 {
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
51 auto mod = new Module(filePath, infoMan);
564
3c867a683258 Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 545
diff changeset
52 // Parse the file.
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
53 mod.parse();
564
3c867a683258 Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 545
diff changeset
54 // Start semantic analysis.
3c867a683258 Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 545
diff changeset
55 mod.semantic();
618
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
56
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
57 void printSymbolTable(ScopeSymbol scopeSym)
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
58 {
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
59 foreach (member; scopeSym.members)
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
60 {
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
61 auto tokens = member.node.getDocComments();
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
62 char[] docText;
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
63 foreach (token; tokens)
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
64 docText ~= token.srcText;
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
65 Stdout.formatln("Id:{}, Symbol:{}, DocText:{}", member.ident.str, member.classinfo.name, docText);
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
66 }
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
67 }
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
68
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
69 printSymbolTable(mod);
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
70 }
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
71
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
72 foreach (info; infoMan.info)
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
73 {
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
74 char[] errorFormat;
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
75 if (info.classinfo is LexerError.classinfo)
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
76 errorFormat = GlobalSettings.lexerErrorFormat;
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
77 else if (info.classinfo is ParserError.classinfo)
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
78 errorFormat = GlobalSettings.parserErrorFormat;
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
79 else if (info.classinfo is SemanticError.classinfo)
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
80 errorFormat = GlobalSettings.semanticErrorFormat;
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
81 else
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
82 continue;
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
83 auto err = cast(Problem)info;
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
84 Stderr.formatln(errorFormat, err.filePath, err.loc, err.col, err.getMsg);
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
85 }
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
86 break;
329
17f43b0d6106 - Renamed command highlight to generate.
aziz
parents: 328
diff changeset
87 case "gen", "generate":
322
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
88 char[] fileName;
329
17f43b0d6106 - Renamed command highlight to generate.
aziz
parents: 328
diff changeset
89 DocOption options = DocOption.Tokens;
322
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
90 foreach (arg; args[2..$])
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
91 {
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
92 switch (arg)
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
93 {
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
94 case "--syntax":
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
95 options |= DocOption.Syntax; break;
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
96 case "--xml":
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
97 options |= DocOption.XML; break;
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
98 case "--html":
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
99 options |= DocOption.HTML; break;
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
100 default:
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
101 fileName = arg;
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
102 }
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
103 }
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
104 if (!(options & (DocOption.XML | DocOption.HTML)))
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
105 options |= DocOption.XML; // Default to XML.
364
1059295c2727 - Every command module has an execute method now.
aziz
parents: 363
diff changeset
106 cmd.Generate.execute(fileName, options);
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
107 break;
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
108 case "importgraph", "igraph":
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
109 string filePath;
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
110 string[] includePaths;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
111 string[] regexps;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
112 uint levels;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
113 IGraphOption options;
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
114 foreach (arg; args[2..$])
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
115 {
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
116 if (strbeg(arg, "-I"))
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
117 includePaths ~= arg[2..$];
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
118 else if(strbeg(arg, "-r"))
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
119 regexps ~= arg[2..$];
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
120 else if(strbeg(arg, "-l"))
392
bb935c6f9b7a Applied fixes and improvements to the Lexer class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 391
diff changeset
121 levels = Integer.toInt(arg[2..$]);
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
122 else
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
123 switch (arg)
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
124 {
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
125 case "--dot":
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
126 options |= IGraphOption.PrintDot; break;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
127 case "--paths":
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
128 options |= IGraphOption.PrintPaths; break;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
129 case "--list":
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
130 options |= IGraphOption.PrintList; break;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
131 case "-i":
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
132 options |= IGraphOption.IncludeUnlocatableModules; break;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
133 case "-hle":
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
134 options |= IGraphOption.HighlightCyclicEdges; break;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
135 case "-hlv":
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
136 options |= IGraphOption.HighlightCyclicVertices; break;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
137 case "-gbp":
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
138 options |= IGraphOption.GroupByPackageNames; break;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
139 case "-gbf":
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
140 options |= IGraphOption.GroupByFullPackageName; break;
427
e2bbc6406a14 Added a new option '-m' to the igraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 422
diff changeset
141 case "-m":
e2bbc6406a14 Added a new option '-m' to the igraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 422
diff changeset
142 options |= IGraphOption.MarkCyclicModules; break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
143 default:
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
144 filePath = arg;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
145 }
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
146 }
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
147 cmd.ImportGraph.execute(filePath, includePaths, regexps, levels, options);
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
148 break;
363
2b387a3c6b58 - Added package cmd.
aziz
parents: 358
diff changeset
149 case "stats", "statistics":
545
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
150 char[][] filePaths;
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
151 bool printTokensTable;
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
152 foreach (arg; args[2..$])
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
153 if (arg == "--table")
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
154 printTokensTable = true;
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
155 else
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
156 filePaths ~= arg;
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
157 cmd.Statistics.execute(filePaths, printTokensTable);
363
2b387a3c6b58 - Added package cmd.
aziz
parents: 358
diff changeset
158 break;
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
159 case "tok", "tokenize":
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
160 char[] filePath;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
161 char[] sourceText;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
162 char[] separator;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
163 bool ignoreWSToks;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
164 bool printWS;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
165
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
166 foreach (arg; args[2..$])
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
167 {
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
168 if (strbeg(arg, "-t"))
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
169 sourceText = arg[2..$];
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
170 else if (strbeg(arg, "-s"))
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
171 separator = arg[2..$];
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
172 else if (arg == "-i")
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
173 ignoreWSToks = true;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
174 else if (arg == "-ws")
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
175 printWS = true;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
176 else
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
177 filePath = arg;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
178 }
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
179
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
180 separator || (separator = "\n");
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
181 sourceText || (sourceText = loadFile(filePath));
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
182
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
183 auto lx = new Lexer(sourceText, null);
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
184 lx.scanAll();
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
185 auto token = lx.firstToken();
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
186
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
187 for (; token.type != TOK.EOF; token = token.next)
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
188 {
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
189 if (token.type == TOK.Newline || ignoreWSToks && token.isWhitespace)
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
190 continue;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
191 if (printWS && token.ws)
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
192 Stdout(token.wsChars);
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
193 Stdout(token.srcText)(separator);
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
194 }
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
195 break;
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
196 case "profile":
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
197 if (args.length < 3)
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
198 break;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
199 char[][] filePaths;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
200 if (args[2] == "dstress")
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
201 {
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
202 auto text = cast(char[])(new File("dstress_files")).read();
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
203 filePaths = split(text, "\0");
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
204 }
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
205 else
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
206 filePaths = args[2..$];
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
207
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
208 StopWatch swatch;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
209 swatch.start;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
210
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
211 foreach (filePath; filePaths)
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
212 (new Lexer(loadFile(filePath), null)).scanAll();
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
213
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
214 Stdout.formatln("Scanned in {:f10}s.", swatch.stop);
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
215 break;
312
fa0b6f32c1ae - Added Special to enum TOK.
aziz
parents: 309
diff changeset
216 case "parse":
fa0b6f32c1ae - Added Special to enum TOK.
aziz
parents: 309
diff changeset
217 if (args.length == 3)
fa0b6f32c1ae - Added Special to enum TOK.
aziz
parents: 309
diff changeset
218 parse(args[2]);
fa0b6f32c1ae - Added Special to enum TOK.
aziz
parents: 309
diff changeset
219 break;
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
220 case "?", "help":
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
221 printHelp(args.length >= 3 ? args[2] : "");
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
222 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
223 default:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
224 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
225 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
226
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
227 const char[] COMMANDS =
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
228 " compile (c)\n"
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
229 " generate (gen)\n"
363
2b387a3c6b58 - Added package cmd.
aziz
parents: 358
diff changeset
230 " help (?)\n"
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
231 " importgraph (igraph)\n"
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
232 " statistics (stats)\n"
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
233 " tokenize (tok)\n";
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
234
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
235 bool strbeg(char[] str, char[] begin)
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
236 {
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
237 if (str.length >= begin.length)
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
238 {
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
239 if (str[0 .. begin.length] == begin)
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
240 return true;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
241 }
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
242 return false;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
243 }
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
244
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
245 char[] helpMain()
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
246 {
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
247 return FormatMsg(MID.HelpMain, VERSION, COMMANDS, COMPILED_WITH, COMPILED_VERSION, COMPILED_DATE);
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
248 }
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
249
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
250 void printHelp(char[] command)
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
251 {
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
252 char[] msg;
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
253 switch (command)
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
254 {
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
255 case "c", "compile":
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
256 msg = "Compile D source files.
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
257 Usage:
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
258 dil compile file.d [file2.d, ...] [Options]
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
259
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
260 This command only parses the source files and does little semantic analysis.
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
261 Errors are printed to standard error output.
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
262
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
263 Options:
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
264
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
265 Example:
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
266 dil c src/main.d";
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
267 break;
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
268 case "gen", "generate":
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
269 msg = GetMsg(MID.HelpGenerate);
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
270 break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
271 case "importgraph", "igraph":
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
272 msg = GetMsg(MID.HelpImportGraph);
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
273 break;
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
274 case "tok", "tokenize":
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
275 msg = `Print the tokens of a D source file.
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
276 Usage:
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
277 dil tok file.d [Options]
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
278
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
279 Options:
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
280 -tTEXT : tokenize TEXT instead of a file.
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
281 -sSEPARATOR : print SEPARATOR instead of newline between tokens.
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
282 -i : ignore whitespace tokens (e.g. comments, shebang etc.)
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
283 -ws : print a token's preceding whitespace characters.
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
284
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
285 Example:
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
286 dil tok -t"module foo; void func(){}"
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
287 dil tok main.d | grep ^[0-9]`;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
288 break;
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
289 case "stats", "statistics":
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
290 msg = "Gather statistics about D source files.
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
291 Usage:
545
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
292 dil stat file.d [file2.d, ...] [Options]
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
293
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
294 Options:
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
295 --table : print the count of all types of tokens in a table.
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
296
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
297 Example:
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
298 dil stat src/dil/Parser.d src/dil/Lexer.d";
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
299 break;
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
300 default:
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
301 msg = helpMain();
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
302 }
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
303 Stdout(msg).newline;
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
304 }
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
305
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
306 void parse(string fileName)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
307 {
578
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 576
diff changeset
308 auto mod = new Module(fileName);
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 576
diff changeset
309 mod.parse();
299
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
310
578
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 576
diff changeset
311 void print(Node[] decls, char[] indent)
299
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
312 {
578
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 576
diff changeset
313 foreach(decl; decls)
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 576
diff changeset
314 {
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 576
diff changeset
315 assert(decl !is null);
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 576
diff changeset
316 Stdout.formatln("{}{}: begin={} end={}", indent, decl.classinfo.name, decl.begin ? decl.begin.srcText : "\33[31mnull\33[0m", decl.end ? decl.end.srcText : "\33[31mnull\33[0m");
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 576
diff changeset
317 print(decl.children, indent ~ " ");
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 576
diff changeset
318 }
299
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
319 }
578
c769bc239006 Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 576
diff changeset
320 print(mod.root.children, "");
299
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
321 }