diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-04-13 17:06:46 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-04-13 17:45:58 +0200 |
commit | 47335aab4148b2cd5b28cd3012d6d6e0a0c82db7 (patch) | |
tree | 33c87e807f22b59d61dbe2aa0f42430c0d0399d3 /compiler/renderer.nim | |
parent | ab426faa226f7041c60e671ad2a3ba79b46ee1c0 (diff) | |
download | Nim-47335aab4148b2cd5b28cd3012d6d6e0a0c82db7.tar.gz |
introduce nkTupleConstr AST node for unary tuple construction; breaking change
Diffstat (limited to 'compiler/renderer.nim')
-rw-r--r-- | compiler/renderer.nim | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/renderer.nim b/compiler/renderer.nim index 0b1b0479f..7d513afb1 100644 --- a/compiler/renderer.nim +++ b/compiler/renderer.nim @@ -437,6 +437,9 @@ proc lsub(g: TSrcGen; n: PNode): int = of nkCommand: result = lsub(g, n.sons[0]) + lcomma(g, n, 1) + 1 of nkExprEqExpr, nkAsgn, nkFastAsgn: result = lsons(g, n) + 3 of nkPar, nkCurly, nkBracket, nkClosure: result = lcomma(g, n) + 2 + of nkTupleConstr: + # assume the trailing comma: + result = lcomma(g, n) + 3 of nkArgList: result = lcomma(g, n) of nkTableConstr: result = if n.len > 0: lcomma(g, n) + 2 else: len("{:}") @@ -1007,6 +1010,11 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext) = put(g, tkParLe, "(") gcomma(g, n, c) put(g, tkParRi, ")") + of nkTupleConstr: + put(g, tkParLe, "(") + gcomma(g, n, c) + if n.len == 1: put(g, tkComma, ",") + put(g, tkParRi, ")") of nkCurly: put(g, tkCurlyLe, "{") gcomma(g, n, c) |