From b880359e84588d1a016e2cbc49ea9389692647af Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 5 Sep 2017 08:48:51 +0200 Subject: parsesql: better 'len' operation; added '[]' access --- lib/pure/parsesql.nim | 9 +++++++-- 1 file 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 = @[] -- cgit 1.4.1-2-gfad0