myrho / elm-parser-extras / Parser.Extras

Some convenience parser combinators.

Combinators

many : Parser a -> Parser (List a)

Apply a parser zero or more times and return a list of the results.

some : Parser a -> Parser ( a, List a )

Apply a parser one or more times and return a tuple of the first result parsed and the list of the remaining results.

between : Parser opening -> Parser closing -> Parser a -> Parser a

Parse an expression between two other parsers

parens : Parser a -> Parser a

Parse an expression between parenthesis.

parens p == between (symbol "(") (symbol ")") p

braces : Parser a -> Parser a

Parse an expression between curly braces.

braces p == between (symbol "{") (symbol "}") p

brackets : Parser a -> Parser a

Parse an expression between square brackets.

brackets p == between (symbol "[") (symbol "]") p

Parsers

quotedString : Char -> Char -> Parser String

Parse a quoted string with an escape character.

quotedString '/' '\'' "'a /'quoted/' string'" --> "a 'quoted' string"

Usually the escape char is the backslash. Due to elm-format removing backslashes before quotes this example uses the normal slash.