summary refs log tree commit diff stats
path: root/compiler/parser.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-08-22 19:28:58 +0200
committerAraq <rumpf_a@web.de>2013-08-22 19:28:58 +0200
commita8c8a85135e73777ea2c115bf1352456c1dd69aa (patch)
treea06a9a97f6e98480d98d6b063dfe224951c233db /compiler/parser.nim
parentcf38d635bf8e94abbc68cca55fd6deb6ebc3da5d (diff)
parentca3a4ce6721c87cfcbb9eb02002ecf8aeb89233c (diff)
downloadNim-a8c8a85135e73777ea2c115bf1352456c1dd69aa.tar.gz
Merge branch 'master' of github.com:Araq/Nimrod
Diffstat (limited to 'compiler/parser.nim')
-rw-r--r--compiler/parser.nim20
1 files changed, 12 insertions, 8 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim
index a92dde74f..699a50c62 100644
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -627,6 +627,13 @@ proc identOrLiteral(p: var TParser, mode: TPrimaryMode): PNode =
     getTok(p)  # we must consume a token here to prevend endless loops!
     result = ast.emptyNode
 
+proc namedParams(p: var TParser, callee: PNode,
+                 kind: TNodeKind, endTok: TTokType): PNode =
+  let a = callee
+  result = newNodeP(kind, p)
+  addSon(result, a)
+  exprColonEqExprListAux(p, endTok, result)
+
 proc primarySuffix(p: var TParser, r: PNode): PNode =
   #| primarySuffix = '(' (exprColonEqExpr comma?)* ')' doBlocks?
   #|               | doBlocks
@@ -636,11 +643,8 @@ proc primarySuffix(p: var TParser, r: PNode): PNode =
   result = r
   while p.tok.indent < 0:
     case p.tok.tokType
-    of tkParLe: 
-      var a = result
-      result = newNodeP(nkCall, p)
-      addSon(result, a)
-      exprColonEqExprListAux(p, tkParRi, result)
+    of tkParLe:
+      result = namedParams(p, result, nkCall, tkParRi)
       if result.len > 1 and result.sons[1].kind == nkExprColonExpr:
         result.kind = nkObjConstr
       else:
@@ -653,10 +657,10 @@ proc primarySuffix(p: var TParser, r: PNode): PNode =
     of tkDot:
       result = dotExpr(p, result)
       result = parseGStrLit(p, result)
-    of tkBracketLe: 
-      result = indexExprList(p, result, nkBracketExpr, tkBracketRi)
+    of tkBracketLe:
+      result = namedParams(p, result, nkBracketExpr, tkBracketRi)
     of tkCurlyLe:
-      result = indexExprList(p, result, nkCurlyExpr, tkCurlyRi)
+      result = namedParams(p, result, nkCurlyExpr, tkCurlyRi)
     else: break
 
 proc primary(p: var TParser, mode: TPrimaryMode): PNode