summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-09-05 08:48:51 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-09-05 08:48:58 +0200
commitb880359e84588d1a016e2cbc49ea9389692647af (patch)
tree1a73a6fc44bdd02320d0976b045fe4c3eda2f6d9 /lib/pure
parentc02159dde43f6d04e33eb273c336732d557074b5 (diff)
downloadNim-b880359e84588d1a016e2cbc49ea9389692647af.tar.gz
parsesql: better 'len' operation; added '[]' access
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/parsesql.nim9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/pure/parsesql.nim b/lib/pure/parsesql.nim
index 59a93df91..00d007d01 100644
--- a/lib/pure/parsesql.nim
+++ b/lib/pure/parsesql.nim
@@ -566,8 +566,13 @@ proc newNode(k: SqlNodeKind, s: string): SqlNode =
   result.strVal = s
 
 proc len*(n: SqlNode): int =
-  if isNil(n.sons): result = 0
-  else: result = n.sons.len
+  if n.kind in {nkIdent, nkStringLit, nkBitStringLit, nkHexStringLit,
+                nkIntegerLit, nkNumericLit}:
+    result = 0
+  else:
+    result = n.sons.len
+
+proc `[]`*(n: SqlNode; i: int): SqlNode = n.sons[i]
 
 proc add*(father, n: SqlNode) =
   if isNil(father.sons): father.sons = @[]