Skip to content

Commit

Permalink
Fix parsing of multi line text (#590)
Browse files Browse the repository at this point in the history
* fix parser of flow sequence
* support line folded
* update test cases
* refactor
* fix literal-scalars
* remove unnecessary indent state updater
  • Loading branch information
goccy authored Dec 14, 2024
1 parent 7601ad3 commit a692a58
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 183 deletions.
3 changes: 3 additions & 0 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,9 @@ func (p *parser) parseFlowSequence(ctx *context) (*ast.SequenceNode, error) {
}

if tk.Type() == token.CollectEntryType {
if isFirst {
return nil, errors.ErrSyntax("expected sequence element, but found ','", tk.RawToken())
}
ctx.goNext()
} else if !isFirst {
return nil, errors.ErrSyntax("',' or ']' must be specified", tk.RawToken())
Expand Down
8 changes: 4 additions & 4 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ b: - 2
{
">\n>",
`
[2:1] could not find document
[2:1] could not find multi line content
1 | >
> 2 | >
^
Expand All @@ -1245,7 +1245,7 @@ b: - 2
{
">\n1",
`
[2:1] could not find document
[2:1] could not find multi line content
1 | >
> 2 | 1
^
Expand All @@ -1254,7 +1254,7 @@ b: - 2
{
"|\n1",
`
[2:1] could not find document
[2:1] could not find multi line content
1 | |
> 2 | 1
^
Expand All @@ -1263,7 +1263,7 @@ b: - 2
{
"a: >3\n 1",
`
[2:3] invalid number of indent is specified in the document header
[2:3] invalid number of indent is specified in the multi line header
1 | a: >3
> 2 | 1
^
Expand Down
Loading

0 comments on commit a692a58

Please sign in to comment.