summary refs log tree commit diff stats
path: root/lib/core/macros.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-10-08 02:14:42 +0200
committerAraq <rumpf_a@web.de>2011-10-08 02:14:42 +0200
commitc138cc36b4b4ad34f982492939db5ae16f409a88 (patch)
treeca21910d3e774e69eb4f232676c4f1d036386060 /lib/core/macros.nim
parente956abbaddfb8609bebeff6ffb9d402709020c48 (diff)
downloadNim-c138cc36b4b4ad34f982492939db5ae16f409a88.tar.gz
new syntactic construct: a{i}
Diffstat (limited to 'lib/core/macros.nim')
-rwxr-xr-xlib/core/macros.nim2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim
index 825979e27..9395366e7 100755
--- a/lib/core/macros.nim
+++ b/lib/core/macros.nim
@@ -22,7 +22,7 @@ type
     nnkTripleStrLit, nnkNilLit, nnkMetaNode, nnkDotCall, 

     nnkCommand, nnkCall, nnkCallStrLit, nnkExprEqExpr, 

     nnkExprColonExpr, nnkIdentDefs, nnkVarTuple, nnkInfix, 

-    nnkPrefix, nnkPostfix, nnkPar, nnkCurly, 

+    nnkPrefix, nnkPostfix, nnkPar, nnkCurly, nnkCurlyExpr,

     nnkBracket, nnkBracketExpr, nnkPragmaExpr, nnkRange, 

     nnkDotExpr, nnkCheckedFieldExpr, nnkDerefExpr, nnkIfExpr, 

     nnkElifExpr, nnkElseExpr, nnkLambda, nnkAccQuoted, 

part 1' href='/ahoang/Nim/commit/compiler/service.nim?h=devel&id=2df9b442c646e06cc577a723dc2592275bf9b6f5'>2df9b442c ^
9fbee85cc ^





438703f59 ^
9fbee85cc ^





92b8fac94 ^
9fbee85cc ^
92b8fac94 ^
9fbee85cc ^
















36e25a684 ^



f52ea04d2 ^

961d3de8e ^

091c1b307 ^





36e25a684 ^
e0f706804 ^
92b8fac94 ^
e0f706804 ^
091c1b307 ^
6825a69a7 ^
92b8fac94 ^
6825a69a7 ^













091c1b307 ^


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










                                                   
      
                                          
                                            
 


                



                                                                         







                                                                              
 
                                                       





                                     
                                      





                                                                   
                                                   
            
                                                       
















                                                                             



                                 

                         

                     





                                       
                  
             
                       
 
               
                 
                           













                                                                           


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

## Implements the "compiler as a service" feature.

import
  times, commands, options, msgs, nimconf,
  extccomp, strutils, os, platform, parseopt

when useCaas:
  import sockets

# We cache modules and the dependency graph. However, we don't check for
# file changes but expect the client to tell us about them, otherwise the
# repeated CRC calculations may turn out to be too slow.

var
  curCaasCmd* = ""
  lastCaasCmd* = ""
    # in caas mode, the list of defines and options will be given at start-up?
    # it's enough to check that the previous compilation command is the same?
  arguments* = ""
    # the arguments to be passed to the program that
    # should be run

proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
  var p = parseopt.initOptParser(cmd)
  var argsCount = 0
  while true: 
    parseopt.next(p)
    case p.kind
    of cmdEnd: break 
    of cmdLongoption, cmdShortOption: 
      # hint[X]:off is parsed as (p.key = "hint[X]", p.val = "off")
      # we fix this here
      var bracketLe = strutils.find(p.key, '[')
      if bracketLe >= 0: 
        var key = substr(p.key, 0, bracketLe - 1)
        var val = substr(p.key, bracketLe + 1) & ':' & p.val
        processSwitch(key, val, pass, gCmdLineInfo)
      else: 
        processSwitch(p.key, p.val, pass, gCmdLineInfo)
    of cmdArgument:
      if argsCount == 0:
        options.command = p.key
      else:
        if pass == passCmd1: options.commandArgs.add p.key
        if argsCount == 1:
          # support UNIX style filenames anywhere for portable build scripts:
          options.gProjectName = unixToNativePath(p.key)
          arguments = cmdLineRest(p)
          break
      inc argsCount
          
  if pass == passCmd2:
    if optRun notin gGlobalOptions and arguments != "":
      rawMessage(errArgsNeedRunOption, [])

proc serve*(action: proc (){.nimcall.}) =
  template execute(cmd) =
    curCaasCmd = cmd
    processCmdLine(passCmd2, cmd)
    action()
    gDirtyBufferIdx = 0
    gDirtyOriginalIdx = 0
    gErrorCounter = 0

  let typ = getConfigVar("server.type")
  case typ
  of "stdin":
    while true:
      var line = stdin.readLine.string
      if line == "quit": quit()
      execute line
      echo ""
      flushFile(stdout)

  of "tcp", "":
    when useCaas:
      var server = socket()
      let p = getConfigVar("server.port")
      let port = if p.len > 0: parseInt(p).TPort else: 6000.TPort
      server.bindAddr(port, getConfigVar("server.address"))
      var inp = "".TaintedString
      server.listen()
      new(stdoutSocket)
      while true:
        accept(server, stdoutSocket)
        stdoutSocket.readLine(inp)
        execute inp.string
        stdoutSocket.send("\c\L")
        stdoutSocket.close()
    else:
      quit "server.type not supported; compiler built without caas support"
  else:
    echo "Invalid server.type:", typ
    quit 1