annotate src/main.d @ 810:525ee3f848d9

Added modules cmd.Compile and dil.ModuleManager. Added options -I, -release and -unittest to the compile command. Tidied main.d up a bit. Renamed start() methods of SemanticPass1 and 2 to run(). Moved function findModuleFilePath() to class ModuleManager. Added msg CouldntLoadModule. Corrected two others. Added member semanticPass to class Module. Implemented visit(ImportDeclaration) in SemanticPass1.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Tue, 11 Mar 2008 02:48:01 +0100
parents 7e84472f4e91
children 5c29f1ebec9f
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;
618
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
8 import dil.lexer.Lexer,
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
9 dil.lexer.Token;
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
10 import dil.ast.Declarations,
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
11 dil.ast.Expressions,
635
b2fc028d8b55 Added class Visitor.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 631
diff changeset
12 dil.ast.Node,
b2fc028d8b55 Added class Visitor.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 631
diff changeset
13 dil.ast.Visitor;
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
14 import dil.semantic.Module;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
15 import dil.semantic.Symbols;
684
10b314bf37e3 Added module dil.semantic.Pass2.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 683
diff changeset
16 import dil.semantic.Pass1,
687
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 684
diff changeset
17 dil.semantic.Pass2,
f14cd41fc87d Added new module dil.semantic.Interpreter.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 684
diff changeset
18 dil.semantic.Interpreter;
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
19 import dil.translator.German;
676
c4e3a34e40f1 Added new module dil.doc.Doc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 672
diff changeset
20 import dil.doc.Doc;
327
a48a987f7515 - Added package dil to import declarations.
aziz
parents: 323
diff changeset
21 import dil.Messages;
464
325714d8aa6c Added new module with compiler constants to resolve import cycle.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 445
diff changeset
22 import dil.CompilerInfo;
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
23 import dil.Information;
755
90668b83ae5e Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 746
diff changeset
24 import dil.SourceText;
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
25 import dil.Compilation;
618
07946b379006 Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 596
diff changeset
26
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
27 import cmd.Compile;
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
28 import cmd.Highlight;
363
2b387a3c6b58 - Added package cmd.
aziz
parents: 358
diff changeset
29 import cmd.Statistics;
364
1059295c2727 - Every command module has an execute method now.
aziz
parents: 363
diff changeset
30 import cmd.ImportGraph;
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
31 import cmd.DDoc;
779
8e6fed11bb68 Moved Settings.d and SettingsLoader.d to src/.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 778
diff changeset
32
8e6fed11bb68 Moved Settings.d and SettingsLoader.d to src/.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 778
diff changeset
33 import Settings;
8e6fed11bb68 Moved Settings.d and SettingsLoader.d to src/.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 778
diff changeset
34 import SettingsLoader;
792
05dfe88dd3bb Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 780
diff changeset
35 // import TypeRules;
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
36 import common;
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
37
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
38 import Integer = tango.text.convert.Integer;
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
39 import tango.stdc.stdio;
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
40 import tango.io.File;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
41 import tango.text.Util;
575
dd3fe62c8a96 Compiles with Tango 0.99.4 now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 564
diff changeset
42 import tango.time.StopWatch;
746
32a8ddd330f8 Using icompare() instead of toLower().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 744
diff changeset
43 import tango.text.Ascii : icompare;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
44
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 794
diff changeset
45 /// Entry function of dil.
0
8ba2570de175 Initial import.
aziz
parents:
diff changeset
46 void main(char[][] args)
8ba2570de175 Initial import.
aziz
parents:
diff changeset
47 {
758
f4b9680c0e16 Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 756
diff changeset
48 auto infoMan = new InfoManager();
779
8e6fed11bb68 Moved Settings.d and SettingsLoader.d to src/.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 778
diff changeset
49 SettingsLoader.SettingsLoader(infoMan).load();
759
9c47f377ca0b Revised module cmd.Generate.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 758
diff changeset
50 if (infoMan.hasInfo)
758
f4b9680c0e16 Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 756
diff changeset
51 return printErrors(infoMan);
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 308
diff changeset
52
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
53 if (args.length <= 1)
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
54 return printHelp("main");
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
55
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
56 string command = args[1];
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
57 switch (command)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
58 {
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
59 case "c", "compile":
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
60 if (args.length < 3)
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
61 return printHelp(command);
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
62
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
63 CompileCommand cmd;
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
64 cmd.context = newCompilationContext();
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
65 cmd.infoMan = infoMan;
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
66
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
67 foreach (arg; args[2..$])
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
68 {
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
69 if (parseDebugOrVersion(arg, cmd.context))
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
70 {}
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
71 else if (strbeg(arg, "-I"))
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
72 cmd.context.importPaths ~= arg[2..$];
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
73 else if (arg == "-release")
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
74 cmd.context.releaseBuild = true;
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
75 else if (arg == "-unittest")
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
76 cmd.context.unittestBuild = true;
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
77 else
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
78 cmd.filePaths ~= arg;
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
79 }
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
80 cmd.run();
765
bc812843603c Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 764
diff changeset
81 infoMan.hasInfo && printErrors(infoMan);
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
82 break;
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
83 case "ddoc", "d":
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
84 if (args.length < 4)
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
85 return printHelp(command);
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
86
807
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
87 DDocCommand cmd;
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
88 cmd.destDirPath = args[2];
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
89 cmd.macroPaths = GlobalSettings.ddocFilePaths;
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
90 cmd.context = newCompilationContext();
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
91 cmd.infoMan = infoMan;
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
92
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
93 // Parse arguments.
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
94 foreach (arg; args[3..$])
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
95 {
807
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
96 if (parseDebugOrVersion(arg, cmd.context))
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
97 {}
800
dcd30b0ba711 Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 798
diff changeset
98 else if (arg == "--xml")
807
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
99 cmd.writeXML = true;
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
100 else if (arg == "-i")
807
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
101 cmd.includeUndocumented = true;
740
f3dead0310ce Added '-v' (verbose) option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 737
diff changeset
102 else if (arg == "-v")
807
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
103 cmd.verbose = true;
746
32a8ddd330f8 Using icompare() instead of toLower().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 744
diff changeset
104 else if (arg.length > 5 && icompare(arg[$-4..$], "ddoc") == 0)
807
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
105 cmd.macroPaths ~= arg;
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
106 else
807
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
107 cmd.filePaths ~= arg;
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
108 }
807
a2880c95eda3 Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 806
diff changeset
109 cmd.run();
765
bc812843603c Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 764
diff changeset
110 infoMan.hasInfo && printErrors(infoMan);
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
111 break;
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
112 case "hl", "highlight":
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
113 if (args.length < 3)
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
114 return printHelp(command);
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
115
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
116 HighlightCommand cmd;
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
117 cmd.infoMan = infoMan;
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
118
322
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
119 foreach (arg; args[2..$])
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
120 {
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
121 switch (arg)
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
122 {
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
123 case "--syntax":
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
124 cmd.add(HighlightCommand.Option.Syntax); break;
322
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
125 case "--xml":
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
126 cmd.add(HighlightCommand.Option.XML); break;
322
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
127 case "--html":
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
128 cmd.add(HighlightCommand.Option.HTML); break;
771
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
129 case "--lines":
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
130 cmd.add(HighlightCommand.Option.PrintLines); break;
322
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
131 default:
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
132 cmd.filePath = arg;
322
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
133 }
ed4ef0173793 - Moved out large TOK switch case to function printToken().
aziz
parents: 315
diff changeset
134 }
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
135 cmd.run();
765
bc812843603c Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 764
diff changeset
136 infoMan.hasInfo && printErrors(infoMan);
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
137 break;
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
138 case "importgraph", "igraph":
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
139 if (args.length < 3)
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
140 return printHelp(command);
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
141
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
142 IGraphCommand cmd;
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
143 cmd.context = newCompilationContext();
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
144
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
145 foreach (arg; args[2..$])
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
146 {
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
147 if (parseDebugOrVersion(arg, cmd.context))
780
edd217e14736 Using CompilationContext in command 'igraph'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 779
diff changeset
148 {}
edd217e14736 Using CompilationContext in command 'igraph'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 779
diff changeset
149 else if (strbeg(arg, "-I"))
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
150 cmd.context.importPaths ~= arg[2..$];
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
151 else if(strbeg(arg, "-x"))
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
152 cmd.regexps ~= arg[2..$];
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
153 else if(strbeg(arg, "-l"))
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
154 cmd.levels = Integer.toInt(arg[2..$]);
703
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
155 else if(strbeg(arg, "-si"))
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
156 cmd.siStyle = arg[3..$];
703
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
157 else if(strbeg(arg, "-pi"))
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
158 cmd.piStyle = arg[3..$];
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
159 else
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
160 switch (arg)
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
161 {
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
162 case "--dot":
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
163 cmd.add(IGraphCommand.Option.PrintDot); break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
164 case "--paths":
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
165 cmd.add(IGraphCommand.Option.PrintPaths); break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
166 case "--list":
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
167 cmd.add(IGraphCommand.Option.PrintList); break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
168 case "-i":
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
169 cmd.add(IGraphCommand.Option.IncludeUnlocatableModules); break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
170 case "-hle":
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
171 cmd.add(IGraphCommand.Option.HighlightCyclicEdges); break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
172 case "-hlv":
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
173 cmd.add(IGraphCommand.Option.HighlightCyclicVertices); break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
174 case "-gbp":
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
175 cmd.add(IGraphCommand.Option.GroupByPackageNames); break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
176 case "-gbf":
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
177 cmd.add(IGraphCommand.Option.GroupByFullPackageName); break;
427
e2bbc6406a14 Added a new option '-m' to the igraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 422
diff changeset
178 case "-m":
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
179 cmd.add(IGraphCommand.Option.MarkCyclicModules); break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
180 default:
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
181 cmd.filePath = arg;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
182 }
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
183 }
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
184 cmd.run();
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
185 break;
363
2b387a3c6b58 - Added package cmd.
aziz
parents: 358
diff changeset
186 case "stats", "statistics":
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
187 if (args.length < 3)
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
188 return printHelp(command);
545
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
189 char[][] filePaths;
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
190 bool printTokensTable;
672
d422e5f2f3ea Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
191 bool printNodesTable;
545
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
192 foreach (arg; args[2..$])
672
d422e5f2f3ea Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
193 if (arg == "--toktable")
545
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
194 printTokensTable = true;
672
d422e5f2f3ea Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
195 else if (arg == "--asttable")
d422e5f2f3ea Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
196 printNodesTable = true;
545
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
197 else
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
198 filePaths ~= arg;
672
d422e5f2f3ea Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
199 cmd.Statistics.execute(filePaths, printTokensTable, printNodesTable);
363
2b387a3c6b58 - Added package cmd.
aziz
parents: 358
diff changeset
200 break;
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
201 case "tok", "tokenize":
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
202 if (args.length < 3)
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
203 return printHelp(command);
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
204 SourceText sourceText;
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
205 char[] filePath;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
206 char[] separator;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
207 bool ignoreWSToks;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
208 bool printWS;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
209
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
210 foreach (arg; args[2..$])
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
211 {
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
212 if (strbeg(arg, "-s"))
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
213 separator = arg[2..$];
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
214 else if (arg == "-")
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
215 sourceText = new SourceText("stdin", readStdin());
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
216 else if (arg == "-i")
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
217 ignoreWSToks = true;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
218 else if (arg == "-ws")
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
219 printWS = true;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
220 else
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
221 filePath = arg;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
222 }
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
223
755
90668b83ae5e Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 746
diff changeset
224 separator || (separator = "\n");
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
225 if (!sourceText)
755
90668b83ae5e Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 746
diff changeset
226 sourceText = new SourceText(filePath, true);
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
227
758
f4b9680c0e16 Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 756
diff changeset
228 infoMan = new InfoManager();
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
229 auto lx = new Lexer(sourceText, infoMan);
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
230 lx.scanAll();
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
231 auto token = lx.firstToken();
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
232
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 676
diff changeset
233 for (; token.kind != TOK.EOF; token = token.next)
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
234 {
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 676
diff changeset
235 if (token.kind == TOK.Newline || ignoreWSToks && token.isWhitespace)
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
236 continue;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
237 if (printWS && token.ws)
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
238 Stdout(token.wsChars);
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
239 Stdout(token.srcText)(separator);
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
240 }
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
241
765
bc812843603c Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 764
diff changeset
242 infoMan.hasInfo && printErrors(infoMan);
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
243 break;
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
244 case "trans", "translate":
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
245 if (args.length < 3)
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
246 return printHelp(command);
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
247
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
248 if (args[2] != "German")
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
249 return Stdout.formatln("Error: unrecognized target language \"{}\"", args[2]);
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
250
758
f4b9680c0e16 Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 756
diff changeset
251 infoMan = new InfoManager();
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
252 auto filePath = args[3];
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
253 auto mod = new Module(filePath, infoMan);
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
254 // Parse the file.
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
255 mod.parse();
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
256 if (!mod.hasErrors)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
257 { // Translate
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
258 auto german = new GermanTranslator(Stdout, " ");
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
259 german.translate(mod.root);
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
260 }
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
261 printErrors(infoMan);
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
262 break;
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
263 case "profile":
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
264 if (args.length < 3)
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
265 break;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
266 char[][] filePaths;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
267 if (args[2] == "dstress")
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
268 {
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
269 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
270 filePaths = split(text, "\0");
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
271 }
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
272 else
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
273 filePaths = args[2..$];
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
274
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
275 StopWatch swatch;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
276 swatch.start;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
277
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
278 foreach (filePath; filePaths)
755
90668b83ae5e Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 746
diff changeset
279 (new Lexer(new SourceText(filePath, true))).scanAll();
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
280
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
281 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
282 break;
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
283 case "?", "help":
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
284 printHelp(args.length >= 3 ? args[2] : "");
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
285 break;
800
dcd30b0ba711 Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 798
diff changeset
286 // case "typerules":
dcd30b0ba711 Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 798
diff changeset
287 // genHTMLTypeRulesTables();
dcd30b0ba711 Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 798
diff changeset
288 // break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
289 default:
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
290 printHelp("main");
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
291 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
292 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
293
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
294 char[] readStdin()
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
295 {
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
296 char[] text;
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
297 while (1)
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
298 {
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
299 auto c = getc(stdin);
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
300 if (c == EOF)
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
301 break;
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
302 text ~= c;
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
303 }
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
304 return text;
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
305 }
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
306
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 794
diff changeset
307 /// Available commands.
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
308 const char[] COMMANDS =
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
309 " compile (c)\n"
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
310 " ddoc (d)\n"
363
2b387a3c6b58 - Added package cmd.
aziz
parents: 358
diff changeset
311 " help (?)\n"
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
312 " highlight (hl)\n"
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
313 " importgraph (igraph)\n"
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
314 " statistics (stats)\n"
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
315 " tokenize (tok)\n"
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
316 " translate (trans)\n";
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
317
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
318 bool strbeg(char[] str, char[] begin)
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
319 {
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
320 if (str.length >= begin.length)
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
321 {
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
322 if (str[0 .. begin.length] == begin)
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
323 return true;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
324 }
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
325 return false;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
326 }
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
327
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
328 /// Creates the global compilation context.
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
329 CompilationContext newCompilationContext()
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
330 {
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
331 auto cc = new CompilationContext;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
332 cc.importPaths = GlobalSettings.importPaths;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
333 cc.addVersionId("dil");
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
334 cc.addVersionId("all");
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
335 version(D2)
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
336 cc.addVersionId("D_Version2");
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
337 foreach (versionId; GlobalSettings.versionIds)
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
338 if (!Lexer.isReservedIdentifier(versionId))
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
339 cc.versionIds[versionId] = true;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
340 return cc;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
341 }
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
342
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
343 bool parseDebugOrVersion(string arg, CompilationContext context)
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
344 {
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
345 if (strbeg(arg, "-debug"))
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
346 {
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
347 if (arg.length > 7)
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
348 {
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
349 auto val = arg[7..$];
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
350 if (isdigit(val[0]))
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
351 context.debugLevel = Integer.toInt(val);
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
352 else if (!Lexer.isReservedIdentifier(val))
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
353 context.addDebugId(val);
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
354 }
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
355 else
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
356 context.debugLevel = 1;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
357 }
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
358 else if (arg.length > 9 && strbeg(arg, "-version="))
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
359 {
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
360 auto val = arg[9..$];
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
361 if (isdigit(val[0]))
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
362 context.versionLevel = Integer.toInt(val);
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
363 else if (!Lexer.isReservedIdentifier(val))
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
364 context.addVersionId(val);
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
365 }
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
366 else
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
367 return false;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
368 return true;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
369 }
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
370
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 794
diff changeset
371 /// Prints the errors collected in infoMan.
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
372 void printErrors(InfoManager infoMan)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
373 {
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
374 foreach (info; infoMan.info)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
375 {
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
376 char[] errorFormat;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
377 if (info.classinfo is LexerError.classinfo)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
378 errorFormat = GlobalSettings.lexerErrorFormat;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
379 else if (info.classinfo is ParserError.classinfo)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
380 errorFormat = GlobalSettings.parserErrorFormat;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
381 else if (info.classinfo is SemanticError.classinfo)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
382 errorFormat = GlobalSettings.semanticErrorFormat;
744
7173ece1b696 Wrapped some macro functions inside struct MacroExpander.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 740
diff changeset
383 else if (info.classinfo is Warning.classinfo)
7173ece1b696 Wrapped some macro functions inside struct MacroExpander.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 740
diff changeset
384 errorFormat = "{0}: Warning: {3}";
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
385 else
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
386 continue;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
387 auto err = cast(Problem)info;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
388 Stderr.formatln(errorFormat, err.filePath, err.loc, err.col, err.getMsg);
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
389 }
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
390 }
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
391
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 794
diff changeset
392 /// Prints a help message for command.
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
393 void printHelp(char[] command)
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
394 {
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
395 char[] msg;
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
396 switch (command)
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
397 {
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
398 case "c", "compile":
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
399 msg = `Compile D source files.
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
400 Usage:
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
401 dil compile file.d [file2.d, ...] [Options]
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
402
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
403 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
404 Errors are printed to standard error output.
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
405
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
406 Options:
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
407 -debug : include debug code
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
408 -debug=level : include debug(l) code where l <= level
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
409 -debug=ident : include debug(ident) code
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
410 -version=level : include version(l) code where l >= level
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
411 -version=ident : include version(ident) code
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
412 -Ipath : add 'path' to the list of import paths
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
413 -release : compile a release build
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
414 -unittest : compile a unittest build
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
415
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
416 Example:
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
417 dil c src/main.d -Isrc/`;
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
418 break;
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
419 case "ddoc", "d":
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
420 msg = `Generate documentation from DDoc comments in D source files.
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
421 Usage:
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
422 dil ddoc Destination file.d [file2.d, ...] [Options]
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
423
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
424 Destination is the folder where the documentation files are written to.
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
425 Files with the extension .ddoc are recognized as macro definition files.
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
426
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
427 Options:
800
dcd30b0ba711 Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 798
diff changeset
428 --xml : write XML instead of HTML documents
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
429 -i : include undocumented symbols
740
f3dead0310ce Added '-v' (verbose) option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 737
diff changeset
430 -v : verbose output
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
431
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
432 Example:
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
433 dil d doc/ src/main.d src/macros_dil.ddoc -i`;
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
434 break;
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
435 case "hl", "highlight":
771
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
436 // msg = GetMsg(MID.HelpGenerate);
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
437 msg = `Highlight a D source file with XML or HTML tags.
771
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
438 Usage:
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
439 dil hl file.d [Options]
771
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
440
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
441 Options:
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
442 --syntax : generate tags for the syntax tree
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
443 --xml : use XML format (default)
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
444 --html : use HTML format
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
445 --lines : print line numbers
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
446
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
447 Example:
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
448 dil hl Parser.d --html --syntax > Parser.html`;
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
449 break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
450 case "importgraph", "igraph":
703
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
451 // msg = GetMsg(MID.HelpImportGraph);
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
452 msg = `Parse a module and build a module dependency graph based on its imports.
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
453 Usage:
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
454 dil igraph file.d Format [Options]
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
455
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
456 The directory of file.d is implicitly added to the list of import paths.
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
457
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
458 Format:
792
05dfe88dd3bb Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 780
diff changeset
459 --dot : generate a dot document (default)
703
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
460 Options related to --dot:
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
461 -gbp : Group modules by package names
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
462 -gbf : Group modules by full package name
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
463 -hle : highlight cyclic edges in the graph
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
464 -hlv : highlight modules in cyclic relationships
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
465 -siSTYLE : the edge style to use for static imports
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
466 -piSTYLE : the edge style to use for public imports
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
467 STYLE can be: "dashed", "dotted", "solid", "invis" or "bold"
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
468
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
469 --paths : print the file paths of the modules in the graph
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
470
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
471 --list : print the names of the module in the graph
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
472 Options common to --paths and --list:
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
473 -lN : print N levels.
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
474 -m : use '*' to mark modules in cyclic relationships
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
475
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
476 Options:
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
477 -Ipath : add 'path' to the list of import paths where modules are
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
478 looked for
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
479 -xREGEXP : exclude modules whose names match the regular expression
703
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
480 REGEXP
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
481 -i : include unlocatable modules
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
482
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
483 Example:
792
05dfe88dd3bb Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 780
diff changeset
484 dil igraph src/main.d --list
05dfe88dd3bb Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 780
diff changeset
485 dil igraph src/main.d | dot -Tpng > main.png`;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
486 break;
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
487 case "tok", "tokenize":
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
488 msg = `Print the tokens of a D source file.
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
489 Usage:
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
490 dil tok file.d [Options]
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
491
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
492 Options:
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
493 - : reads text from the standard input.
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
494 -sSEPARATOR : print SEPARATOR instead of newline between tokens.
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
495 -i : ignore whitespace tokens (e.g. comments, shebang etc.)
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
496 -ws : print a token's preceding whitespace characters.
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
497
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
498 Example:
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
499 echo "module foo; void func(){}" | dil tok -
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
500 dil tok main.d | grep ^[0-9]`;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
501 break;
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
502 case "stats", "statistics":
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
503 msg = "Gather statistics about D source files.
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
504 Usage:
545
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
505 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
506
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
507 Options:
672
d422e5f2f3ea Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
508 --toktable : print the count of all kinds of tokens in a table.
d422e5f2f3ea Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
509 --asttable : print the count of all kinds of nodes in a table.
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
510
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
511 Example:
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
512 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
513 break;
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
514 case "trans", "translate":
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
515 msg = `Translate a D source file to another language.
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
516 Usage:
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
517 dil translate Language file.d
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
518
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
519 Languages that are supported:
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
520 *) German
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
521
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
522 Example:
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
523 dil trans German src/main.d`;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
524 break;
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
525 case "main":
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
526 default:
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
527 auto COMPILED_WITH = __VENDOR__;
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
528 auto COMPILED_VERSION = Format("{}.{,:d3}", __VERSION__/1000, __VERSION__%1000);
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
529 auto COMPILED_DATE = __TIMESTAMP__;
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
530 msg = FormatMsg(MID.HelpMain, VERSION, COMMANDS, COMPILED_WITH,
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
531 COMPILED_VERSION, COMPILED_DATE);
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
532 }
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
533 Stdout(msg).newline;
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
534 }