summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-12-09 13:47:45 +0100
committerGitHub <noreply@github.com>2018-12-09 13:47:45 +0100
commit606b43ba1130b5672e91ddd156d81267634ed465 (patch)
treebf98c523a1fd3527b608b49e738f988fb1495504 /compiler/semstmts.nim
parent981dcc6b9a9f0ea24a4fba24498854dc8d94ff27 (diff)
parent96647618c289dc5ed025c141b4f7c8c191d4ab2b (diff)
downloadNim-606b43ba1130b5672e91ddd156d81267634ed465.tar.gz
Merge pull request #9911 from nc-x/fixes-#9627
`include` now accepts collective arguments
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim30
1 files changed, 23 insertions, 7 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 2e2a3a20a..04fe91cfb 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -1843,17 +1843,33 @@ proc semMacroDef(c: PContext, n: PNode): PNode =
   if n.sons[bodyPos].kind == nkEmpty:
     localError(c.config, n.info, errImplOfXexpected % s.name.s)
 
+proc incMod(c: PContext, n: PNode, it: PNode, includeStmtResult: PNode) =
+  var f = checkModuleName(c.config, it)
+  if f != InvalidFileIDX:
+    if containsOrIncl(c.includedFiles, f.int):
+      localError(c.config, n.info, errRecursiveDependencyX % toFilename(c.config, f))
+    else:
+      addSon(includeStmtResult, semStmt(c, c.graph.includeFileCallback(c.graph, c.module, f), {}))
+      excl(c.includedFiles, f.int)
+
 proc evalInclude(c: PContext, n: PNode): PNode =
   result = newNodeI(nkStmtList, n.info)
   addSon(result, n)
   for i in countup(0, sonsLen(n) - 1):
-    var f = checkModuleName(c.config, n.sons[i])
-    if f != InvalidFileIDX:
-      if containsOrIncl(c.includedFiles, f.int):
-        localError(c.config, n.info, errRecursiveDependencyX % toFilename(c.config, f))
-      else:
-        addSon(result, semStmt(c, c.graph.includeFileCallback(c.graph, c.module, f), {}))
-        excl(c.includedFiles, f.int)
+    var imp: PNode
+    let it = n.sons[i]
+    if it.kind == nkInfix and it.len == 3 and it[2].kind == nkBracket:
+      let sep = it[0]
+      let dir = it[1]
+      imp = newNodeI(nkInfix, it.info)
+      imp.add sep
+      imp.add dir
+      imp.add sep # dummy entry, replaced in the loop
+      for x in it[2]:
+        imp.sons[2] = x
+        incMod(c, n, imp, result)
+    else:
+      incMod(c, n, it, result)
 
 proc setLine(n: PNode, info: TLineInfo) =
   for i in 0 ..< safeLen(n): setLine(n.sons[i], info)