parsesql: better 'len' operation; added '[]' access
This commit is contained in:
parent
c02159dde4
commit
b880359e84
1 changed files with 7 additions and 2 deletions
|
|
@ -566,8 +566,13 @@ proc newNode(k: SqlNodeKind, s: string): SqlNode =
|
||||||
result.strVal = s
|
result.strVal = s
|
||||||
|
|
||||||
proc len*(n: SqlNode): int =
|
proc len*(n: SqlNode): int =
|
||||||
if isNil(n.sons): result = 0
|
if n.kind in {nkIdent, nkStringLit, nkBitStringLit, nkHexStringLit,
|
||||||
else: result = n.sons.len
|
nkIntegerLit, nkNumericLit}:
|
||||||
|
result = 0
|
||||||
|
else:
|
||||||
|
result = n.sons.len
|
||||||
|
|
||||||
|
proc `[]`*(n: SqlNode; i: int): SqlNode = n.sons[i]
|
||||||
|
|
||||||
proc add*(father, n: SqlNode) =
|
proc add*(father, n: SqlNode) =
|
||||||
if isNil(father.sons): father.sons = @[]
|
if isNil(father.sons): father.sons = @[]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue