Mercurial > projects > dil
annotate src/main.d @ 839:4063da6f3edd default tip
Refactored the config file and how it is loaded.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Thu, 21 Aug 2008 17:51:04 +0200 |
parents | 80eb3251e010 |
children |
rev | line source |
---|---|
0 | 1 /++ |
2 Author: Aziz Köksal | |
249 | 3 License: GPL3 |
0 | 4 +/ |
347 | 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 | 12 dil.ast.Node, |
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 | 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 | 29 import cmd.Statistics; |
364 | 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 | 44 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
45 /// Entry function of dil. |
0 | 46 void main(char[][] args) |
47 { | |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
756
diff
changeset
|
48 auto infoMan = new InfoManager(); |
839
4063da6f3edd
Refactored the config file and how it is loaded.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
832
diff
changeset
|
49 ConfigLoader(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 | 52 |
306 | 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 | 55 |
56 string command = args[1]; | |
57 switch (command) | |
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") |
824
a8b3de006554
Adding 'unittest' to version Ids if the flag -unittest is active.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
819
diff
changeset
|
76 { |
a8b3de006554
Adding 'unittest' to version Ids if the flag -unittest is active.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
819
diff
changeset
|
77 version(D2) |
a8b3de006554
Adding 'unittest' to version Ids if the flag -unittest is active.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
819
diff
changeset
|
78 cmd.context.addVersionId("unittest"); |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
79 cmd.context.unittestBuild = true; |
824
a8b3de006554
Adding 'unittest' to version Ids if the flag -unittest is active.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
819
diff
changeset
|
80 } |
819
438ed3a72c9d
Added option -d to the compile command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
816
diff
changeset
|
81 else if (arg == "-d") |
438ed3a72c9d
Added option -d to the compile command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
816
diff
changeset
|
82 cmd.context.acceptDeprecated = true; |
816
35d238d502cb
The ModuleManager handles packages as well now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
814
diff
changeset
|
83 else if (arg == "-ps") |
35d238d502cb
The ModuleManager handles packages as well now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
814
diff
changeset
|
84 cmd.printSymbolTree = true; |
35d238d502cb
The ModuleManager handles packages as well now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
814
diff
changeset
|
85 else if (arg == "-pm") |
35d238d502cb
The ModuleManager handles packages as well now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
814
diff
changeset
|
86 cmd.printModuleTree = true; |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
87 else |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
88 cmd.filePaths ~= arg; |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
89 } |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
90 cmd.run(); |
765
bc812843603c
Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
764
diff
changeset
|
91 infoMan.hasInfo && printErrors(infoMan); |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
92 break; |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
93 case "ddoc", "d": |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
94 if (args.length < 4) |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
95 return printHelp(command); |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
96 |
807
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
97 DDocCommand cmd; |
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
98 cmd.destDirPath = args[2]; |
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
99 cmd.macroPaths = GlobalSettings.ddocFilePaths; |
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
100 cmd.context = newCompilationContext(); |
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
101 cmd.infoMan = infoMan; |
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
102 |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
103 // Parse arguments. |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
104 foreach (arg; args[3..$]) |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
105 { |
807
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
106 if (parseDebugOrVersion(arg, cmd.context)) |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
107 {} |
800
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
108 else if (arg == "--xml") |
807
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
109 cmd.writeXML = true; |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
110 else if (arg == "-i") |
807
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
111 cmd.includeUndocumented = true; |
740
f3dead0310ce
Added '-v' (verbose) option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
737
diff
changeset
|
112 else if (arg == "-v") |
807
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
113 cmd.verbose = true; |
746
32a8ddd330f8
Using icompare() instead of toLower().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
744
diff
changeset
|
114 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
|
115 cmd.macroPaths ~= arg; |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
116 else |
807
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
117 cmd.filePaths ~= arg; |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
118 } |
807
a2880c95eda3
Refactored ddoc command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
806
diff
changeset
|
119 cmd.run(); |
765
bc812843603c
Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
764
diff
changeset
|
120 infoMan.hasInfo && printErrors(infoMan); |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
121 break; |
808
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
122 case "hl", "highlight": |
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
123 if (args.length < 3) |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
124 return printHelp(command); |
808
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
125 |
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
126 HighlightCommand cmd; |
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
127 cmd.infoMan = infoMan; |
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
128 |
322
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
129 foreach (arg; args[2..$]) |
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
130 { |
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
131 switch (arg) |
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
132 { |
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
133 case "--syntax": |
808
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
134 cmd.add(HighlightCommand.Option.Syntax); break; |
322
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
135 case "--xml": |
808
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
136 cmd.add(HighlightCommand.Option.XML); break; |
322
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
137 case "--html": |
808
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
138 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
|
139 case "--lines": |
808
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
140 cmd.add(HighlightCommand.Option.PrintLines); break; |
322
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
141 default: |
808
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
142 cmd.filePath = arg; |
322
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
143 } |
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
144 } |
808
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
145 cmd.run(); |
765
bc812843603c
Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
764
diff
changeset
|
146 infoMan.hasInfo && printErrors(infoMan); |
306 | 147 break; |
366 | 148 case "importgraph", "igraph": |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
149 if (args.length < 3) |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
150 return printHelp(command); |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
151 |
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
152 IGraphCommand cmd; |
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
153 cmd.context = newCompilationContext(); |
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
154 |
366 | 155 foreach (arg; args[2..$]) |
156 { | |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
157 if (parseDebugOrVersion(arg, cmd.context)) |
780
edd217e14736
Using CompilationContext in command 'igraph'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
779
diff
changeset
|
158 {} |
edd217e14736
Using CompilationContext in command 'igraph'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
779
diff
changeset
|
159 else if (strbeg(arg, "-I")) |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
160 cmd.context.importPaths ~= arg[2..$]; |
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
161 else if(strbeg(arg, "-x")) |
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
162 cmd.regexps ~= arg[2..$]; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
163 else if(strbeg(arg, "-l")) |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
164 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
|
165 else if(strbeg(arg, "-si")) |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
166 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
|
167 else if(strbeg(arg, "-pi")) |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
168 cmd.piStyle = arg[3..$]; |
366 | 169 else |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
170 switch (arg) |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
171 { |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
172 case "--dot": |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
173 cmd.add(IGraphCommand.Option.PrintDot); break; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
174 case "--paths": |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
175 cmd.add(IGraphCommand.Option.PrintPaths); break; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
176 case "--list": |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
177 cmd.add(IGraphCommand.Option.PrintList); break; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
178 case "-i": |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
179 cmd.add(IGraphCommand.Option.IncludeUnlocatableModules); break; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
180 case "-hle": |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
181 cmd.add(IGraphCommand.Option.HighlightCyclicEdges); break; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
182 case "-hlv": |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
183 cmd.add(IGraphCommand.Option.HighlightCyclicVertices); break; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
184 case "-gbp": |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
185 cmd.add(IGraphCommand.Option.GroupByPackageNames); break; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
186 case "-gbf": |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
187 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
|
188 case "-m": |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
189 cmd.add(IGraphCommand.Option.MarkCyclicModules); break; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
190 default: |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
191 cmd.filePath = arg; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
192 } |
366 | 193 } |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
194 cmd.run(); |
366 | 195 break; |
363 | 196 case "stats", "statistics": |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
197 if (args.length < 3) |
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
198 return printHelp(command); |
811
5c29f1ebec9f
Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
810
diff
changeset
|
199 |
5c29f1ebec9f
Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
810
diff
changeset
|
200 StatsCommand cmd; |
545
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
201 foreach (arg; args[2..$]) |
672
d422e5f2f3ea
Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
670
diff
changeset
|
202 if (arg == "--toktable") |
811
5c29f1ebec9f
Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
810
diff
changeset
|
203 cmd.printTokensTable = true; |
672
d422e5f2f3ea
Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
670
diff
changeset
|
204 else if (arg == "--asttable") |
811
5c29f1ebec9f
Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
810
diff
changeset
|
205 cmd.printNodesTable = true; |
545
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
206 else |
811
5c29f1ebec9f
Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
810
diff
changeset
|
207 cmd.filePaths ~= arg; |
5c29f1ebec9f
Refactored statistics command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
810
diff
changeset
|
208 cmd.run(); |
363 | 209 break; |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
210 case "tok", "tokenize": |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
211 if (args.length < 3) |
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
212 return printHelp(command); |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
213 SourceText sourceText; |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
214 char[] filePath; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
215 char[] separator; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
216 bool ignoreWSToks; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
217 bool printWS; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
218 |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
219 foreach (arg; args[2..$]) |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
220 { |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
221 if (strbeg(arg, "-s")) |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
222 separator = arg[2..$]; |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
223 else if (arg == "-") |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
224 sourceText = new SourceText("stdin", readStdin()); |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
225 else if (arg == "-i") |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
226 ignoreWSToks = true; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
227 else if (arg == "-ws") |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
228 printWS = true; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
229 else |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
230 filePath = arg; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
231 } |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
232 |
755
90668b83ae5e
Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
746
diff
changeset
|
233 separator || (separator = "\n"); |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
234 if (!sourceText) |
755
90668b83ae5e
Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
746
diff
changeset
|
235 sourceText = new SourceText(filePath, true); |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
236 |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
756
diff
changeset
|
237 infoMan = new InfoManager(); |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
238 auto lx = new Lexer(sourceText, infoMan); |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
239 lx.scanAll(); |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
240 auto token = lx.firstToken(); |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
241 |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
242 for (; token.kind != TOK.EOF; token = token.next) |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
243 { |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
244 if (token.kind == TOK.Newline || ignoreWSToks && token.isWhitespace) |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
245 continue; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
246 if (printWS && token.ws) |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
247 Stdout(token.wsChars); |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
248 Stdout(token.srcText)(separator); |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
249 } |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
250 |
765
bc812843603c
Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
764
diff
changeset
|
251 infoMan.hasInfo && printErrors(infoMan); |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
252 break; |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
253 case "trans", "translate": |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
254 if (args.length < 3) |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
255 return printHelp(command); |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
256 |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
257 if (args[2] != "German") |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
258 return Stdout.formatln("Error: unrecognized target language \"{}\"", args[2]); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
259 |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
756
diff
changeset
|
260 infoMan = new InfoManager(); |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
261 auto filePath = args[3]; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
262 auto mod = new Module(filePath, infoMan); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
263 // Parse the file. |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
264 mod.parse(); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
265 if (!mod.hasErrors) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
266 { // Translate |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
267 auto german = new GermanTranslator(Stdout, " "); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
268 german.translate(mod.root); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
269 } |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
270 printErrors(infoMan); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
271 break; |
513
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
272 case "profile": |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
273 if (args.length < 3) |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
274 break; |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
275 char[][] filePaths; |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
276 if (args[2] == "dstress") |
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 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
|
279 filePaths = split(text, "\0"); |
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 else |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
282 filePaths = args[2..$]; |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
283 |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
284 StopWatch swatch; |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
285 swatch.start; |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
286 |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
287 foreach (filePath; filePaths) |
755
90668b83ae5e
Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
746
diff
changeset
|
288 (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
|
289 |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
290 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
|
291 break; |
338 | 292 case "?", "help": |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
293 printHelp(args.length >= 3 ? args[2] : ""); |
338 | 294 break; |
800
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
295 // case "typerules": |
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
296 // genHTMLTypeRulesTables(); |
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
297 // break; |
306 | 298 default: |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
299 printHelp("main"); |
306 | 300 } |
301 } | |
302 | |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
303 char[] readStdin() |
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 char[] text; |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
306 while (1) |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
307 { |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
308 auto c = getc(stdin); |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
309 if (c == EOF) |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
310 break; |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
311 text ~= c; |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
312 } |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
313 return text; |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
314 } |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
315 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
316 /// Available commands. |
338 | 317 const char[] COMMANDS = |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
318 " compile (c)\n" |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
319 " ddoc (d)\n" |
363 | 320 " help (?)\n" |
808
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
321 " highlight (hl)\n" |
366 | 322 " importgraph (igraph)\n" |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
323 " statistics (stats)\n" |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
324 " tokenize (tok)\n" |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
325 " translate (trans)\n"; |
338 | 326 |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
327 bool strbeg(char[] str, char[] begin) |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
328 { |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
329 if (str.length >= begin.length) |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
330 { |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
331 if (str[0 .. begin.length] == begin) |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
332 return true; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
333 } |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
334 return false; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
335 } |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
336 |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
337 /// Creates the global compilation context. |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
338 CompilationContext newCompilationContext() |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
339 { |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
340 auto cc = new CompilationContext; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
341 cc.importPaths = GlobalSettings.importPaths; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
342 cc.addVersionId("dil"); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
343 cc.addVersionId("all"); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
344 version(D2) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
345 cc.addVersionId("D_Version2"); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
346 foreach (versionId; GlobalSettings.versionIds) |
814
49e32b5bc161
Added isValidUnreservedIdentifier() to Lexer.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
811
diff
changeset
|
347 if (Lexer.isValidUnreservedIdentifier(versionId)) |
826 | 348 cc.addVersionId(versionId); |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
349 return cc; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
350 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
351 |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
352 bool parseDebugOrVersion(string arg, CompilationContext context) |
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 if (strbeg(arg, "-debug")) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
355 { |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
356 if (arg.length > 7) |
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 auto val = arg[7..$]; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
359 if (isdigit(val[0])) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
360 context.debugLevel = Integer.toInt(val); |
814
49e32b5bc161
Added isValidUnreservedIdentifier() to Lexer.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
811
diff
changeset
|
361 else if (Lexer.isValidUnreservedIdentifier(val)) |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
362 context.addDebugId(val); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
363 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
364 else |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
365 context.debugLevel = 1; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
366 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
367 else if (arg.length > 9 && strbeg(arg, "-version=")) |
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 auto val = arg[9..$]; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
370 if (isdigit(val[0])) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
371 context.versionLevel = Integer.toInt(val); |
814
49e32b5bc161
Added isValidUnreservedIdentifier() to Lexer.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
811
diff
changeset
|
372 else if (Lexer.isValidUnreservedIdentifier(val)) |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
373 context.addVersionId(val); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
374 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
375 else |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
376 return false; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
377 return true; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
378 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
379 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
380 /// Prints the errors collected in infoMan. |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
381 void printErrors(InfoManager infoMan) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
382 { |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
383 foreach (info; infoMan.info) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
384 { |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
385 char[] errorFormat; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
386 if (info.classinfo is LexerError.classinfo) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
387 errorFormat = GlobalSettings.lexerErrorFormat; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
388 else if (info.classinfo is ParserError.classinfo) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
389 errorFormat = GlobalSettings.parserErrorFormat; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
390 else if (info.classinfo is SemanticError.classinfo) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
391 errorFormat = GlobalSettings.semanticErrorFormat; |
744
7173ece1b696
Wrapped some macro functions inside struct MacroExpander.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
740
diff
changeset
|
392 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
|
393 errorFormat = "{0}: Warning: {3}"; |
839
4063da6f3edd
Refactored the config file and how it is loaded.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
832
diff
changeset
|
394 else if (info.classinfo is dil.Information.Error.classinfo) |
4063da6f3edd
Refactored the config file and how it is loaded.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
832
diff
changeset
|
395 errorFormat = "Error: {3}"; |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
396 else |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
397 continue; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
398 auto err = cast(Problem)info; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
399 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
|
400 } |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
401 } |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
402 |
826 | 403 /// Prints the help message of a command. |
338 | 404 void printHelp(char[] command) |
405 { | |
406 char[] msg; | |
407 switch (command) | |
408 { | |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
409 case "c", "compile": |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
410 msg = `Compile D source files. |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
411 Usage: |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
412 dil compile file.d [file2.d, ...] [Options] |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
413 |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
414 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
|
415 Errors are printed to standard error output. |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
416 |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
417 Options: |
819
438ed3a72c9d
Added option -d to the compile command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
816
diff
changeset
|
418 -d : accept deprecated code |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
419 -debug : include debug code |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
420 -debug=level : include debug(l) code where l <= level |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
421 -debug=ident : include debug(ident) code |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
422 -version=level : include version(l) code where l >= level |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
423 -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
|
424 -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
|
425 -release : compile a release build |
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
426 -unittest : compile a unittest build |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
427 |
816
35d238d502cb
The ModuleManager handles packages as well now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
814
diff
changeset
|
428 -ps : print the symbol tree of the modules |
35d238d502cb
The ModuleManager handles packages as well now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
814
diff
changeset
|
429 -pm : print the package/module tree |
35d238d502cb
The ModuleManager handles packages as well now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
814
diff
changeset
|
430 |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
431 Example: |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
432 dil c src/main.d -Isrc/`; |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
433 break; |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
434 case "ddoc", "d": |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
435 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
|
436 Usage: |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
437 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
|
438 |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
439 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
|
440 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
|
441 |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
442 Options: |
800
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
443 --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
|
444 -i : include undocumented symbols |
740
f3dead0310ce
Added '-v' (verbose) option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
737
diff
changeset
|
445 -v : verbose output |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
446 |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
447 Example: |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
448 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
|
449 break; |
808
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
450 case "hl", "highlight": |
771
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
451 // 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
|
452 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
|
453 Usage: |
808
28e1ff1dcfcf
Renamed generate command to highlight and refactored it.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
807
diff
changeset
|
454 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
|
455 |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
456 Options: |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
457 --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
|
458 --xml : use XML format (default) |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
459 --html : use HTML format |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
460 --lines : print line numbers |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
461 |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
462 Example: |
832
80eb3251e010
Updated to Tango 0.99.7.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
826
diff
changeset
|
463 dil hl src/main.d --html --syntax > main.html`; |
338 | 464 break; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
465 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
|
466 // 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
|
467 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
|
468 Usage: |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
469 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
|
470 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
471 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
|
472 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
473 Format: |
792
05dfe88dd3bb
Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
780
diff
changeset
|
474 --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
|
475 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
|
476 -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
|
477 -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
|
478 -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
|
479 -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
|
480 -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
|
481 -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
|
482 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
|
483 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
484 --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
|
485 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
486 --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
|
487 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
|
488 -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
|
489 -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
|
490 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
491 Options: |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
492 -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
|
493 looked for |
809
7e84472f4e91
Refactored the importgraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
808
diff
changeset
|
494 -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
|
495 REGEXP |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
496 -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
|
497 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
498 Example: |
792
05dfe88dd3bb
Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
780
diff
changeset
|
499 dil igraph src/main.d --list |
05dfe88dd3bb
Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
780
diff
changeset
|
500 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
|
501 break; |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
502 case "tok", "tokenize": |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
503 msg = `Print the tokens of a D source file. |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
504 Usage: |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
505 dil tok file.d [Options] |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
506 |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
507 Options: |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
508 - : reads text from the standard input. |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
509 -sSEPARATOR : print SEPARATOR instead of newline between tokens. |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
510 -i : ignore whitespace tokens (e.g. comments, shebang etc.) |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
511 -ws : print a token's preceding whitespace characters. |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
512 |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
513 Example: |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
514 echo "module foo; void func(){}" | dil tok - |
832
80eb3251e010
Updated to Tango 0.99.7.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
826
diff
changeset
|
515 dil tok src/main.d | grep ^[0-9]`; |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
516 break; |
513
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
517 case "stats", "statistics": |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
518 msg = "Gather statistics about D source files. |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
519 Usage: |
545
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
520 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
|
521 |
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
522 Options: |
672
d422e5f2f3ea
Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
670
diff
changeset
|
523 --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
|
524 --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
|
525 |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
526 Example: |
832
80eb3251e010
Updated to Tango 0.99.7.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
826
diff
changeset
|
527 dil stat src/main.d src/dil/Unicode.d"; |
513
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
528 break; |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
529 case "trans", "translate": |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
530 msg = `Translate a D source file to another language. |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
531 Usage: |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
532 dil translate Language file.d |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
533 |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
534 Languages that are supported: |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
535 *) German |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
536 |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
537 Example: |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
538 dil trans German src/main.d`; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
539 break; |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
540 case "main": |
338 | 541 default: |
810
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
542 auto COMPILED_WITH = __VENDOR__; |
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
543 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
|
544 auto COMPILED_DATE = __TIMESTAMP__; |
525ee3f848d9
Added modules cmd.Compile and dil.ModuleManager.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
809
diff
changeset
|
545 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
|
546 COMPILED_VERSION, COMPILED_DATE); |
338 | 547 } |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
375
diff
changeset
|
548 Stdout(msg).newline; |
338 | 549 } |