pithub / elm-parser-extra / Parser.Advanced.Extra

Convenience functions for Parser.Advanced.


Everything here works just like in the Parser.Extra module, except that String arguments become Token arguments, and you need to provide a Problem for certain scenarios.


Table of Contents

Look Ahead

lookAhead : Parser.Advanced.Parser c x a -> Parser.Advanced.Parser c x a

Just like Parser.Extra.lookAhead.

negativeLookAhead : x -> Parser.Advanced.Parser c x a -> Parser.Advanced.Parser c x ()

Just like Parser.Extra.negativeLookAhead except you provide a Token instead of a String. That way you can specify your custom type of problem for when the given parser would succeed.

Miscellaneous

followedBy : Parser.Advanced.Parser c x b -> Parser.Advanced.Parser c x a -> Parser.Advanced.Parser c x b

Just like Parser.Extra.followedBy.

committed : Parser.Advanced.Parser c x a -> Parser.Advanced.Parser c x a

Just like Parser.Extra.committed.

Binds

Flipped versions of andThen with 1 to 5 parsers and callbacks with 1 to 5 input parameters.

(In other functional languages, the flipped version of andThen is often called "bind", hence the names here.)

bind : Parser.Advanced.Parser c x a -> (a -> Parser.Advanced.Parser c x b) -> Parser.Advanced.Parser c x b

Just like Parser.Extra.bind.

bind2 : Parser.Advanced.Parser c x a1 -> Parser.Advanced.Parser c x a2 -> (a1 -> a2 -> Parser.Advanced.Parser c x b) -> Parser.Advanced.Parser c x b

Just like Parser.Extra.bind2.

bind3 : Parser.Advanced.Parser c x a1 -> Parser.Advanced.Parser c x a2 -> Parser.Advanced.Parser c x a3 -> (a1 -> a2 -> a3 -> Parser.Advanced.Parser c x b) -> Parser.Advanced.Parser c x b

Just like Parser.Extra.bind3.

bind4 : Parser.Advanced.Parser c x a1 -> Parser.Advanced.Parser c x a2 -> Parser.Advanced.Parser c x a3 -> Parser.Advanced.Parser c x a4 -> (a1 -> a2 -> a3 -> a4 -> Parser.Advanced.Parser c x b) -> Parser.Advanced.Parser c x b

Just like Parser.Extra.bind4.

bind5 : Parser.Advanced.Parser c x a1 -> Parser.Advanced.Parser c x a2 -> Parser.Advanced.Parser c x a3 -> Parser.Advanced.Parser c x a4 -> Parser.Advanced.Parser c x a5 -> (a1 -> a2 -> a3 -> a4 -> a5 -> Parser.Advanced.Parser c x b) -> Parser.Advanced.Parser c x b

Just like Parser.Extra.bind5.

Low-Level

These are low-level functions which are used under the hood to implement some of the other parsers of this module.

Maybe they can be useful to you, too?


type alias ParserResult c x a =
Result (List (Parser.Advanced.DeadEnd c x)) a

Result of Parser.Advanced.run. The type alias simplifies the following function signatures a little bit.

getParserResult : Parser.Advanced.Parser c x a -> Parser.Advanced.Parser c x (ParserResult c x a)

Just like Parser.Extra.getParserResult.

getParserOutcome : Parser.Advanced.Parser c x a -> Parser.Advanced.Parser c x ( String, ParserResult c x ( a, Basics.Int ) )

Just like Parser.Extra.getParserOutcome.