PetitParser icon indicating copy to clipboard operation
PetitParser copied to clipboard

PPYAMLGrammar doesn’t parse single-quoted scalars

Open Rinzwind opened this issue 3 years ago • 2 comments

In the following, the last example returns a PPFailure:

PPYAMLGrammar parse: 'foo'. "⇒ 'foo'"
PPYAMLGrammar parse: '"foo"'. "⇒ 'foo'"
PPYAMLGrammar parse: '''foo'''. "⇒ a PPFailure"

I would expect the last example to also return 'foo'. See section ‘7.3.2. Single-Quoted Style’ in the YAML specification v1.2.2 or section ‘4.6.8. Single Quoted’ in the older v1.0 specification.

Rinzwind avatar Feb 24 '23 20:02 Rinzwind

Note that the following example does not return a PPFailure; it returns #('one' 'two') rather than #('one' 'two' 'three' 'four' 'five') as I would expect:

PPYAMLGrammar parse: '
- "one"
- two
- ''three''
- four
- "five"
'

Rinzwind avatar Feb 24 '23 20:02 Rinzwind

When writing the previous comment, I didn’t know about PPEndOfInputParser yet. Replacing PPYAMLGrammar by PPYAMLGrammar new end makes the example return a PPFailure instead of #('one' 'two'). Suggestion: making the class method #parse: use PPEndOfInputParser might better match novice expectations.

Rinzwind avatar May 06 '23 18:05 Rinzwind