summary refs log tree commit diff stats
path: root/nimsuggest/sexp.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-05-27 16:38:03 +0200
committerAndreas Rumpf <rumpf_a@web.de>2019-05-27 21:29:02 +0200
commitdfcd82669b5c803b5305a95571886aed6e23b339 (patch)
tree7725efd2efb3ad22ab0d0e5727366ff0865aa4e4 /nimsuggest/sexp.nim
parent795044ed2b9efd20ea220104ffc2894421930b2c (diff)
downloadNim-dfcd82669b5c803b5305a95571886aed6e23b339.tar.gz
update nimsuggest
Diffstat (limited to 'nimsuggest/sexp.nim')
-rw-r--r--nimsuggest/sexp.nim54
1 files changed, 15 insertions, 39 deletions
diff --git a/nimsuggest/sexp.nim b/nimsuggest/sexp.nim
index 910ecb9e9..4fa93a6ee 100644
--- a/nimsuggest/sexp.nim
+++ b/nimsuggest/sexp.nim
@@ -292,52 +292,37 @@ proc raiseParseErr*(p: SexpParser, msg: string) {.noinline, noreturn.} =
 
 proc newSString*(s: string): SexpNode {.procvar.}=
   ## Creates a new `SString SexpNode`.
-  new(result)
-  result.kind = SString
-  result.str = s
+  result = SexpNode(kind: SString, str: s)
 
 proc newSStringMove(s: string): SexpNode =
-  new(result)
-  result.kind = SString
+  result = SexpNode(kind: SString)
   shallowCopy(result.str, s)
 
 proc newSInt*(n: BiggestInt): SexpNode {.procvar.} =
   ## Creates a new `SInt SexpNode`.
-  new(result)
-  result.kind = SInt
-  result.num  = n
+  result = SexpNode(kind: SInt, num: n)
 
 proc newSFloat*(n: float): SexpNode {.procvar.} =
   ## Creates a new `SFloat SexpNode`.
-  new(result)
-  result.kind = SFloat
-  result.fnum  = n
+  result = SexpNode(kind: SFloat, fnum: n)
 
 proc newSNil*(): SexpNode {.procvar.} =
   ## Creates a new `SNil SexpNode`.
-  new(result)
+  result = SexpNode(kind: SNil)
 
 proc newSCons*(car, cdr: SexpNode): SexpNode {.procvar.} =
   ## Creates a new `SCons SexpNode`
-  new(result)
-  result.kind = SCons
-  result.car = car
-  result.cdr = cdr
+  result = SexpNode(kind: SCons, car: car, cdr: cdr)
 
 proc newSList*(): SexpNode {.procvar.} =
   ## Creates a new `SList SexpNode`
-  new(result)
-  result.kind = SList
-  result.elems = @[]
+  result = SexpNode(kind: SList, elems: @[])
 
 proc newSSymbol*(s: string): SexpNode {.procvar.} =
-  new(result)
-  result.kind = SSymbol
-  result.symbol = s
+  result = SexpNode(kind: SSymbol, symbol: s)
 
 proc newSSymbolMove(s: string): SexpNode =
-  new(result)
-  result.kind = SSymbol
+  result = SexpNode(kind: SSymbol)
   shallowCopy(result.symbol, s)
 
 proc getStr*(n: SexpNode, default: string = ""): string =
@@ -386,36 +371,27 @@ proc getCons*(n: SexpNode, defaults: Cons = (newSNil(), newSNil())): Cons =
 
 proc sexp*(s: string): SexpNode =
   ## Generic constructor for SEXP data. Creates a new `SString SexpNode`.
-  new(result)
-  result.kind = SString
-  result.str = s
+  result = SexpNode(kind: SString, str: s)
 
 proc sexp*(n: BiggestInt): SexpNode =
   ## Generic constructor for SEXP data. Creates a new `SInt SexpNode`.
-  new(result)
-  result.kind = SInt
-  result.num  = n
+  result = SexpNode(kind: SInt, num: n)
 
 proc sexp*(n: float): SexpNode =
   ## Generic constructor for SEXP data. Creates a new `SFloat SexpNode`.
-  new(result)
-  result.kind = SFloat
-  result.fnum  = n
+  result = SexpNode(kind: SFloat, fnum: n)
 
 proc sexp*(b: bool): SexpNode =
   ## Generic constructor for SEXP data. Creates a new `SSymbol
   ## SexpNode` with value t or `SNil SexpNode`.
-  new(result)
   if b:
-    result.kind = SSymbol
-    result.symbol = "t"
+    result = SexpNode(kind: SSymbol, symbol: "t")
   else:
-    result.kind = SNil
+    result = SexpNode(kind: SNil)
 
 proc sexp*(elements: openArray[SexpNode]): SexpNode =
   ## Generic constructor for SEXP data. Creates a new `SList SexpNode`
-  new(result)
-  result.kind = SList
+  result = SexpNode(kind: SList)
   newSeq(result.elems, elements.len)
   for i, p in pairs(elements): result.elems[i] = p