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