annotate src/main.d @ 814:49e32b5bc161

Added isValidUnreservedIdentifier() to Lexer. Added the msg InvalidModuleName.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 12 Mar 2008 17:01:27 +0100
parents 5c29f1ebec9f
children 35d238d502cb
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);
811
5c29f1ebec9f Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 810
diff changeset
189
5c29f1ebec9f Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 810
diff changeset
190 StatsCommand cmd;
545
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
191 foreach (arg; args[2..$])
672
d422e5f2f3ea Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
192 if (arg == "--toktable")
811
5c29f1ebec9f Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 810
diff changeset
193 cmd.printTokensTable = true;
672
d422e5f2f3ea Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
194 else if (arg == "--asttable")
811
5c29f1ebec9f Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 810
diff changeset
195 cmd.printNodesTable = true;
545
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
196 else
811
5c29f1ebec9f Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 810
diff changeset
197 cmd.filePaths ~= arg;
5c29f1ebec9f Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 810
diff changeset
198 cmd.run();
363
2b387a3c6b58 - Added package cmd.
aziz
parents: 358
diff changeset
199 break;
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
200 case "tok", "tokenize":
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
201 if (args.length < 3)
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
202 return printHelp(command);
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
203 SourceText sourceText;
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
204 char[] filePath;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
205 char[] separator;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
206 bool ignoreWSToks;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
207 bool printWS;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
208
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
209 foreach (arg; args[2..$])
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
210 {
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
211 if (strbeg(arg, "-s"))
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
212 separator = arg[2..$];
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
213 else if (arg == "-")
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
214 sourceText = new SourceText("stdin", readStdin());
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
215 else if (arg == "-i")
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
216 ignoreWSToks = true;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
217 else if (arg == "-ws")
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
218 printWS = true;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
219 else
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
220 filePath = arg;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
221 }
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
222
755
90668b83ae5e Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 746
diff changeset
223 separator || (separator = "\n");
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
224 if (!sourceText)
755
90668b83ae5e Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 746
diff changeset
225 sourceText = new SourceText(filePath, true);
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
226
758
f4b9680c0e16 Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 756
diff changeset
227 infoMan = new InfoManager();
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
228 auto lx = new Lexer(sourceText, infoMan);
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
229 lx.scanAll();
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
230 auto token = lx.firstToken();
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
231
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 676
diff changeset
232 for (; token.kind != TOK.EOF; token = token.next)
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
233 {
679
ff6971637f88 Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 676
diff changeset
234 if (token.kind == TOK.Newline || ignoreWSToks && token.isWhitespace)
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
235 continue;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
236 if (printWS && token.ws)
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
237 Stdout(token.wsChars);
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
238 Stdout(token.srcText)(separator);
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
239 }
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
240
765
bc812843603c Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 764
diff changeset
241 infoMan.hasInfo && printErrors(infoMan);
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
242 break;
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
243 case "trans", "translate":
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
244 if (args.length < 3)
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
245 return printHelp(command);
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
246
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
247 if (args[2] != "German")
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
248 return Stdout.formatln("Error: unrecognized target language \"{}\"", args[2]);
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
249
758
f4b9680c0e16 Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 756
diff changeset
250 infoMan = new InfoManager();
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
251 auto filePath = args[3];
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
252 auto mod = new Module(filePath, infoMan);
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
253 // Parse the file.
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
254 mod.parse();
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
255 if (!mod.hasErrors)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
256 { // Translate
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
257 auto german = new GermanTranslator(Stdout, " ");
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
258 german.translate(mod.root);
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
259 }
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
260 printErrors(infoMan);
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
261 break;
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
262 case "profile":
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
263 if (args.length < 3)
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
264 break;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
265 char[][] filePaths;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
266 if (args[2] == "dstress")
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
267 {
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
268 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
269 filePaths = split(text, "\0");
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
270 }
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
271 else
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
272 filePaths = args[2..$];
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
273
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
274 StopWatch swatch;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
275 swatch.start;
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
276
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
277 foreach (filePath; filePaths)
755
90668b83ae5e Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 746
diff changeset
278 (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
279
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
280 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
281 break;
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
282 case "?", "help":
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
283 printHelp(args.length >= 3 ? args[2] : "");
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
284 break;
800
dcd30b0ba711 Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 798
diff changeset
285 // case "typerules":
dcd30b0ba711 Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 798
diff changeset
286 // genHTMLTypeRulesTables();
dcd30b0ba711 Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 798
diff changeset
287 // break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
288 default:
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
289 printHelp("main");
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
290 }
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
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
293 char[] readStdin()
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
294 {
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
295 char[] text;
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
296 while (1)
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
297 {
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
298 auto c = getc(stdin);
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
299 if (c == EOF)
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
300 break;
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
301 text ~= c;
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
302 }
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
303 return text;
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
304 }
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
305
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 794
diff changeset
306 /// Available commands.
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
307 const char[] COMMANDS =
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
308 " compile (c)\n"
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
309 " ddoc (d)\n"
363
2b387a3c6b58 - Added package cmd.
aziz
parents: 358
diff changeset
310 " help (?)\n"
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
311 " highlight (hl)\n"
366
dcbd3bf9bf74 - Added command importgraph/igraph to main.d.
aziz
parents: 364
diff changeset
312 " importgraph (igraph)\n"
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
313 " statistics (stats)\n"
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
314 " tokenize (tok)\n"
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
315 " translate (trans)\n";
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
316
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
317 bool strbeg(char[] str, char[] begin)
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
318 {
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
319 if (str.length >= begin.length)
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
320 {
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
321 if (str[0 .. begin.length] == begin)
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
322 return true;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
323 }
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
324 return false;
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
325 }
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
326
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
327 /// Creates the global compilation context.
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
328 CompilationContext newCompilationContext()
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
329 {
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
330 auto cc = new CompilationContext;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
331 cc.importPaths = GlobalSettings.importPaths;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
332 cc.addVersionId("dil");
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
333 cc.addVersionId("all");
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
334 version(D2)
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
335 cc.addVersionId("D_Version2");
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
336 foreach (versionId; GlobalSettings.versionIds)
814
49e32b5bc161 Added isValidUnreservedIdentifier() to Lexer.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 811
diff changeset
337 if (Lexer.isValidUnreservedIdentifier(versionId))
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
338 cc.versionIds[versionId] = true;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
339 return cc;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
340 }
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 bool parseDebugOrVersion(string arg, CompilationContext context)
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
343 {
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
344 if (strbeg(arg, "-debug"))
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
345 {
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
346 if (arg.length > 7)
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
347 {
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
348 auto val = arg[7..$];
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
349 if (isdigit(val[0]))
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
350 context.debugLevel = Integer.toInt(val);
814
49e32b5bc161 Added isValidUnreservedIdentifier() to Lexer.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 811
diff changeset
351 else if (Lexer.isValidUnreservedIdentifier(val))
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
352 context.addDebugId(val);
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
353 }
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
354 else
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
355 context.debugLevel = 1;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
356 }
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
357 else if (arg.length > 9 && strbeg(arg, "-version="))
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
358 {
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
359 auto val = arg[9..$];
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
360 if (isdigit(val[0]))
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
361 context.versionLevel = Integer.toInt(val);
814
49e32b5bc161 Added isValidUnreservedIdentifier() to Lexer.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 811
diff changeset
362 else if (Lexer.isValidUnreservedIdentifier(val))
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
363 context.addVersionId(val);
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
364 }
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
365 else
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
366 return false;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
367 return true;
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
368 }
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
369
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 794
diff changeset
370 /// Prints the errors collected in infoMan.
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
371 void printErrors(InfoManager infoMan)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
372 {
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
373 foreach (info; infoMan.info)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
374 {
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
375 char[] errorFormat;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
376 if (info.classinfo is LexerError.classinfo)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
377 errorFormat = GlobalSettings.lexerErrorFormat;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
378 else if (info.classinfo is ParserError.classinfo)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
379 errorFormat = GlobalSettings.parserErrorFormat;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
380 else if (info.classinfo is SemanticError.classinfo)
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
381 errorFormat = GlobalSettings.semanticErrorFormat;
744
7173ece1b696 Wrapped some macro functions inside struct MacroExpander.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 740
diff changeset
382 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
383 errorFormat = "{0}: Warning: {3}";
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
384 else
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
385 continue;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
386 auto err = cast(Problem)info;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
387 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
388 }
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
798
c24be8d4f6ab Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 794
diff changeset
391 /// Prints a help message for command.
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
392 void printHelp(char[] command)
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
393 {
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
394 char[] msg;
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
395 switch (command)
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
396 {
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
397 case "c", "compile":
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
398 msg = `Compile D source files.
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
399 Usage:
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
400 dil compile file.d [file2.d, ...] [Options]
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
401
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
402 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
403 Errors are printed to standard error output.
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
404
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
405 Options:
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
406 -debug : include debug code
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
407 -debug=level : include debug(l) code where l <= level
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
408 -debug=ident : include debug(ident) code
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
409 -version=level : include version(l) code where l >= level
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
410 -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
411 -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
412 -release : compile a release build
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
413 -unittest : compile a unittest build
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
414
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
415 Example:
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
416 dil c src/main.d -Isrc/`;
520
f203c5248d0b Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 513
diff changeset
417 break;
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
418 case "ddoc", "d":
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
419 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
420 Usage:
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
421 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
422
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
423 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
424 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
425
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
426 Options:
800
dcd30b0ba711 Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 798
diff changeset
427 --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
428 -i : include undocumented symbols
740
f3dead0310ce Added '-v' (verbose) option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 737
diff changeset
429 -v : verbose output
731
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
430
ca7607226caa Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 714
diff changeset
431 Example:
778
78be32e3e157 Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 771
diff changeset
432 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
433 break;
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
434 case "hl", "highlight":
771
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
435 // 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
436 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
437 Usage:
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
438 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
439
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
440 Options:
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
441 --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
442 --xml : use XML format (default)
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
443 --html : use HTML format
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
444 --lines : print line numbers
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
445
ef9bee5a2d61 Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 765
diff changeset
446 Example:
808
28e1ff1dcfcf Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 807
diff changeset
447 dil hl Parser.d --html --syntax > Parser.html`;
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
448 break;
375
0bd21b746a04 - Added code to main() for recognizing options to the importgraph command.
aziz
parents: 368
diff changeset
449 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
450 // 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
451 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
452 Usage:
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
453 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
454
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
455 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
456
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
457 Format:
792
05dfe88dd3bb Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 780
diff changeset
458 --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
459 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
460 -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
461 -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
462 -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
463 -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
464 -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
465 -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
466 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
467
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
468 --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
469
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
470 --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
471 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
472 -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
473 -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
474
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
475 Options:
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
476 -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
477 looked for
809
7e84472f4e91 Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 808
diff changeset
478 -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
479 REGEXP
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
480 -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
481
bf10602159c1 Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 687
diff changeset
482 Example:
792
05dfe88dd3bb Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 780
diff changeset
483 dil igraph src/main.d --list
05dfe88dd3bb Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 780
diff changeset
484 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
485 break;
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
486 case "tok", "tokenize":
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
487 msg = `Print the tokens of a D source file.
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
488 Usage:
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
489 dil tok file.d [Options]
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
490
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
491 Options:
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
492 - : reads text from the standard input.
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
493 -sSEPARATOR : print SEPARATOR instead of newline between tokens.
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
494 -i : ignore whitespace tokens (e.g. comments, shebang etc.)
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
495 -ws : print a token's preceding whitespace characters.
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
496
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
497 Example:
756
804111ec8213 Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 755
diff changeset
498 echo "module foo; void func(){}" | dil tok -
487
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
499 dil tok main.d | grep ^[0-9]`;
bccca748d745 Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 485
diff changeset
500 break;
513
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
501 case "stats", "statistics":
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
502 msg = "Gather statistics about D source files.
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
503 Usage:
545
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
504 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
505
0bac0bb506ca Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 532
diff changeset
506 Options:
672
d422e5f2f3ea Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 670
diff changeset
507 --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
508 --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
509
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
510 Example:
6160ab7b1816 Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 487
diff changeset
511 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
512 break;
670
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
513 case "trans", "translate":
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
514 msg = `Translate a D source file to another language.
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
515 Usage:
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
516 dil translate Language file.d
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
517
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
518 Languages that are supported:
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
519 *) German
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
520
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
521 Example:
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
522 dil trans German src/main.d`;
d8c32113afde Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 649
diff changeset
523 break;
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
524 case "main":
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
525 default:
810
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
526 auto COMPILED_WITH = __VENDOR__;
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
527 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
528 auto COMPILED_DATE = __TIMESTAMP__;
525ee3f848d9 Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 809
diff changeset
529 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
530 COMPILED_VERSION, COMPILED_DATE);
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
531 }
391
33b566df6af4 Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents: 375
diff changeset
532 Stdout(msg).newline;
338
63c6afb915f7 - Made some corrections to the message catalogs.
aziz
parents: 334
diff changeset
533 }