fjoppe / Legivel

F# Yaml 1.2 parser
https://fjoppe.github.io/Legivel
The Unlicense
60 stars 5 forks source link

Quoted strings are not supported #14

Closed rbauduin closed 5 years ago

rbauduin commented 5 years ago

Description

I have a YAML file with a string value containing ::

value: "Software Engineering: A Practioners's Approach"

However when loading that YAML file, I get the error

{Location = (l1153, c10);
    Message = "Reserved indicators can't start a plain scalar.";};

Single quotes cause the same problem.

Expected behavior

This seems to be a valid syntax and the file should be parsed without error.

Actual behavior

Generates error: Message = "Reserved indicators can't start a plain scalar.";};

Known workarounds

value: >
       Software Engineering: A Practioners's Approach

Related information

fjoppe commented 5 years ago

Just to give some (empy) feedback. I've tried to reproduce this on Win 10 with both net45 and netstandard2.0 libs, but I did not observe this issue. They parse both yaml examples (problem and workaround). I've been installing a dev env under Linux, but haven't finished doing this.

Note, this parse error is generated when trying to parse a plain scalar, but fails when the string starts with an illegal indicator. However, other forms are tried later in the parsing process, and if another form succeeds, this error is discarded. So the succeeding form in this case would be the parsing of a double-quoted string. Which somehow fails. I'd think the problem is in there. Hopefully there are no garbage-characters in your string? Note that another workaround is to put the string without double quotes.

Other question. Is there any case where you succesfully parsed a double- or single- quoted string? Or do they just all fail, in all cases? If that is the case, many unit-tests of this project would fail on your system.

rbauduin commented 5 years ago

The only quoted string instance I have in my code that is parsed without error is the single-quoted empty string ''. Non empty quoted strings never were accepted.

I'm ok using the workaround, but in case you want to investigate further, here are some pointers to my code:

I use it to load database fixtures from a Ruby on Rail project.

fjoppe commented 5 years ago

Hi,

I notice in this project file there is a ref to Levivel v0.2.2. Which has no dotnetcore support yet. There is a difference between net45 and netstandard involving Lists (ie the error list :) ) which was fixed in v0.3.0. Could you please re-confirm that you're using the right version?

rbauduin commented 5 years ago

Actually I test this on the explorationsbranch, which has version 0.3.1: https://gitlab.com/myowndb/myowndb/blob/explorations/lib/lib.fsproj

(I see I also included a link to the master branch, which might be the source of the confusion)

fjoppe commented 5 years ago

What is the Region/Culture setting of your system?

I understand that .Net Regex has a CultureInvariant setting, which Legivel does not use.

rbauduin commented 5 years ago

I tried again this morning and I can't reproduce the problem anymore.... I didn't change anything in the meantime.... Maybe the upgrade to Legivel 0.3.1 was not completely taken into account? (I upgraded when I encountered the problem, but the problem still was present after the upgrade).

Anyway, thanks for looking at it, and thanks for Legivel, it helps me a lot!