Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Yaml/Parser.elm
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,14 @@ listInlineString =
listInlineNext : List Ast.Value -> Ast.Value -> P.Parser (P.Step (List Ast.Value) (List Ast.Value))
listInlineNext elements element =
P.oneOf
[ P.succeed (listInlineOnMore elements element)
|. P.chompIf U.isComma
[ P.succeed identity
|. P.symbol ","
|. U.whitespace
|= P.oneOf
[ P.succeed (listInlineOnDone elements element)
|. P.symbol "]"
, P.succeed (listInlineOnMore elements element)
]
, P.succeed (listInlineOnDone elements element)
|. P.chompIf U.isListEnd
]
Expand Down
8 changes: 8 additions & 0 deletions tests/TestParser.elm
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,14 @@ suite =
ccc
]""" <|
Ast.List_ [ Ast.String_ "aaa", Ast.String_ "bbb", Ast.String_ "ccc ccc\n ccc" ]
, Test.test "an inline list with a trailing comma" <|
\_ ->
expectValue "[ aaa, bbb, ]" <|
Ast.List_ [ Ast.String_ "aaa", Ast.String_ "bbb" ]
, Test.test "an inline list with a trailing explicit null" <|
\_ ->
expectValue "[ aaa, bbb, null ]" <|
Ast.List_ [ Ast.String_ "aaa", Ast.String_ "bbb", Ast.Null_ ]
, Test.test "an inline list with an inline list inside" <|
\_ ->
expectValue "[ aaa, [ bbb, aaa, ccc ], ccc ]" <|
Expand Down