Mercurial > projects > dil
annotate trunk/src/main.d @ 800:dcd30b0ba711
Added --xml option to command 'ddoc'.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 01 Mar 2008 17:58:23 +0100 |
parents | c24be8d4f6ab |
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 |
363 | 27 import cmd.Generate; |
28 import cmd.Statistics; | |
364 | 29 import cmd.ImportGraph; |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
30 import cmd.DDoc; |
779
8e6fed11bb68
Moved Settings.d and SettingsLoader.d to src/.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
778
diff
changeset
|
31 |
8e6fed11bb68
Moved Settings.d and SettingsLoader.d to src/.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
778
diff
changeset
|
32 import Settings; |
8e6fed11bb68
Moved Settings.d and SettingsLoader.d to src/.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
778
diff
changeset
|
33 import SettingsLoader; |
792
05dfe88dd3bb
Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
780
diff
changeset
|
34 // import TypeRules; |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
375
diff
changeset
|
35 import common; |
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
375
diff
changeset
|
36 |
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
375
diff
changeset
|
37 import Integer = tango.text.convert.Integer; |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
38 import tango.stdc.stdio; |
513
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
39 import tango.io.File; |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
40 import tango.text.Util; |
575
dd3fe62c8a96
Compiles with Tango 0.99.4 now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
564
diff
changeset
|
41 import tango.time.StopWatch; |
746
32a8ddd330f8
Using icompare() instead of toLower().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
744
diff
changeset
|
42 import tango.text.Ascii : icompare; |
306 | 43 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
44 /// Entry function of dil. |
0 | 45 void main(char[][] args) |
46 { | |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
756
diff
changeset
|
47 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
|
48 SettingsLoader.SettingsLoader(infoMan).load(); |
759
9c47f377ca0b
Revised module cmd.Generate.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
49 if (infoMan.hasInfo) |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
756
diff
changeset
|
50 return printErrors(infoMan); |
309 | 51 |
306 | 52 if (args.length <= 1) |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
375
diff
changeset
|
53 return Stdout(helpMain()).newline; |
306 | 54 |
55 string command = args[1]; | |
56 switch (command) | |
57 { | |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
58 case "c", "compile": |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
59 if (args.length < 2) |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
60 return printHelp("compile"); |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
61 |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
62 string[] filePaths; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
63 auto context = newCompilationContext(); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
64 foreach (arg; args[2..$]) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
65 { |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
66 if (parseDebugOrVersion(arg, context)) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
67 {} |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
68 else |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
69 filePaths ~= arg; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
70 } |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
756
diff
changeset
|
71 infoMan = new InfoManager(); |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
72 foreach (filePath; filePaths) |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
73 { |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
74 auto mod = new Module(filePath, infoMan); |
564
3c867a683258
Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
545
diff
changeset
|
75 // Parse the file. |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
76 mod.parse(); |
649
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
77 if (mod.hasErrors) |
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
78 continue; |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
79 |
564
3c867a683258
Fixed VariableDeclaration.semantic().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
545
diff
changeset
|
80 // Start semantic analysis. |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
81 auto pass1 = new SemanticPass1(mod, context); |
649
3ebe76ad680e
Using SemanticPass1 in main.d do start semantic analysis.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
635
diff
changeset
|
82 pass1.start(); |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
83 |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
705
diff
changeset
|
84 void printSymbolTable(ScopeSymbol scopeSym, char[] indent) |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
85 { |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
86 foreach (member; scopeSym.members) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
87 { |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
705
diff
changeset
|
88 auto tokens = getDocTokens(member.node); |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
89 char[] docText; |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
90 foreach (token; tokens) |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
91 docText ~= token.srcText; |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
705
diff
changeset
|
92 Stdout(indent).formatln("Id:{}, Symbol:{}, DocText:{}", member.name.str, member.classinfo.name, docText); |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
705
diff
changeset
|
93 if (auto s = cast(ScopeSymbol)member) |
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
705
diff
changeset
|
94 printSymbolTable(s, indent ~ "→ "); |
618
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
95 } |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
96 } |
07946b379006
Refactored the way dot expressions are parsed.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
596
diff
changeset
|
97 |
714
140469ecb90e
Added code and applied fixes.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
705
diff
changeset
|
98 printSymbolTable(mod, ""); |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
99 } |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
100 |
765
bc812843603c
Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
764
diff
changeset
|
101 infoMan.hasInfo && printErrors(infoMan); |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
102 break; |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
103 case "ddoc", "d": |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
104 if (args.length < 4) |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
105 return printHelp("ddoc"); |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
106 |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
107 auto destination = args[2]; |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
108 auto macroPaths = GlobalSettings.ddocFilePaths; |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
109 char[][] filePaths; |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
110 bool incUndoc; |
800
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
111 bool writeXML; |
740
f3dead0310ce
Added '-v' (verbose) option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
737
diff
changeset
|
112 bool verbose; |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
113 // Parse arguments. |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
114 auto context = newCompilationContext(); |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
115 foreach (arg; args[3..$]) |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
116 { |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
117 if (parseDebugOrVersion(arg, context)) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
118 {} |
800
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
119 else if (arg == "--xml") |
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
120 writeXML = true; |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
121 else if (arg == "-i") |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
122 incUndoc = true; |
740
f3dead0310ce
Added '-v' (verbose) option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
737
diff
changeset
|
123 else if (arg == "-v") |
f3dead0310ce
Added '-v' (verbose) option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
737
diff
changeset
|
124 verbose = true; |
746
32a8ddd330f8
Using icompare() instead of toLower().
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
744
diff
changeset
|
125 else if (arg.length > 5 && icompare(arg[$-4..$], "ddoc") == 0) |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
126 macroPaths ~= arg; |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
127 else |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
128 filePaths ~= arg; |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
129 } |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
130 |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
756
diff
changeset
|
131 infoMan = new InfoManager(); |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
132 // Execute command. |
800
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
133 cmd.DDoc.execute(filePaths, destination, macroPaths, writeXML, |
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
134 incUndoc, verbose, context, infoMan); |
765
bc812843603c
Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
764
diff
changeset
|
135 infoMan.hasInfo && printErrors(infoMan); |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
136 break; |
329 | 137 case "gen", "generate": |
322
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
138 char[] fileName; |
771
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
139 GenOption options = GenOption.Tokens; |
322
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
140 foreach (arg; args[2..$]) |
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
141 { |
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
142 switch (arg) |
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 case "--syntax": |
771
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
145 options |= GenOption.Syntax; break; |
322
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
146 case "--xml": |
771
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
147 options |= GenOption.XML; break; |
322
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
148 case "--html": |
771
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
149 options |= GenOption.HTML; break; |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
150 case "--lines": |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
151 options |= GenOption.PrintLines; break; |
322
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
152 default: |
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
153 fileName = arg; |
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
154 } |
ed4ef0173793
- Moved out large TOK switch case to function printToken().
aziz
parents:
315
diff
changeset
|
155 } |
771
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
156 if (!(options & (GenOption.XML | GenOption.HTML))) |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
157 options |= GenOption.XML; // Default to XML. |
759
9c47f377ca0b
Revised module cmd.Generate.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
758
diff
changeset
|
158 cmd.Generate.execute(fileName, options, infoMan); |
765
bc812843603c
Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
764
diff
changeset
|
159 infoMan.hasInfo && printErrors(infoMan); |
306 | 160 break; |
366 | 161 case "importgraph", "igraph": |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
162 string filePath; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
163 string[] regexps; |
703
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
164 string siStyle = "dashed"; // static import style |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
165 string piStyle = "bold"; // public import style |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
166 uint levels; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
167 IGraphOption options; |
780
edd217e14736
Using CompilationContext in command 'igraph'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
779
diff
changeset
|
168 auto context = newCompilationContext(); |
366 | 169 foreach (arg; args[2..$]) |
170 { | |
780
edd217e14736
Using CompilationContext in command 'igraph'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
779
diff
changeset
|
171 if (parseDebugOrVersion(arg, context)) |
edd217e14736
Using CompilationContext in command 'igraph'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
779
diff
changeset
|
172 {} |
edd217e14736
Using CompilationContext in command 'igraph'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
779
diff
changeset
|
173 else if (strbeg(arg, "-I")) |
edd217e14736
Using CompilationContext in command 'igraph'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
779
diff
changeset
|
174 context.importPaths ~= arg[2..$]; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
175 else if(strbeg(arg, "-r")) |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
176 regexps ~= arg[2..$]; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
177 else if(strbeg(arg, "-l")) |
392
bb935c6f9b7a
Applied fixes and improvements to the Lexer class.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
391
diff
changeset
|
178 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
|
179 else if(strbeg(arg, "-si")) |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
180 siStyle = arg[3..$]; |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
181 else if(strbeg(arg, "-pi")) |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
182 piStyle = arg[3..$]; |
366 | 183 else |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
184 switch (arg) |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
185 { |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
186 case "--dot": |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
187 options |= IGraphOption.PrintDot; break; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
188 case "--paths": |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
189 options |= IGraphOption.PrintPaths; break; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
190 case "--list": |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
191 options |= IGraphOption.PrintList; break; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
192 case "-i": |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
193 options |= IGraphOption.IncludeUnlocatableModules; break; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
194 case "-hle": |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
195 options |= IGraphOption.HighlightCyclicEdges; break; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
196 case "-hlv": |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
197 options |= IGraphOption.HighlightCyclicVertices; break; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
198 case "-gbp": |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
199 options |= IGraphOption.GroupByPackageNames; break; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
200 case "-gbf": |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
201 options |= IGraphOption.GroupByFullPackageName; break; |
427
e2bbc6406a14
Added a new option '-m' to the igraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
422
diff
changeset
|
202 case "-m": |
e2bbc6406a14
Added a new option '-m' to the igraph command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
422
diff
changeset
|
203 options |= IGraphOption.MarkCyclicModules; break; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
204 default: |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
205 filePath = arg; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
206 } |
366 | 207 } |
780
edd217e14736
Using CompilationContext in command 'igraph'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
779
diff
changeset
|
208 cmd.ImportGraph.execute(filePath, context, regexps, levels, siStyle, piStyle, options); |
366 | 209 break; |
363 | 210 case "stats", "statistics": |
545
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
211 char[][] filePaths; |
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
212 bool printTokensTable; |
672
d422e5f2f3ea
Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
670
diff
changeset
|
213 bool printNodesTable; |
545
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
214 foreach (arg; args[2..$]) |
672
d422e5f2f3ea
Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
670
diff
changeset
|
215 if (arg == "--toktable") |
545
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
216 printTokensTable = true; |
672
d422e5f2f3ea
Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
670
diff
changeset
|
217 else if (arg == "--asttable") |
d422e5f2f3ea
Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
670
diff
changeset
|
218 printNodesTable = true; |
545
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
219 else |
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
220 filePaths ~= arg; |
672
d422e5f2f3ea
Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
670
diff
changeset
|
221 cmd.Statistics.execute(filePaths, printTokensTable, printNodesTable); |
363 | 222 break; |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
223 case "tok", "tokenize": |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
224 SourceText sourceText; |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
225 char[] filePath; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
226 char[] separator; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
227 bool ignoreWSToks; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
228 bool printWS; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
229 |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
230 foreach (arg; args[2..$]) |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
231 { |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
232 if (strbeg(arg, "-s")) |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
233 separator = arg[2..$]; |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
234 else if (arg == "-") |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
235 sourceText = new SourceText("stdin", readStdin()); |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
236 else if (arg == "-i") |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
237 ignoreWSToks = true; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
238 else if (arg == "-ws") |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
239 printWS = true; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
240 else |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
241 filePath = arg; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
242 } |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
243 |
755
90668b83ae5e
Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
746
diff
changeset
|
244 separator || (separator = "\n"); |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
245 if (!sourceText) |
755
90668b83ae5e
Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
746
diff
changeset
|
246 sourceText = new SourceText(filePath, true); |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
247 |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
756
diff
changeset
|
248 infoMan = new InfoManager(); |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
249 auto lx = new Lexer(sourceText, infoMan); |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
250 lx.scanAll(); |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
251 auto token = lx.firstToken(); |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
252 |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
253 for (; token.kind != TOK.EOF; token = token.next) |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
254 { |
679
ff6971637f88
Renamed Token member type to kind.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
676
diff
changeset
|
255 if (token.kind == TOK.Newline || ignoreWSToks && token.isWhitespace) |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
256 continue; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
257 if (printWS && token.ws) |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
258 Stdout(token.wsChars); |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
259 Stdout(token.srcText)(separator); |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
260 } |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
261 |
765
bc812843603c
Template functions are wrapped inside TemplateDeclarations now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
764
diff
changeset
|
262 infoMan.hasInfo && printErrors(infoMan); |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
263 break; |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
264 case "trans", "translate": |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
265 if (args.length < 3) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
266 return printHelp("trans"); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
267 |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
268 if (args[2] != "German") |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
269 return Stdout.formatln("Error: unrecognized target language \"{}\"", args[2]); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
270 |
758
f4b9680c0e16
Revised module dil.SettingsLoader.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
756
diff
changeset
|
271 infoMan = new InfoManager(); |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
272 auto filePath = args[3]; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
273 auto mod = new Module(filePath, infoMan); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
274 // Parse the file. |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
275 mod.parse(); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
276 if (!mod.hasErrors) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
277 { // Translate |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
278 auto german = new GermanTranslator(Stdout, " "); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
279 german.translate(mod.root); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
280 } |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
281 printErrors(infoMan); |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
282 break; |
513
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
283 case "profile": |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
284 if (args.length < 3) |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
285 break; |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
286 char[][] filePaths; |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
287 if (args[2] == "dstress") |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
288 { |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
289 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
|
290 filePaths = split(text, "\0"); |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
291 } |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
292 else |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
293 filePaths = args[2..$]; |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
294 |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
295 StopWatch swatch; |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
296 swatch.start; |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
297 |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
298 foreach (filePath; filePaths) |
755
90668b83ae5e
Introduced new module dil.SourceText and class SourceText.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
746
diff
changeset
|
299 (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
|
300 |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
301 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
|
302 break; |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
303 // case "parse": |
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
304 // if (args.length == 3) |
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
305 // parse(args[2]); |
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
306 // break; |
338 | 307 case "?", "help": |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
308 printHelp(args.length >= 3 ? args[2] : ""); |
338 | 309 break; |
800
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
310 // case "typerules": |
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
311 // genHTMLTypeRulesTables(); |
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
312 // break; |
306 | 313 default: |
314 } | |
315 } | |
316 | |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
317 char[] readStdin() |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
318 { |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
319 char[] text; |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
320 while (1) |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
321 { |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
322 auto c = getc(stdin); |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
323 if (c == EOF) |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
324 break; |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
325 text ~= c; |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
326 } |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
327 return text; |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
328 } |
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
329 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
330 /// Available commands. |
338 | 331 const char[] COMMANDS = |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
332 " compile (c)\n" |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
333 " ddoc (d)\n" |
338 | 334 " generate (gen)\n" |
363 | 335 " help (?)\n" |
366 | 336 " importgraph (igraph)\n" |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
337 " statistics (stats)\n" |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
338 " tokenize (tok)\n" |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
339 " translate (trans)\n"; |
338 | 340 |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
341 bool strbeg(char[] str, char[] begin) |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
342 { |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
343 if (str.length >= begin.length) |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
344 { |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
345 if (str[0 .. begin.length] == begin) |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
346 return true; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
347 } |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
348 return false; |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
349 } |
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
350 |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
351 /// Creates the global compilation context. |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
352 CompilationContext newCompilationContext() |
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 cc = new CompilationContext; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
355 cc.importPaths = GlobalSettings.importPaths; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
356 cc.addVersionId("dil"); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
357 cc.addVersionId("all"); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
358 version(D2) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
359 cc.addVersionId("D_Version2"); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
360 foreach (versionId; GlobalSettings.versionIds) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
361 if (!Lexer.isReservedIdentifier(versionId)) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
362 cc.versionIds[versionId] = true; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
363 return cc; |
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 |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
366 bool parseDebugOrVersion(string arg, CompilationContext context) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
367 { |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
368 if (strbeg(arg, "-debug")) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
369 { |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
370 if (arg.length > 7) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
371 { |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
372 auto val = arg[7..$]; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
373 if (isdigit(val[0])) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
374 context.debugLevel = Integer.toInt(val); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
375 else if (!Lexer.isReservedIdentifier(val)) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
376 context.addDebugId(val); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
377 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
378 else |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
379 context.debugLevel = 1; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
380 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
381 else if (arg.length > 9 && strbeg(arg, "-version=")) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
382 { |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
383 auto val = arg[9..$]; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
384 if (isdigit(val[0])) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
385 context.versionLevel = Integer.toInt(val); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
386 else if (!Lexer.isReservedIdentifier(val)) |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
387 context.addVersionId(val); |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
388 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
389 else |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
390 return false; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
391 return true; |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
392 } |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
393 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
394 /// Prints the errors collected in infoMan. |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
395 void printErrors(InfoManager infoMan) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
396 { |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
397 foreach (info; infoMan.info) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
398 { |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
399 char[] errorFormat; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
400 if (info.classinfo is LexerError.classinfo) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
401 errorFormat = GlobalSettings.lexerErrorFormat; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
402 else if (info.classinfo is ParserError.classinfo) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
403 errorFormat = GlobalSettings.parserErrorFormat; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
404 else if (info.classinfo is SemanticError.classinfo) |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
405 errorFormat = GlobalSettings.semanticErrorFormat; |
744
7173ece1b696
Wrapped some macro functions inside struct MacroExpander.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
740
diff
changeset
|
406 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
|
407 errorFormat = "{0}: Warning: {3}"; |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
408 else |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
409 continue; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
410 auto err = cast(Problem)info; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
411 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
|
412 } |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
413 } |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
414 |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
415 /// Prints the compiler's main help message. |
338 | 416 char[] helpMain() |
417 { | |
794
a7320b7cb7dc
Removed module util/metastrings.d.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
792
diff
changeset
|
418 auto COMPILED_WITH = __VENDOR__; |
a7320b7cb7dc
Removed module util/metastrings.d.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
792
diff
changeset
|
419 auto COMPILED_VERSION = Format("{}.{,:d3}", __VERSION__/1000, __VERSION__%1000); |
a7320b7cb7dc
Removed module util/metastrings.d.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
792
diff
changeset
|
420 auto COMPILED_DATE = __TIMESTAMP__; |
a7320b7cb7dc
Removed module util/metastrings.d.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
792
diff
changeset
|
421 return FormatMsg(MID.HelpMain, VERSION, COMMANDS, COMPILED_WITH, |
a7320b7cb7dc
Removed module util/metastrings.d.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
792
diff
changeset
|
422 COMPILED_VERSION, COMPILED_DATE); |
338 | 423 } |
424 | |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
425 /// Prints a help message for command. |
338 | 426 void printHelp(char[] command) |
427 { | |
428 char[] msg; | |
429 switch (command) | |
430 { | |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
431 case "c", "compile": |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
432 msg = `Compile D source files. |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
433 Usage: |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
434 dil compile file.d [file2.d, ...] [Options] |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
435 |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
436 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
|
437 Errors are printed to standard error output. |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
438 |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
439 Options: |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
440 -debug : include debug code |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
441 -debug=level : include debug(l) code where l <= level |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
442 -debug=ident : include debug(ident) code |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
443 -version=level : include version(l) code where l >= level |
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
444 -version=ident : include version(ident) code |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
445 |
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
446 Example: |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
447 dil c src/main.d`; |
520
f203c5248d0b
Added 'compile' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
513
diff
changeset
|
448 break; |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
449 case "ddoc", "d": |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
450 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
|
451 Usage: |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
452 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
|
453 |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
454 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
|
455 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
|
456 |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
457 Options: |
800
dcd30b0ba711
Added --xml option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
798
diff
changeset
|
458 --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
|
459 -i : include undocumented symbols |
740
f3dead0310ce
Added '-v' (verbose) option to command 'ddoc'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
737
diff
changeset
|
460 -v : verbose output |
731
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
461 |
ca7607226caa
Added new module cmd.DDoc.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
714
diff
changeset
|
462 Example: |
778
78be32e3e157
Implemented conditional compilation.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
771
diff
changeset
|
463 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
|
464 break; |
338 | 465 case "gen", "generate": |
771
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
466 // msg = GetMsg(MID.HelpGenerate); |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
467 msg = `Generate an XML or HTML document from a D source file. |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
468 Usage: |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
469 dil gen file.d [Options] |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
470 |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
471 Options: |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
472 --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
|
473 --xml : use XML format (default) |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
474 --html : use HTML format |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
475 --lines : print line numbers |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
476 |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
477 Example: |
ef9bee5a2d61
Command 'generate' can print line numbers now.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
765
diff
changeset
|
478 dil gen Parser.d --html --syntax > Parser.html`; |
338 | 479 break; |
375
0bd21b746a04
- Added code to main() for recognizing options to the importgraph command.
aziz
parents:
368
diff
changeset
|
480 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
|
481 // 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
|
482 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
|
483 Usage: |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
484 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
|
485 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
486 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
|
487 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
488 Format: |
792
05dfe88dd3bb
Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
780
diff
changeset
|
489 --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
|
490 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
|
491 -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
|
492 -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
|
493 -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
|
494 -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
|
495 -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
|
496 -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
|
497 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
|
498 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
499 --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
|
500 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
501 --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
|
502 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
|
503 -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
|
504 -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
|
505 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
506 Options: |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
507 -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
|
508 looked for |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
509 -rREGEXP : exclude modules whose names match the regular expression |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
510 REGEXP |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
511 -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
|
512 |
bf10602159c1
Added static and public import styles to 'igraph' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
687
diff
changeset
|
513 Example: |
792
05dfe88dd3bb
Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
780
diff
changeset
|
514 dil igraph src/main.d --list |
05dfe88dd3bb
Added new module TypeRules.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
780
diff
changeset
|
515 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
|
516 break; |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
517 case "tok", "tokenize": |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
518 msg = `Print the tokens of a D source file. |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
519 Usage: |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
520 dil tok file.d [Options] |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
521 |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
522 Options: |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
523 - : reads text from the standard input. |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
524 -sSEPARATOR : print SEPARATOR instead of newline between tokens. |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
525 -i : ignore whitespace tokens (e.g. comments, shebang etc.) |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
526 -ws : print a token's preceding whitespace characters. |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
527 |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
528 Example: |
756
804111ec8213
Improved command 'tokenize'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
755
diff
changeset
|
529 echo "module foo; void func(){}" | dil tok - |
487
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
530 dil tok main.d | grep ^[0-9]`; |
bccca748d745
Added 'tokenize' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
485
diff
changeset
|
531 break; |
513
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
532 case "stats", "statistics": |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
533 msg = "Gather statistics about D source files. |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
534 Usage: |
545
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
535 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
|
536 |
0bac0bb506ca
Added '--table' option to 'stats' command.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
532
diff
changeset
|
537 Options: |
672
d422e5f2f3ea
Added '--asttable' option to command 'statistics'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
670
diff
changeset
|
538 --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
|
539 --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
|
540 |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
541 Example: |
6160ab7b1816
Refactored code related to settings.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
487
diff
changeset
|
542 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
|
543 break; |
670
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
544 case "trans", "translate": |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
545 msg = `Translate a D source file to another language. |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
546 Usage: |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
547 dil translate Language file.d |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
548 |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
549 Languages that are supported: |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
550 *) German |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
551 |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
552 Example: |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
553 dil trans German src/main.d`; |
d8c32113afde
Added command 'translate'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
649
diff
changeset
|
554 break; |
338 | 555 default: |
556 msg = helpMain(); | |
557 } | |
391
33b566df6af4
Migrated project to Tango.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
375
diff
changeset
|
558 Stdout(msg).newline; |
338 | 559 } |
560 | |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
561 /+void parse(string fileName) |
306 | 562 { |
578
c769bc239006
Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
576
diff
changeset
|
563 auto mod = new Module(fileName); |
c769bc239006
Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
576
diff
changeset
|
564 mod.parse(); |
299
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
249
diff
changeset
|
565 |
578
c769bc239006
Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
576
diff
changeset
|
566 void print(Node[] decls, char[] indent) |
299
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
249
diff
changeset
|
567 { |
578
c769bc239006
Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
576
diff
changeset
|
568 foreach(decl; decls) |
c769bc239006
Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
576
diff
changeset
|
569 { |
c769bc239006
Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
576
diff
changeset
|
570 assert(decl !is null); |
c769bc239006
Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
576
diff
changeset
|
571 Stdout.formatln("{}{}: begin={} end={}", indent, decl.classinfo.name, decl.begin ? decl.begin.srcText : "\33[31mnull\33[0m", decl.end ? decl.end.srcText : "\33[31mnull\33[0m"); |
c769bc239006
Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
576
diff
changeset
|
572 print(decl.children, indent ~ " "); |
c769bc239006
Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
576
diff
changeset
|
573 } |
299
559d5d62e0c1
- Added checks for null before adding member to Node.children.
aziz
parents:
249
diff
changeset
|
574 } |
578
c769bc239006
Moved Parser.d to new package 'parser'.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
576
diff
changeset
|
575 print(mod.root.children, ""); |
798
c24be8d4f6ab
Added documentation comments.
Aziz K?ksal <aziz.koeksal@gmail.com>
parents:
794
diff
changeset
|
576 }+/ |