diff --git a/nyml.nimble b/nyml.nimble index 9960105..996320d 100644 --- a/nyml.nimble +++ b/nyml.nimble @@ -2,7 +2,7 @@ version = "0.1.6" author = "George Lemon" -description = "A stupid simple YAML Parser. From YAML to stringified JSON (fastest) or JsonNode" +description = "A stupid simple YAML Parser. YAML to stringified JSON, JsonNode or Nim objects via pkg/jsony" license = "MIT" srcDir = "src" # Dependencies @@ -16,7 +16,7 @@ task tests, "Run test": task dev, "compile nyml": echo "\n✨ Compiling..." & "\n" - exec "nim --gc:arc --out:bin/nyml --hints:off --threads:on c src/nyml.nim" + exec "nim --mm:arc --out:bin/nyml --hints:off --threads:on c src/nyml.nim" task bench, "benchmark": - exec "nim c --gc:arc -d:danger -d:release benchmarks/test.nim" \ No newline at end of file + exec "nim c --mm:arc -d:danger -d:release benchmarks/test.nim" \ No newline at end of file diff --git a/src/nyml.nim b/src/nyml.nim index 02ccee1..abb14e9 100644 --- a/src/nyml.nim +++ b/src/nyml.nim @@ -1,10 +1,9 @@ -# A stupid simple YAML-like parser. +# A stupid simple YAML-like parser. From YAML to JsonNode, +# stringified JSON or Nim objects via pkg/jsony. # -# Can parse YAML to JsonNode, stringified JSON or Nim objects via JSONY -# -# (c) 2023 yamlike | MIT License -# Made by Humans from OpenPeep -# https://github.com/openpeeps/yamlike +# (c) 2023 nyml | MIT License +# Made by Humans from OpenPeeps +# https://github.com/openpeeps/nyml import jsony import std/macros @@ -70,5 +69,5 @@ template fromYaml*(str: string, obj: typedesc[object]): untyped = jsony.fromJson(jsonContent, obj) # when isMainModule: -# # echo yaml(readFile("test.yml"), data = %*{"hello": "yepsi"}) -# echo yaml(readFile("test.yml"), data = %*{"hello": "yepsi"}).toJsonStr() \ No newline at end of file + # echo yaml(readFile("test.yml"), data = %*{"hello": "yepsi"}) + # echo yaml(readFile("test.yml"), data = %*{"hello": "yepsi"}).toJsonStr() \ No newline at end of file diff --git a/src/nyml/dump.nim b/src/nyml/dump.nim index f326969..e0e94b0 100644 --- a/src/nyml/dump.nim +++ b/src/nyml/dump.nim @@ -1,10 +1,9 @@ -# A stupid simple YAML-like parser. +# A stupid simple YAML-like parser. From YAML to JsonNode, +# stringified JSON or Nim objects via pkg/jsony. # -# Can parse YAML to JsonNode, stringified JSON or Nim objects via JSONY -# -# (c) 2023 yamlike | MIT License -# Made by Humans from OpenPeep -# https://github.com/openpeeps/yamlike +# (c) 2023 nyml | MIT License +# Made by Humans from OpenPeeps +# https://github.com/openpeeps/nyml import jsony import std/[json, strutils] diff --git a/src/nyml/meta.nim b/src/nyml/meta.nim index 59b224e..0b6f6d3 100644 --- a/src/nyml/meta.nim +++ b/src/nyml/meta.nim @@ -1,10 +1,9 @@ -# A stupid simple YAML-like parser. +# A stupid simple YAML-like parser. From YAML to JsonNode, +# stringified JSON or Nim objects via pkg/jsony. # -# Can parse YAML to JsonNode, stringified JSON or Nim objects via JSONY -# -# (c) 2023 yamlike | MIT License -# Made by Humans from OpenPeep -# https://github.com/openpeeps/yamlike +# (c) 2023 nyml | MIT License +# Made by Humans from OpenPeeps +# https://github.com/openpeeps/nyml import std/json from std/strutils import `%`, contains, split, join diff --git a/src/nyml/parser.nim b/src/nyml/parser.nim index 637adcc..be3603a 100644 --- a/src/nyml/parser.nim +++ b/src/nyml/parser.nim @@ -1,10 +1,9 @@ -# A stupid simple YAML-like parser. +# A stupid simple YAML-like parser. From YAML to JsonNode, +# stringified JSON or Nim objects via pkg/jsony. # -# Can parse YAML to JsonNode, stringified JSON or Nim objects via JSONY -# -# (c) 2023 yamlike | MIT License -# Made by Humans from OpenPeep -# https://github.com/openpeeps/yamlike +# (c) 2023 nyml | MIT License +# Made by Humans from OpenPeeps +# https://github.com/openpeeps/nyml import toktok import std/[json, jsonutils] @@ -413,7 +412,7 @@ proc parseObject(p: var Parser, this: TokenTuple): Node = if p.curr.kind == tkIdentifier and p.curr.pos == this.pos: p.setError("Invalid indentation") return - while p.curr.pos >= this.pos and p.curr.kind in {tkIdentifier, tkHyphen}: + while p.curr.pos > this.pos and p.curr.kind in {tkIdentifier, tkHyphen}: if p.curr.kind == tkIdentifier and p.next.kind != tkColon: p.setError("Missing assignment token") return @@ -472,7 +471,8 @@ proc parseYAML*(yml: YAML, strContents: string): Parser = if p.rootType == Array: p.writeNodes(p.program.nodes) else: + echo p.program.nodes p.code &= "{" p.writeNodes(p.program.nodes) p.code &= "}" - result = p \ No newline at end of file + result = p