Best way to Parse a collection of strings using elm/parser?

Hi all!

I have this question about elm parser:

Given this string ("aproved","pending") I expect a list ["aproved","pending"]

I am having a bit of trouble understanding how to parse a quoted string, I don’t care about escaping quotes, but at one point it may come that the quotes are optional.
I’ve tried the following:

items : Parser (List String)
items =
    Parser.sequence
        { start = "("
        , separator = ","
        , end = ")"
        , spaces = spaces
        , item = quoted
        , trailing = Forbidden
        }


quoted : Parser String
quoted =
    succeed identity
        |. token "\""
        |= variable
            { start = always True
            , inner = (/=) ','
            , reserved = Set.fromList []
            }
        |. token "\""

The error I get is error: [{ col = 26, problem = Expecting "\"", row = 1 },{ col = 12, problem = Expecting ")", row = 1 }]

Perhaps your variable call needs to exclude " so it’ can’t eat the closing character before the following token gets a crack at it.

Thanks @wondible

I don’t exactly know what you mean, I’ve try this but it doesn’t work:

quoted : Parser String
quoted =
    succeed identity
        |. token "\""
        |= variable
            { start = (/=) '"'
            , inner = (/=) '"'
            , reserved = Set.fromList []
            }
        |. token "\""

My string was URL encoded, and that’s the reason the parser was failing :stuck_out_tongue:

About parsing qouted strings @unsoundscapes pointed me to parser he made:

1 Like