KmolYuan / yaml-peg-rs

A YAML 1.2 parser using a greedy parsing algorithm with PEG atoms. Support anchors, directives, positions, tags, serde, and no-std.
https://crates.io/crates/yaml-peg
MIT License
16 stars 4 forks source link

deserializing '0.1 blabla' in collections fails #13

Open Shishqa opened 2 weeks ago

Shishqa commented 2 weeks ago

Hi!

Discovered a bug with parsing yamls like

- 1.2 blabla

results in

invalid sequence terminator:

1:7
- 1.2 blabla
      ^

or

test: 3.1415 i will fail

results in

invalid map terminator:

1:14
test: 3.1415 i will fail
             ^

This can be tested with diff:

diff --git a/src/tests/complete_doc.yaml b/src/tests/complete_doc.yaml
index 9bf86f3..d77c178 100644
--- a/src/tests/complete_doc.yaml
+++ b/src/tests/complete_doc.yaml
@@ -6,6 +6,7 @@ a0 bb: !x!foo .val.
 ::a1:  # Test comment after wrapped! (1)
   b1  : 4.
   b2:
+    - 1.1 Ghz
     - 123   abc
     - 50%
     - 0o10
@@ -16,6 +17,7 @@ a0 bb: !x!foo .val.
     - -.infs
     - 2001-11-23 15:01:42 -5
     - https://www.google.com/
+  c1: 3.14 flops
 -a2: !!t1 4.03  # Test comment after normal scalars.
 ?  # Test comment after wrapped! (2)
   - q

The issue, I guess, is somewhere in these lines, but I haven't figured it out fast


loving this library btw!

Shishqa commented 2 weeks ago

checked, it fails even outside a collection:

3.1415 i will fail

results in:

invalid document splitter:

1:8
3.1415 i will fail
       ^