diff --git a/parser/parser.go b/parser/parser.go index de102eeb..7a765c85 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -476,9 +476,11 @@ func (p *parser) parseSequenceEntry(ctx *context) (*ast.SequenceNode, error) { curColumn := tk.Position.Column for tk.Type == token.SequenceEntryType { p.progress(1) // skip sequence token + entryTk := tk tk = p.currentToken() if tk == nil { - return nil, errors.ErrSyntax("empty sequence value", p.previousToken()) + sequenceNode.Values = append(sequenceNode.Values, ast.Null(p.createNullToken(entryTk))) + break } var comment *ast.CommentGroupNode if tk.Type == token.CommentType { diff --git a/parser/parser_test.go b/parser/parser_test.go index 6c824a00..6b8b3ae9 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -93,6 +93,7 @@ func TestParser(t *testing.T) { "value: >\n\n", "value: >\nother:", "value: >\n\nother:", + "a:\n-", } for _, src := range sources { if _, err := parser.Parse(lexer.Tokenize(src), 0); err != nil { @@ -974,19 +975,6 @@ a }, { ` -a: -- b: c -- `, - ` -[4:1] empty sequence value - 2 | a: - 3 | - b: c -> 4 | - - ^ -`, - }, - { - ` a: |invalidopt foo `, @@ -1052,7 +1040,7 @@ a: - b: - `, ` -[3:4] empty sequence value +[3:4] block sequence entries are not allowed in this context 2 | a: - > 3 | b: - ^ diff --git a/scanner/scanner.go b/scanner/scanner.go index c6b5d4cc..371bd8a3 100644 --- a/scanner/scanner.go +++ b/scanner/scanner.go @@ -802,7 +802,7 @@ func (s *Scanner) scanSequence(ctx *Context) bool { } nc := ctx.nextChar() - if nc != ' ' && !s.isNewLineChar(nc) { + if nc != 0 && nc != ' ' && !s.isNewLineChar(nc) { return false }