about summary refs log tree commit diff stats
path: root/dwm.png
blob: b1f9ba7e5f4cc7350ee2392ebcea5fcbe00fb49b (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 c0 00 00 00 50 08 02 00 00 00 c0 d8 ed .PNG........IHDR.......P........
0020 13 00 00 00 06 62 4b 47 44 00 ff 00 ff 00 ff a0 bd a7 93 00 00 00 09 70 48 59 73 00 00 0b 13 00 .....bKGD..............pHYs.....
0040 00 0b 13 01 00 9a 9c 18 00 00 00 07 74 49 4d 45 07 d6 07 13 0c 31 06 de 1b 2a 10 00 00 00 1d 74 ............tIME.....1...*.....t
0060 45 58 74 43 6f 6d 6d 65 6e 74 00 43 72 65 61 74 65 64 20 77 69 74 68 20 54 68 65 20 47 49 4d 50 EXtComment.Created.with.The.GIMP
0080 ef 64 25 6e 00 00 00 d9 49 44 41 54 78 da ed dd 41 0a 80 30 0c 00 41 23 fe ff cb f1 0d 81 06 52 .d%n....IDATx...A..0..A#.......R
00a0 32 73 56 51 59 da 4b d0 c8 cc 67 92 88 28 1d 3f ed fe b7 79 bd 02 04 84 80 10 10 02 02 01 21 20 2sVQY.K...g..(.?...y..........!.
00c0 04 84 80 40 40 08 08 01 21 20 10 10 02 42 40 08 08 04 84 80 10 10 02 42 40 20 20 04 84 80 10 10 ...@@...!....B@........B@.......
00e0 08 08 01 21 20 04 04 02 a2 43 dc fe 00 d5 ef 03 75 7f 7f a8 7a 7d 2b 10 b6 30 10 10 02 42 40 08 ...!.....C......u...z}+..0...B@.
0100 08 04 84 80 10 10 02 02 01 21 20 04 84 80 40 40 1c f4 55 4f e8 fe 3f d7 b6 79 9a db e7 99 ac 40 .........!....@@..UO..?..y.....@
0120 d8 c2 10 10 02 42 40 20 20 04 84 80 10 10 08 08 01 21 20 04 04 02 42 40 8c 52 9e 07 9a 36 af d3 .....B@..........!....B@.R...6..
0140 7d 3f db e6 93 ac 40 08 08 01 21 20 10 10 02 42 40 08 08 04 84 80 10 10 02 02 01 21 20 04 c4 d5 }?....@...!....B@..........!....
0160 7e 8b c2 15 a9 b3 6f d5 23 00 00 00 00 49 45 4e 44 ae 42 60 82 ~.....o.#....IEND.B`.
t; 2009-12-07 01:23:19 +0100 committer Andreas Rumpf <andreas@andreas-desktop> 2009-12-07 01:23:19 +0100 version 0.8.5: added Nimrod version of the compiler' href='/ahoang/Nim/commit/rod/main.nim?h=devel&id=e254741541b0389dfb0b675116c76a6a144b90b7'>e25474154 ^
688c54d8f ^


aaf49947e ^

61fb83ecb ^
cb4d81065 ^

6a9baf3fd ^
cb4d81065 ^
86556ebfd ^
aa88e150d ^
cb4d81065 ^


342e50e26 ^
e25474154 ^
b92fcacb9 ^


e25474154 ^
ca4b971bc ^


4910a87c6 ^

bf6c2c5cc ^
b06c0f97a ^

bf6c2c5cc ^
4910a87c6 ^

826c1e2d7 ^
b92fcacb9 ^

826c1e2d7 ^
342e50e26 ^
ca4b971bc ^
006ee79a9 ^
86556ebfd ^


e25474154 ^
826c1e2d7 ^
342e50e26 ^

b92fcacb9 ^
826c1e2d7 ^
e25474154 ^
cb4d81065 ^

b9f8528db ^
cb4d81065 ^





01ab5948a ^
826c1e2d7 ^
342e50e26 ^
ca4b971bc ^









342e50e26 ^
b92fcacb9 ^

aa175e9e5 ^
6d125da93 ^
3d88d06b3 ^







826c1e2d7 ^
52e36a19a ^

342e50e26 ^
328e7a100 ^
ca4b971bc ^



328e7a100 ^
ca4b971bc ^
f9bd8cc98 ^
826c1e2d7 ^
342e50e26 ^

7aad0d654 ^
cb4d81065 ^

7920dc289 ^
ca4b971bc ^





cb4d81065 ^







7920dc289 ^
ca4b971bc ^
e25474154 ^
826c1e2d7 ^
342e50e26 ^

adbabf145 ^
342e50e26 ^
b92fcacb9 ^


091c1b307 ^
826c1e2d7 ^
342e50e26 ^
826c1e2d7 ^

342e50e26 ^
826c1e2d7 ^
c617479c6 ^
9e6fb3f69 ^
c617479c6 ^
826c1e2d7 ^
e25474154 ^
091c1b307 ^

826c1e2d7 ^

091c1b307 ^
826c1e2d7 ^
342e50e26 ^
826c1e2d7 ^

29db0d858 ^
826c1e2d7 ^

091c1b307 ^
b7116a28e ^
86556ebfd ^
92b8fac94 ^
aaf49947e ^

a58a2f382 ^
9207492bb ^

b7116a28e ^
aaf49947e ^
9207492bb ^
328e7a100 ^
aaf49947e ^
92b8fac94 ^
aaf49947e ^
86556ebfd ^
aaf49947e ^
86bf97a73 ^
86bf97a73 ^

826c1e2d7 ^
342e50e26 ^
826c1e2d7 ^
aaf49947e ^
ddc6cec69 ^
d634da775 ^
b92fcacb9 ^
328e7a100 ^
342e50e26 ^
92b8fac94 ^
342e50e26 ^
aaf49947e ^
e25474154 ^
328e7a100 ^
9c65ea0d1 ^
826c1e2d7 ^
8090b6c02 ^
328e7a100 ^
342e50e26 ^
826c1e2d7 ^
5131b3cea ^
328e7a100 ^
342e50e26 ^
826c1e2d7 ^
8d734244b ^
328e7a100 ^
f530bbd63 ^
f182d8d70 ^
826c1e2d7 ^
aaf49947e ^
342e50e26 ^
aaf49947e ^
cb4d81065 ^



ca4b971bc ^





cb4d81065 ^
a4d40d137 ^
cb4d81065 ^






a4d40d137 ^
cb4d81065 ^






aaf49947e ^
cb4d81065 ^





aaf49947e ^
cb4d81065 ^





500394225 ^
cb4d81065 ^








500394225 ^
cb4d81065 ^







870567d08 ^
cb4d81065 ^







76235348f ^
cb4d81065 ^





aaf49947e ^
328e7a100 ^
826c1e2d7 ^
c98696d74 ^
328e7a100 ^
342e50e26 ^

89f9772f1 ^

342e50e26 ^
89f9772f1 ^

86556ebfd ^
89f9772f1 ^
369581901 ^







fc7b3a7c2 ^
369581901 ^
89f9772f1 ^
86556ebfd ^
89f9772f1 ^
fc7b3a7c2 ^
ca4b971bc ^
fc7b3a7c2 ^
e98d54b05 ^
fc7b3a7c2 ^

89f9772f1 ^

328e7a100 ^
89f9772f1 ^
328e7a100 ^
acb6a3665 ^
328e7a100 ^

89f9772f1 ^
86556ebfd ^
c98696d74 ^
328e7a100 ^
826c1e2d7 ^
aaf49947e ^
328e7a100 ^
342e50e26 ^
545b1582c ^
aaf49947e ^
328e7a100 ^
342e50e26 ^

328e7a100 ^
841a179d2 ^
328e7a100 ^
826c1e2d7 ^
091c1b307 ^
73c306258 ^
826c1e2d7 ^
178275f49 ^

328e7a100 ^
7aad0d654 ^
328e7a100 ^
826c1e2d7 ^
86bf97a73 ^
342e50e26 ^
aaf49947e ^
342e50e26 ^
328e7a100 ^
9753782f9 ^
ab31b776e ^
9753782f9 ^

342e50e26 ^
328e7a100 ^
9753782f9 ^
721534119 ^

aa175e9e5 ^
f8dd74a07 ^
86bf97a73 ^




31f3034c3 ^

f644e3079 ^
342e50e26 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384

 
                            
                                         




                                                   
                                                        
 


                                                             

                                                                             
                      

                                                   
                                                                         
                                             
                                                 
 


                               
                                  
 


                                     
 


                                                                                 

                     
                                                             

                                                                            
                                          

           
                                           

                                    
                       
                                        
                      
                             


                                                    
 
                                       

                                                                    
                                                                          
                       
 

                                                    
                                       





                                                                      
 
                                            
                         









                                                                  
                         

                               
 
                                                                                                    







                                                              
                       

                                   
                                       
                        



                                                                                                   
                                                  
                          
 
                                            

                                                        
 

                                               
                           





                                                           







                                                                                 
                                                  
                          
 
                                            

                                                 
                                              
                                                           


                                  
 
                                             
                                                                    

                            
                                      
                                                                                        
       
                                   
                               
                                                
 

                                                   

                                                              
 
                                                   
                               

                              
                                                          

                                                                
 
                                                        
                                                                 
                                      

                   
               

                  
                                          
               
                       
                           
                                    
                 
       
                                                                     
 
     

                             
                                       
                         
                         
 
                         
                                                                          
                    
                                
                                    
            
                             
                                        
                                        
                            
                                           
                            
                           
                              
                                             
                            
                           
                             
                                              
                            
           
                     
                         
                           
                              
         
                                                                                          
                         



                                                         





                                                                            
                               
            






                                                               
                   






                                                               
                





                                                               
               





                                                               
                








                                                               
                           







                                                               
             







                                                               
                  





                                                               
                 
                           
                           
            
                      

                                                   

                                      
                                                                             

                                
                                                                  
 







                                                                    
 
                       
                                                
                                                             
                                                      
                                           
                                                  
                                                
                                                             

                                         

       
                                                           
         
                                                                 
                                          

                                                                                              
 
                                                             
             
                       
                       
             
                       
                        
                                                       
            
                      

                            
                                                                                
              
                             
                             
         
                                            
                                            

                                    
                      
                  
                            
                            
       
                                                                      
 
                               
                                                    
                                    
                                                        

                                             
                                                        
                                                                         
                       

                                                                      
                                    
 




                                        

                                                                                
 
                       
#
#
#           The Nim Compiler
#        (c) Copyright 2015 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

# implements the command dispatcher and several commands

when not defined(nimcore):
  {.error: "nimcore MUST be defined for Nim's core tooling".}

import
  llstream, strutils, ast, astalgo, lexer, syntaxes, renderer, options, msgs,
  os, condsyms, times,
  wordrecg, sem, semdata, idents, passes, extccomp,
  cgen, json, nversion,
  platform, nimconf, importer, passaux, depends, vm, vmdef, types, idgen,
  parser, modules, ccgutils, sigmatch, ropes,
  modulegraphs, tables, rod, lineinfos, pathutils

when not defined(leanCompiler):
  import jsgen, docgen, docgen2

from magicsys import resetSysTypes

proc semanticPasses(g: ModuleGraph) =
  registerPass g, verbosePass
  registerPass g, semPass

proc writeDepsFile(g: ModuleGraph) =
  let fname = g.config.nimcacheDir / RelativeFile(g.config.projectName & ".deps")
  let f = open(fname.string, fmWrite)
  for m in g.modules:
    if m != nil:
      f.writeLine(toFullPath(g.config, m.position.FileIndex))
  for k in g.inclToMod.keys:
    if g.getModule(k).isNil:  # don't repeat includes which are also modules
      f.writeLine(toFullPath(g.config, k))
  f.close()

proc commandGenDepend(graph: ModuleGraph) =
  semanticPasses(graph)
  registerPass(graph, gendependPass)
  compileProject(graph)
  let project = graph.config.projectFull
  writeDepsFile(graph)
  generateDot(graph, project)
  execExternalProgram(graph.config, "dot -Tpng -o" &
      changeFileExt(project, "png").string &
      ' ' & changeFileExt(project, "dot").string)

proc commandCheck(graph: ModuleGraph) =
  graph.config.errorMax = high(int)  # do not stop after first error
  defineSymbol(graph.config.symbols, "nimcheck")
  semanticPasses(graph)  # use an empty backend for semantic checking only
  compileProject(graph)

when not defined(leanCompiler):
  proc commandDoc2(graph: ModuleGraph; json: bool) =
    handleDocOutputOptions graph.config
    graph.config.errorMax = high(int)  # do not stop after first error
    semanticPasses(graph)
    if json: registerPass(graph, docgen2JsonPass)
    else: registerPass(graph, docgen2Pass)
    compileProject(graph)
    finishDoc2Pass(graph.config.projectName)

proc commandCompileToC(graph: ModuleGraph) =
  let conf = graph.config

  if conf.outDir.isEmpty:
    conf.outDir = conf.projectPath
  if conf.outFile.isEmpty:
    let targetName = if optGenDynLib in conf.globalOptions:
      platform.OS[conf.target.targetOS].dllFrmt % conf.projectName
    else:
      conf.projectName & platform.OS[conf.target.targetOS].exeExt
    conf.outFile = RelativeFile targetName

  extccomp.initVars(conf)
  semanticPasses(graph)
  registerPass(graph, cgenPass)

  if {optRun, optForceFullMake} * conf.globalOptions == {optRun} or isDefined(conf, "nimBetterRun"):
    let proj = changeFileExt(conf.projectFull, "")
    if not changeDetectedViaJsonBuildInstructions(conf, proj):
      # nothing changed
      # Little hack here in order to not lose our precious
      # hintSuccessX message:
      conf.notes.incl hintSuccessX
      return

  compileProject(graph)
  if graph.config.errorCounter > 0:
    return # issue #9933
  cgenWriteModules(graph.backend, conf)
  if conf.cmd != cmdRun:
    extccomp.callCCompiler(conf)
    # for now we do not support writing out a .json file with the build instructions when HCR is on
    if not conf.hcrOn:
      extccomp.writeJsonBuildInstructions(conf)
    if optGenScript in graph.config.globalOptions:
      writeDepsFile(graph)

proc commandJsonScript(graph: ModuleGraph) =
  let proj = changeFileExt(graph.config.projectFull, "")
  extccomp.runJsonBuildInstructions(graph.config, proj)

when not defined(leanCompiler):
  proc commandCompileToJS(graph: ModuleGraph) =
    let conf = graph.config

    if conf.outDir.isEmpty:
      conf.outDir = conf.projectPath
    if conf.outFile.isEmpty:
      conf.outFile = RelativeFile(conf.projectName & ".js")

    #incl(gGlobalOptions, optSafeCode)
    setTarget(graph.config.target, osJS, cpuJS)
    #initDefines()
    defineSymbol(graph.config.symbols, "ecmascript") # For backward compatibility
    defineSymbol(graph.config.symbols, "js")
    semanticPasses(graph)
    registerPass(graph, JSgenPass)
    compileProject(graph)
    if optGenScript in graph.config.globalOptions:
      writeDepsFile(graph)

proc interactivePasses(graph: ModuleGraph) =
  initDefines(graph.config.symbols)
  defineSymbol(graph.config.symbols, "nimscript")
  # note: seems redundant with -d:nimHasLibFFI
  when hasFFI: defineSymbol(graph.config.symbols, "nimffi")
  registerPass(graph, verbosePass)
  registerPass(graph, semPass)
  registerPass(graph, evalPass)

proc commandInteractive(graph: ModuleGraph) =
  graph.config.errorMax = high(int)  # do not stop after first error
  interactivePasses(graph)
  compileSystemModule(graph)
  if graph.config.commandArgs.len > 0:
    discard graph.compileModule(fileInfoIdx(graph.config, graph.config.projectFull), {})
  else:
    var m = graph.makeStdinModule()
    incl(m.flags, sfMainModule)
    processModule(graph, m, llStreamOpenStdIn())

const evalPasses = [verbosePass, semPass, evalPass]

proc evalNim(graph: ModuleGraph; nodes: PNode, module: PSym) =
  carryPasses(graph, nodes, module, evalPasses)

proc commandEval(graph: ModuleGraph; exp: string) =
  if graph.systemModule == nil:
    interactivePasses(graph)
    compileSystemModule(graph)
  let echoExp = "echo \"eval\\t\", " & "repr(" & exp & ")"
  evalNim(graph, echoExp.parseString(graph.cache, graph.config),
    makeStdinModule(graph))

proc commandScan(cache: IdentCache, config: ConfigRef) =
  var f = addFileExt(AbsoluteFile mainCommandArg(config), NimExt)
  var stream = llStreamOpen(f, fmRead)
  if stream != nil:
    var
      L: TLexer
      tok: TToken
    initToken(tok)
    openLexer(L, f, stream, cache, config)
    while true:
      rawGetTok(L, tok)
      printTok(config, tok)
      if tok.tokType == tkEof: break
    closeLexer(L)
  else:
    rawMessage(config, errGenerated, "cannot open file: " & f.string)

const
  PrintRopeCacheStats = false

proc mainCommand*(graph: ModuleGraph) =
  let conf = graph.config
  let cache = graph.cache

  setupModuleCache(graph)
  # In "nim serve" scenario, each command must reset the registered passes
  clearPasses(graph)
  conf.lastCmdTime = epochTime()
  conf.searchPaths.add(conf.libpath)
  setId(100)
  case conf.command.normalize
  of "c", "cc", "compile", "compiletoc":
    # compile means compileToC currently
    conf.cmd = cmdCompileToC
    defineSymbol(graph.config.symbols, "c")
    commandCompileToC(graph)
  of "cpp", "compiletocpp":
    conf.cmd = cmdCompileToCpp
    defineSymbol(graph.config.symbols, "cpp")
    commandCompileToC(graph)
  of "objc", "compiletooc":
    conf.cmd = cmdCompileToOC
    defineSymbol(graph.config.symbols, "objc")
    commandCompileToC(graph)
  of "run":
    conf.cmd = cmdRun
    when hasTinyCBackend:
      extccomp.setCC("tcc")
      commandCompileToC(graph)
    else:
      rawMessage(conf, errGenerated, "'run' command not available; rebuild with -d:tinyc")
  of "js", "compiletojs":
    when defined(leanCompiler):
      quit "compiler wasn't built with JS code generator"
    else:
      conf.cmd = cmdCompileToJS
      if conf.hcrOn:
        # XXX: At the moment, system.nim cannot be compiled in JS mode
        # with "-d:useNimRtl". The HCR option has been processed earlier
        # and it has added this define implictly, so we must undo that here.
        # A better solution might be to fix system.nim
        undefSymbol(conf.symbols, "useNimRtl")
      commandCompileToJS(graph)
  of "doc0":
    when defined(leanCompiler):
      quit "compiler wasn't built with documentation generator"
    else:
      wantMainModule(conf)
      conf.cmd = cmdDoc
      loadConfigs(DocConfig, cache, conf)
      commandDoc(cache, conf)
  of "doc2", "doc":
    when defined(leanCompiler):
      quit "compiler wasn't built with documentation generator"
    else:
      conf.cmd = cmdDoc
      loadConfigs(DocConfig, cache, conf)
      defineSymbol(conf.symbols, "nimdoc")
      commandDoc2(graph, false)
  of "rst2html":
    when defined(leanCompiler):
      quit "compiler wasn't built with documentation generator"
    else:
      conf.cmd = cmdRst2html
      loadConfigs(DocConfig, cache, conf)
      commandRst2Html(cache, conf)
  of "rst2tex":
    when defined(leanCompiler):
      quit "compiler wasn't built with documentation generator"
    else:
      conf.cmd = cmdRst2tex
      loadConfigs(DocTexConfig, cache, conf)
      commandRst2TeX(cache, conf)
  of "jsondoc0":
    when defined(leanCompiler):
      quit "compiler wasn't built with documentation generator"
    else:
      wantMainModule(conf)
      conf.cmd = cmdDoc
      loadConfigs(DocConfig, cache, conf)
      wantMainModule(conf)
      defineSymbol(conf.symbols, "nimdoc")
      commandJson(cache, conf)
  of "jsondoc2", "jsondoc":
    when defined(leanCompiler):
      quit "compiler wasn't built with documentation generator"
    else:
      conf.cmd = cmdDoc
      loadConfigs(DocConfig, cache, conf)
      wantMainModule(conf)
      defineSymbol(conf.symbols, "nimdoc")
      commandDoc2(graph, true)
  of "ctags":
    when defined(leanCompiler):
      quit "compiler wasn't built with documentation generator"
    else:
      wantMainModule(conf)
      conf.cmd = cmdDoc
      loadConfigs(DocConfig, cache, conf)
      defineSymbol(conf.symbols, "nimdoc")
      commandTags(cache, conf)
  of "buildindex":
    when defined(leanCompiler):
      quit "compiler wasn't built with documentation generator"
    else:
      conf.cmd = cmdDoc
      loadConfigs(DocConfig, cache, conf)
      commandBuildIndex(cache, conf)
  of "gendepend":
    conf.cmd = cmdGenDepend
    commandGenDepend(graph)
  of "dump":
    conf.cmd = cmdDump
    if getConfigVar(conf, "dump.format") == "json":
      wantMainModule(conf)

      var definedSymbols = newJArray()
      for s in definedSymbolNames(conf.symbols): definedSymbols.elems.add(%s)

      var libpaths = newJArray()
      for dir in conf.searchPaths: libpaths.elems.add(%dir.string)

      var hints = newJObject() # consider factoring with `listHints`
      for a in hintMin..hintMax:
        let key = lineinfos.HintsToStr[ord(a) - ord(hintMin)]
        hints[key] = %(a in conf.notes)
      var warnings = newJObject()
      for a in warnMin..warnMax:
        let key = lineinfos.WarningsToStr[ord(a) - ord(warnMin)]
        warnings[key] = %(a in conf.notes)

      var dumpdata = %[
        (key: "version", val: %VersionAsString),
        (key: "project_path", val: %conf.projectFull.string),
        (key: "defined_symbols", val: definedSymbols),
        (key: "lib_paths", val: %libpaths),
        (key: "outdir", val: %conf.outDir.string),
        (key: "out", val: %conf.outFile.string),
        (key: "nimcache", val: %getNimcacheDir(conf).string),
        (key: "hints", val: hints),
        (key: "warnings", val: warnings),
      ]

      msgWriteln(conf, $dumpdata, {msgStdout, msgSkipHook})
    else:
      msgWriteln(conf, "-- list of currently defined symbols --",
                 {msgStdout, msgSkipHook})
      for s in definedSymbolNames(conf.symbols): msgWriteln(conf, s, {msgStdout, msgSkipHook})
      msgWriteln(conf, "-- end of list --", {msgStdout, msgSkipHook})

      for it in conf.searchPaths: msgWriteln(conf, it.string)
  of "check":
    conf.cmd = cmdCheck
    commandCheck(graph)
  of "parse":
    conf.cmd = cmdParse
    wantMainModule(conf)
    discard parseFile(conf.projectMainIdx, cache, conf)
  of "scan":
    conf.cmd = cmdScan
    wantMainModule(conf)
    commandScan(cache, conf)
    msgWriteln(conf, "Beware: Indentation tokens depend on the parser's state!")
  of "secret":
    conf.cmd = cmdInteractive
    commandInteractive(graph)
  of "e":
    incl conf.globalOptions, optWasNimscript
    commandEval(graph, mainCommandArg(conf))
  of "nop", "help":
    # prevent the "success" message:
    conf.cmd = cmdDump
  of "jsonscript":
    conf.cmd = cmdJsonScript
    commandJsonScript(graph)
  else:
    rawMessage(conf, errGenerated, "invalid command: " & conf.command)

  if conf.errorCounter == 0 and
     conf.cmd notin {cmdInterpret, cmdRun, cmdDump}:
    when declared(system.getMaxMem):
      let usedMem = formatSize(getMaxMem()) & " peakmem"
    else:
      let usedMem = formatSize(getTotalMem())
    rawMessage(conf, hintSuccessX, [$conf.linesCompiled,
               formatFloat(epochTime() - conf.lastCmdTime, ffDecimal, 3),
               usedMem,
               if isDefined(conf, "danger"): "Dangerous Release Build"
               elif isDefined(conf, "release"): "Release Build"
               else: "Debug Build"])

  when PrintRopeCacheStats:
    echo "rope cache stats: "
    echo "  tries : ", gCacheTries
    echo "  misses: ", gCacheMisses
    echo "  int tries: ", gCacheIntTries
    echo "  efficiency: ", formatFloat(1-(gCacheMisses.float/gCacheTries.float),
                                       ffDecimal, 3)

  resetAttributes(conf)