flyx / nimyaml Goto Github PK
View Code? Open in Web Editor NEWYAML implementation for Nim
Home Page: https://nimyaml.org
License: Other
YAML implementation for Nim
Home Page: https://nimyaml.org
License: Other
I have yaml [0.5.1] installed from nimble and I am running with a Nim self-built from git 07d7d35d99526283.
I run the following program
import basic2d, yaml
var pointList: seq[Point2D]
var f = newFileStream("points.yaml")
load(f, pointList)
f.close()
This program fails to compile, as does any other program where I load() on a structure containing Point2Ds. By contrast, calling dump() on these structures works fine. The error is
$ nim compile test.nim
Hint: system [Processing]
Hint: test [Processing]
Hint: basic2d [Processing]
Hint: math [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: yaml [Processing]
Hint: streams [Processing]
Hint: unicode [Processing]
Hint: lexbase [Processing]
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: etcpriv [Processing]
Hint: json [Processing]
Hint: macros [Processing]
Hint: queues [Processing]
Hint: typetraits [Processing]
test.nim(5, 5) template/generic instantiation from here
c:\users\andi\.nimble\pkgs\yaml-0.5.1\private\serialization.nim(789, 17) template/generic instantiation from here
c:\users\andi\.nimble\pkgs\yaml-0.5.1\private\serialization.nim(770, 19) template/generic instantiation from here
c:\users\andi\.nimble\pkgs\yaml-0.5.1\private\serialization.nim(645, 18) template/generic instantiation from here
c:\users\andi\.nimble\pkgs\yaml-0.5.1\private\serialization.nim(218, 19) template/generic instantiation from here
c:\users\andi\.nimble\pkgs\yaml-0.5.1\private\serialization.nim(614, 20) template/generic instantiation from here
c:\users\andi\.nimble\pkgs\yaml-0.5.1\private\serialization.nim(468, 30) template/generic instantiation from here
c:\msys64\home\andi\work\g\nim\lib\pure\basic2d.nim(71, 7) template/generic instantiation from here
c:\users\andi\.nimble\pkgs\yaml-0.5.1\private\serialization.nim(614, 20) template/generic instantiation from here
c:\users\andi\.nimble\pkgs\yaml-0.5.1\private\serialization.nim(140, 22) template/generic instantiation from here
c:\users\andi\.nimble\pkgs\yaml-0.5.1\private\serialization.nim(143, 48) Error: type mismatch: got (string)
but expected one of:
proc parseBiggestFloat(s: string; number: var BiggestFloat; start = 0): int
Currently it seems whenever I load a single object from a file that specifies additional fields that don't correspond to any of the object an exception is thrown and it aborts.
I'm within a use-case where I wouldn't mind excessive fields in the file tho and would rather just skip them and proceed with loading whatever fields do fit.
AFAIS there's currently no way to achieve this.
NimYAML is currently not on the current list of YAML libraries on the official YAML website.
This input:
foo:
bla
blubb
renders as:
%YAML 1.2
---
!!map {
? !!str "foo"
: !!null "",
? !!str "bla"
: !!null "",
? !!str "blubb"
: !!null ""
}
It should lead to an error.
hello,
looks like Nim 0.17.3 devel branch breaks many things: the parser, test unit, and others
I'd like to use NimYAML to parse a document which has some structure but is not totally specified. In general, it looks something like this.
Name: parent
Children:
- Name: child
Children:
- Name:
Metadata:
Key: value
OtherKey: [arbitrary, value]
I can represent the nesting properly and even the fact that certain fields are optional. However, I run into problems deserializing Metadata
. I can deal with string values, but in an idea world I would like to say the value can be any object. Is there a way to do this currently? I know I can approximate it with variants, but this means I need to update my codebase every time a new type of value is added. I've also run into #28 since I would prefer not to add tags to simple value types like seq[string]
.
fplDocument
can be the root level of the ancestry, to get rid of all the annoying ancestry.len > 0
checking.
Currently, when internal state is inconsistent, there's an assert(false)
in the code. This should be improved by raising an internal error with a meaningful message like
internal error at line #l, column #c in file #f. please report this bug.
Hey, nimyaml stopped compiling on latest devel, using:
Nim Compiler Version 0.17.3 (2017-11-14) [Linux: amd64]
Copyright (c) 2006-2017 by Andreas Rumpf
git hash: ab938fc901d1eb00ef973c22ec94d660682208b0
active boot switches: -d:release -d:nativeStackTrace
e.g.: nim tests
throws me:
Hint: used config file '/etc/nim.cfg' [Conf]
Hint: tests [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: algorithm [Processing]
Hint: streams [Processing]
yaml/private/lex.nim(1, 2) Hint: 'c' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(259, 51) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(242, 58) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(246, 53) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(250, 57) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(244, 63) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(245, 61) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(253, 69) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(254, 64) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(255, 64) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(247, 51) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(257, 48) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(258, 47) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(248, 52) Hint: 'YamlLexerError' is declared but not used [XDeclaredButNotUsed]
yaml/private/lex.nim(1160, 9) template/generic instantiation from here
yaml/private/lex.nim(1142, 36) template/generic instantiation from here
yaml/private/lex.nim(1069, 11) Error: illegal capture 'peek'
Using dump with the psJson style writes out an empty string "" as null, however when then loading it back via a plain load it parses it back as string "null", effecitvely turning all empty strings into "null" strings.
YAML 1.2 requires UTF-16 and UTF-32 support. Currently, only UTF-8 is processed.
0.17.3 [Linux: amd64]
Copyright (c) 2006-2017 by Andreas Rumpf
git hash: fea66497b4f36ed73cfaa5eaa962cfd30307930a
active boot switches: -d:release -d:nativeStackTrace
libs/yaml/yaml/private/internal.nim(9, 5) Error: expression '
let ii321627 = ("libs/yaml/yaml/serialization.nim", 1060)
echo ["[NimYAML] Error in file ", ii321627.filename, " at line ", ii321627.line, ":"]
echo ["Too many children: " & $recListLen(recCase[i][1])]
echo ["[NimYAML] Stacktrace:"]
try: writeStackTrace()
except: discard
echo ["[NimYAML] Please report this bug."]
quit 1' is of type 'NimNode' and has to be discarded
Please download this file:
https://github.com/ua-parser/uap-core/blob/master/tests/test_device.yaml
And run this program:
https://gist.github.com/treeform/c140984cf3e69e7c8ed8e76feba5c004
It reads the file twice and compares the results. They are not equal and assert is triggered. They should be equal its the same file.
Its random what will happen but once you compile a program same random thing will happen in the binary. Compiling without changes produces the same binary. Compiling with changes causes it to crash some place else. Some times no issues happens it it runs fine.
So far I have seen:
This fails:
bla"keks: foo
So does this:
bla]keks: foo
The lookahead for recognizing an implicit map start does not correctly parse quotes or flow indicators that are part of a plain scalar.
:
(two empty lines) gives:
Parser error at line 3, column 1:
Invalid indentation (expected indentation of -1)
^
With nim 0.17.0 there's a compilation error.
Nim Compiler Version 0.17.0 (2017-05-30) [Linux: amd64]
Copyright (c) 2006-2017 by Andreas Rumpf
git hash: eb83ec2685f5bbd0d65051b1f00502f05a367172
active boot switches: -d:release
/home/hohlerde/.nimble/pkgs/yaml-0.9.1/yaml/hints.nim(268, 35) template/generic instantiation from here
/home/hohlerde/.nimble/pkgs/yaml-0.9.1/yaml/hints.nim(112, 3) Error: invalid expression: '
of '~':
ythInitial => ythNULL'
To reproduce just compile the following code:
import yaml
proc main*() =
echo "hello"
when isMainModule:
main()
Apparently, this arises when trying to serialize anything that contains a table. A small example would be
import streams, yaml, tables
var
t = {"a": "b"}.newTable()
s = newFileStream("test.yaml", fmWrite)
dump(t, s)
s.close()
It seems that this happens because representChild
is explicit defined not to raise exceptions, but accessing table keys can raise KeyError
.
I think one should either catch that exception, or remove the explicit pragma {. raises: [] .}
and let the compiler infer effects
YAML has are mappings and sequences, but token kinds in NimYAML are yamlMap
and yamlSequence
. Either shorten both or use full names both times. Same issue may exist elsewhere in the code, check for it.
fpBlockLineStart
can be merged into fplBlockObjectStart
, just check for start of line when handling document markers.
I have a weird error: I can't seem to load 0
%YAML 1.2
number: 0
import yaml.serialization, streams, os
type
Value = object
number: int
var raw = newFileStream("a.yaml", fmRead)
var value: Value
load(raw, value)
echo value
If I run this on the yaml, I get the error. If I change number to anything != 0 it seems to work
Is it a known problem and is it easy to fix ? I use nim devel(> 0.18.1)
It looks like its want me to report this bug, or the code that wants me to report the bug had a bug? I am confused.
/Users/me/.nimble/pkgs/yaml-#head/yaml/private/internal.nim(9, 5) Error: expression '
let ii378627 = ("/Users/me/.nimble/pkgs/yaml-#head/yaml/serialization.nim", 1060)
echo ["[NimYAML] Error in file ", ii378627.filename, " at line ", ii378627.line, ":"]
echo ["Too many children: " & $recListLen(recCase[i][1])]
echo ["[NimYAML] Stacktrace:"]
try: writeStackTrace()
except: discard
echo ["[NimYAML] Please report this bug."]
quit 1' is of type 'NimNode' and has to be discarded
Nim Compiler Version 0.17.3 [MacOSX: amd64]
Copyright (c) 2006-2018 by Andreas Rumpf
git hash: 5460bd2764db46048b9a3ecdd1d17a20a4b48b79
active boot switches: -d:release
Hi:
import yaml.serialization, yaml.presenter, streams
type Person = object
name : string
age : int32
var personList = newSeq[Person]()
personList.add(Person(name: "Karl Koch", age: 23))
personList.add(Person(name: "Peter Pan", age: 12))
var s = newStringStream("test ")
dump(personList, s,
options = defineOptions(style = psJson))
echo "hello"
var line = ""
while s.readLine(line):
echo line
s.close()
output:
hello
Currently, representObject
generates both the tag and the content of the resulting event(s). This should be separated in representChild
for the tag and representObject
for the value. This would be consistent with constructObject
and constructChild
. Also, this makes it possible to use the same representObject
proc for multiple types/tags. This is required for #12 .
This mainly boils down to „properly generate tags for custom generic types“. So that, for example, Container[Container[string]]
gets a tag !nim:custom:Container(nim:custom:Container(tag:yaml.org,2002:string))
.
Currently blocked by nim-lang/Nim#4832
Objects get serialized to mappings. The keys of these mappings that represent the names of the object's fields get the object tag !!str
. This should rather be !nim:fieldName
or something. Surprisingly, there is no standard tag for that.
{1}
yields:
yamlStartDoc()
yamlStartMap(tag=?)
yamlScalar(tag=?, content="1")
yamlEndDoc()
Expected:
yamlStartDoc()
yamlStartMap(tag=?)
yamlScalar(tag=?, content="1")
yamlScalar(tag=?, content="")
yamlEndMap()
yamlEndDoc()
This is allowed by YAML:
foo:
- bla
But NimYAML gives:
Parser error at line 2, column 2:
Illegal sequence item in map
- bla
^
import yaml.serialization
type
ObjectKind = enum
okA, okB
ObjectType = object
case kind: ObjectKind
of okA: a: string
of okB: b: int
markAsImplicit(ObjectType)
yields
yaml/serialization.nim(1351, 13) Error: This type cannot be marked as implicit
It works with
# ...
case kind: ObjectKind
of okA:
a: string
of okB:
b: int
# ...
Example input:
"foo: bar"
Parsing a float gives me a compilation error, a minimal example being
import streams, yaml
type Config = object
cpus: float64
proc readConf(): Config =
var s = newFileStream("conf.yaml", fmRead)
load(s, result)
s.close()
See this example in the spec. It must be supported for both implicit and explicit key-value pairs.
Being able to load JSON (and not YAML, which is a superset) would be a nice feature. I know that NimYAML is meant to primarily be a YAML loader, so perhaps this would be better as a separate project.
this is the yaml script
scenes:
-
duration: 9
label:
- {text: "...", position: {x:201, y:241} }
- {text: "...", position: {x:268, y:202} }
- {text: "...", , position: {x:278, y:151} }
- {text: "...", position: {x:348, y:111} }
this is the Nim code
import yaml/[parser, stream], streams
proc main() =
var s = newFileStream("bug.yml")
var p = newYamlParser()
var ev = p.parse(s)
try:
for x in ev:
echo x.kind
except YamlStreamError as err:
echo err.msg
main()
and this is the result:
...
[NimYAML] Error in file C:\Users\Jangko\.nimble\pkgs\yaml-0.9.1\yaml\parser.nim at line 845:
assertion failed!
[NimYAML] Stacktrace:
Traceback (most recent call last)
test.nim(14) test
test.nim(10) main
stream.nim(208) finished
internal.nim(26) stateFlow
[NimYAML] Please report this bug.
Is this really a bug?, I think I just put something wrong in the yaml script. Perhaps an alternate error message is better.
Btw, your yaml library is awesome
a
"b"
This runs into some assert false
, but is valid YAML according to spec.
Currently, block scalars are slurped in completely by blockScalar()
, instead, they can be handled like multiline plain scalars line per line, so that checking for document end markers, comments etc can be done like for everything else, and not separately in blockScalar()
.
Example json :
{
"skeleton": {
"hash": "Lb8yfqsfTuFiRtjhPw5ZzTEPxik",
"spine": "3.5.03-beta",
"width": 227.32,
"height": 841.06,
"fps": 30,
"images": "./images/"
},
"bones": [
{ "name": "root" },
{ "name": "vine1", "parent": "root", "length": 74, "rotation": 90, "x": 339.09, "y": -467.15, "color": "f700ffff" },
{ "name": "vine2", "parent": "vine1", "length": 74, "x": 74, "color": "f700ffff" },
{ "name": "vine3", "parent": "vine1", "length": 74, "rotation": 38.94, "x": 137.97, "y": 47.51, "color": "f700ffff" },
{ "name": "vine4", "parent": "vine1", "length": 74, "rotation": 16.67, "x": 214.29, "y": 68.52, "color": "f700ffff" },
{ "name": "vine5", "parent": "vine1", "length": 74, "rotation": -21.73, "x": 289.61, "y": 40.92, "color": "f700ffff" },
{ "name": "vine6", "parent": "vine1", "length": 74, "rotation": -50.04, "x": 341.12, "y": -15.58, "color": "f700ffff" },
{ "name": "vine7", "parent": "vine1", "length": 74, "rotation": -39.25, "x": 402.7, "y": -61.82, "color": "f700ffff" },
{ "name": "vine8", "parent": "vine1", "length": 74, "rotation": -6.18, "x": 483.27, "y": -69.84, "color": "f700ffff" },
{ "name": "vine9", "parent": "vine1", "length": 74, "rotation": 27.11, "x": 554.25, "y": -36.44, "color": "f700ffff" },
{ "name": "vine10", "parent": "vine1", "length": 74, "rotation": 48, "x": 608.62, "y": 19.05, "color": "f700ffff" },
{ "name": "vine11", "parent": "vine1", "length": 74, "rotation": 39.7, "x": 670.66, "y": 66.39, "color": "f700ffff" },
{ "name": "vine12", "parent": "vine1", "length": 74, "rotation": 10.72, "x": 750.09, "y": 80.23, "color": "f700ffff" },
{ "name": "vine13", "parent": "vine1", "length": 74, "rotation": -18.44, "x": 826.06, "y": 56.95, "color": "f700ffff" },
{ "name": "vine-control1", "parent": "root", "length": 296.68, "rotation": 88.64, "x": -2.5, "y": 2.55, "color": "ff0004ff" },
{ "name": "vine-control2", "parent": "vine-control1", "length": 292.59, "rotation": 0.96, "x": 296.68, "color": "ff0004ff" },
{ "name": "vine-control3", "parent": "vine-control2", "length": 247.5, "rotation": 0.16, "x": 292.59, "color": "ff0004ff" },
{ "name": "vine-control4", "parent": "vine-control3", "length": 212.43, "rotation": 0.5, "x": 247.5, "color": "ff0004ff" }
],
...
}
Sample code to test with :
when isMainModule:
import
atlas,
skeleton_json,
yaml.serialization as yaml,
streams
type
SkeletonJson = object
skeleton: Skeleton
bones: seq[Bone]
Skeleton = object
hash: string
spine: string
width: float
height: float
fps: int
images: string
Bone = object
name: string
parent: string
length: float64
rotation: float64
x, y: float64
color: string
#proc createTexture(atlasPage: AtlasPage, path: string) =
# echo repr atlasPage
# echo path
#let textureAtlas = atlas.createFromFile("./spine-runtimes/spine-sfml/data/goblins.atlas", createTexture, nil)
#let skelJson = skeleton_json.create(textureAtlas)
#let skelData = skelJson.readDataFile("./spine-runtimes/spine-sfml/data/goblins-mesh.json")
#echo repr skelData
var sk: SkeletonJson
var s = newFileStream("test.json")
setDefaultValue(Bone, parent, nil)
setDefaultValue(Bone, length, 0.0)
setDefaultValue(Bone, rotation, 0.0)
setDefaultValue(Bone, x, 0.0)
setDefaultValue(Bone, y, 0.0)
setDefaultValue(Bone, color, nil)
yaml.load(s, sk)
s.close()
After running nimble install yaml
I am greeted with the warning
Warning: File 'bench.nim' inside package 'yaml' is outside of the permitted namespace, should be inside a directory named 'yaml' but is in a directory named 'bench' instead. This will be an error in the future.
Hint: Rename the directory to 'yaml' or prevent its installation by adding `skipDirs = @["bench"]` to the .nimble file.
Seems like nim is starting to require that any production files be included in the package directory.
It also keeps giving me: Warning: No .nimble file found for /Users/chris/.nimble/pkgs/yaml-0.10.1
Nim version: 0.17.0
Nimble version: 0.8.6
When there is a parsing error at the end of a line, the corresponding exception has the wrong line number (1 more than the correct number).
For instance, parsing a file such as
name: Andrea
age: abc
surname: Ferretti
with the following code
import yaml
type Person = object
name, surname: string
age: int
var
s = newFileStream("test.yaml", fmRead)
c: Person
try:
load(s, c)
except YamlConstructionError:
let e = (ref YamlConstructionError)(getCurrentException())
echo "ERROR at line ", e.line, " column ", e.column
echo e.lineContent
echo e.msg
finally:
s.close()
will print
ERROR at line 3 column 6
surname: Ferretti
^
Cannot construct to int32: abc
This seems not to happen when the error is, say, finding a field when a sequence was expected.
I am not sure where this exactly comes from, because I see the lexer state comes from lexbase
, but I will let you know if I find anything.
I hope I am not bothering you too much! :-)
- [1 ]
- 2
Leads to:
Parser error at line 2, column 4:
Unclosed flow content
- 2
^
Nim's JavaScript backend is currently not supported because it doesn't support first-class iterators. Since it is unlikely that this will change in the near future, to support the backend, fastparse.nim
must be refactored to not use first-class iterators.
Required changes:
What should be done to declare NimYAML fit for JS:
Hi,
First off, props on this awesome project! Nice to see such a polished, well-documented project as part of the Nim ecosystem 👍
Just a query really - I'm trying use yaml.set_default_value
on a ref object, and it's not compiling. I'm not sure if this is a limitation of this macro or if there's a way I need to kinda deref the ref object(?).
My example is:
type Config = ref object
docs_root*: string
drafts_root*: string
yaml_set_default_value(Config, docs_root, "~/.example")
# Error
stack trace: (most recent call last)
../../../.nimble/pkgs/yaml-0.11.0/yaml/serialization.nim(1453, 13) getFieldIndex
../../../.choosenim/toolchains/nim-#devel/lib/core/macros.nim(1196, 11) $
../../../.choosenim/toolchains/nim-#devel/lib/system.nim(3978, 20) failedAssertImpl
../../../.choosenim/toolchains/nim-#devel/lib/system.nim(3971, 11) raiseAssert
../../../.choosenim/toolchains/nim-#devel/lib/system.nim(3011, 7) sysFatal
notorious.nim(26, 23) template/generic instantiation of `setDefaultValue` from here
../../../.nimble/pkgs/yaml-0.11.0/yaml/serialization.nim(1561, 69) template/generic instantiation of `getFieldIndex` from here
../../../.choosenim/toolchains/nim-#devel/lib/system.nim(3011, 7) Error: unhandled exception: /home/james/.choosenim/toolchains/nim-#devel/lib/core/macros.nim(1196, 17) `false` Invalid node kind nnkBracketExpr for macros.`$`
Any idea if this is doable?
Regards.
EDIT: Forgive the snake_case!
I am new to Nim, I have never installed anything by nimble and I cannot install this package. Here is listing what I get. Do you have any idea what I am doing bad? I am on Ubuntu.
ladislav@vento:~/pok_98$ nimble install yaml
No local packages.json found, download it from internet? [y/N]
y
Downloading "Official" package list
Trying https://github.com/nim-lang/packages/raw/master/packages.json...
Done.
Searching in "official" package list...
Downloading https://github.com/flyx/NimYAML into /tmp/nimble_1112/githubcom_flyxNimYAML using git...
Found tags...
Cloning latest tagged version: v0.7.0
Cloning into '/tmp/nimble_1112/githubcom_flyxNimYAML'...
remote: Counting objects: 51, done.
remote: Compressing objects: 100% (48/48), done.
remote: Total 51 (delta 1), reused 11 (delta 0), pack-reused 0
Unpacking objects: 100% (51/51), done.
Checking connectivity... done.
Note: checking out '721632322bcc15c966ced0e0fe1d3869aa79725b'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
Traceback (most recent call last)
nimble.nim(1007) nimble
nimble.nim(939) doAction
nimble.nim(581) install
nimble.nim(536) downloadPkg
download.nim(200) doDownload
download.nim(164) verifyClone
packageparser.nim(239) getPkgInfo
packageparser.nim(230) readPackageInfo
Error: unhandled exception: Could not read package info file in /tmp/nimble_1112/githubcom_flyxNimYAML/yaml.nimble;
Reading as ini file failed with:
Invalid section: .
Evaluating as NimScript file failed with:
Cannot find nimscriptapi.nim. [NimbleError]
/Users/me/.nimble/pkgs/yaml-0.10.3/yaml/private/lex.nim(1160, 9) template/generic instantiation from here
/Users/me/.nimble/pkgs/yaml-0.10.3/yaml/private/lex.nim(1142, 36) template/generic instantiation from here
/Users/me/.nimble/pkgs/yaml-0.10.3/yaml/private/lex.nim(1069, 11) Error: illegal capture 'peek'
Has been fixed on github but not if you install with nimble.
You are welcome!
It will be convenient to have any parsers under one "roof".
The package name should be nimyaml
, as is the registered name in the Nimble package list.
This amounts to changing the yaml.nimble
to nimyaml.nimble
(no changes required in the actual code - it can still be imported with import yaml
).
Otherwise, depending on nimyaml
in a different nimble project causes issues. Namely, Nimble will install nimyaml
as a dependency, but will use a folder like yaml-0.6.0
. Next time nimble is run, it will not detect nimyaml as installed, due to the name mismatch, and will try to clone it again. But the directory exists, hence it will ask for confirmation (defaulting to no overwrite). In case the user does not confirm, nimble exits immediately.
This make nimyaml very inconvenient to use as a dependency in another project
Both {}
and []
vanish when outputted in block-only style. That must not happen.
Just wanted to let you know that the library does not work on the devel branch anymore. You may want to open a suitable issue on Nim for this.
An example that does not compile is:
import yaml
type Foo = object
a: int
var
s = newFileStream("test.yaml", fmRead)
c: Foo
load(s, c)
s.close()
for Nim 0.18.1:
.nimble\pkgs\yaml-0.10.3\yaml\stream.nim(140, 31) Error: enable the 'not nil' annotation with {.experimental: "notnil".}
Backslashes are currently not escaped when presenting content as quoted string. That leads to invalid YAML output.
Reproducing code:
import yaml.serialization, streams
type Vec* = tuple[x, y: float]
var v = (x: 40.0, y: 50.0)
var s = newFileStream("out.yaml")
load(s, v)
s.close()
echo "v = <", v.x, ", ", v.y, ">"
This fails with [path\to\]yaml-0.8.0\yaml\serialization.nim(270, 15) Error: undeclared identifier: 'parseBiggestFloat'
It seems that parseBiggestFloat
can be found in the parseutils
module, whereas NimYAML only includes strutils
, which has parseBiggestInt
.
It would probably be good to add a regression test to tserialization.nim
, which doesn't seem to test any floats.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.