[{"name":"Pratt","comment":"\n\n  - [**Parser**](#parser): [`expression`](#expression)\n  - [**Configuration**](#configuration): [`Config`](#Config)\n    [`configure`](#configure)\n  - [**Configuration Helpers**](#configuration-helpers):\n    [`subExpression`](#subExpression)\n      - [**NUD Helpers**](#nud-helpers): [`constant`](#constant) [`prefix`](#prefix)\n      - [**LED Helpers**](#led-helpers): [`infixLeft`](#infixLeft)\n        [`infixRight`](#infixRight) [`postfix`](#postfix)\n\n\n# Parser\n\n@docs expression\n\n\n# Configuration\n\n@docs Config, configure\n\n\n# Configuration Helpers\n\n@docs subExpression\n\n\n## NUD Helpers\n\n@docs constant, prefix\n\n\n## LED Helpers\n\n@docs infixLeft, infixRight, postfix\n\n","unions":[],"aliases":[{"name":"Config","comment":" An opaque type based on\n[`Pratt.Advanced.Config`](Pratt.Advanced#Config)\nrepresenting the parser configuration.\nA `Config` is created using [`configure`](#configure).\n","args":["expr"],"type":"Pratt.Advanced.Config Basics.Never Parser.Problem expr"}],"values":[{"name":"configure","comment":" Build a [`Config`](#Config) from `NUD`, `LED` and `spaces` parsers.\n\n**`nuds`:**\n\n> A list of _\"**Nu**ll **D**enotation\"_ parsers that do **not** take an\n> expression on the left. They will be tried successively by the parser using\n> `Parser.oneOf` and the parser `Config`.\n\n> Examples: parsers for constants, literals, prefix expressions,\n> function calls or a sub-expression between parentheses.\n\n**`leds`:**\n\n> A list of _\"**Le**ft **D**enotation\"_ parsers that **do** take an expression\n> on the left and have an `Int` _binding power_. The ones that have a binding\n> power above the current one (`0` by default) will be tried by the parser using\n> `Parser.oneOf`, the parser `Config` and the current _left_ expression (the\n> expression returned by the previous parser).\n\n> Examples: parsers for prefix and postfix expressions.\n\n**`spaces`:**\n\n> A parser called before and after each `nud` and `led` parser, usually used to\n> consume whitespaces.\n\n> If a more specific behavior is needed, this parser can be ignored by using\n> `succeed ()` and a custom behavior added inside `nuds` and `leds` parsers.\n\n**Notes:**\n\n  - The `NUD` and `LED` parsers are parameterized by a [`Config`](#Config)\n    to be able to call [`expression`](#expression) and\n    [`subExpression`](#subExpression), which are the main building\n    blocks for `NUD` and `LED` helpers. This `Config` will be automatically\n    passed by the parser.\n  - The parser will not use `backtrackable`, so it is up to you to correctly\n    setup your parsers to avoid having failed parsers consuming characters.\n\nFor example, a basic calculator could be configured like this:\n\n    import Parser exposing (..)\n    import Pratt exposing (..)\n\n    nuds : List (Config Float -> Parser Float)\n    nuds =\n        [ always float\n        , prefix 3 (symbol \"-\") negate\n        , \\config ->\n            succeed identity\n                |. symbol \"(\"\n                |= expression config\n                |. symbol \")\"\n        ]\n\n    leds : List (Config Float -> ( Int, Float -> Parser Float ))\n    leds =\n        [ infixLeft 1 (symbol \"+\") (+)\n        , infixLeft 1 (symbol \"-\") (-)\n        , infixLeft 2 (symbol \"*\") (*)\n        , infixLeft 2 (symbol \"/\") (/)\n        , infixRight 4 (symbol \"^\") (^)\n        ]\n\n    conf : Config Float\n    conf =\n        configure\n            { nuds = nuds\n            , leds = leds\n            , spaces = spaces\n            }\n\n    parser : Parser Float\n    parser =\n        succeed identity\n            |= expression  conf\n            |. end\n\n\n    run parser \"-1*3--5+4/2^2\" --> Ok ((-1*3)-(-5)+(4/(2^2)))\n    run parser \"-1*3--5+4/2^2\" --> Ok 3\n    run parser \"((-1*3)-(-5)+(4/(2^2)))\" --> Ok 3\n\n","type":"{ nuds : List.List (Pratt.Config expr -> Parser.Parser expr), leds : List.List (Pratt.Config expr -> ( Basics.Int, expr -> Parser.Parser expr )), spaces : Parser.Parser () } -> Pratt.Config expr"},{"name":"constant","comment":" Build a NUD parser for a constant.\n\nThe `Config` argument is passed automatically by the parser.\n\n    import Parser exposing (..)\n    import Pratt exposing (..)\n\n    nuds : List (Config Float -> Parser Float)\n    nuds =\n        [ constant (keyword \"pi\") pi ]\n\n    conf : Config Float\n    conf =\n        configure\n            { nuds = nuds, leds = [], spaces = spaces }\n\n    run (expression conf) \"pi\" --> Ok pi\n\n","type":"Parser.Parser () -> expr -> Pratt.Config expr -> Parser.Parser expr"},{"name":"expression","comment":" Build a parser based on the given [configuration](#configuration) that can\nbe combined with other\n[`elm/parser`](https://package.elm-lang.org/packages/elm/parser/1.1.0/Parser)\nparsers.\n\nThe top level expression is parsed with a _binding power_ of 0,\nsee [`subExpression`](#subExpression).\n\nFor example a parser that, given a [`Config`](#Config), requires the end of the\nstring after having parsed successfully an expression, can be written like this:\n\n    import Parser exposing (..)\n    import Pratt exposing (..)\n\n    parser : Config expr -> Parser expr\n    parser config =\n        succeed identity\n            |= expression config\n            |. end\n\nLet's test it with a simple integer `NUD` parser:\n\n    nuds : List (Config Int -> Parser Int)\n    nuds =\n        [ always int ]\n\n    conf : Config Int\n    conf =\n        configure\n            { nuds = nuds\n            , leds = []\n            , spaces = succeed ()\n            }\n\n    run (parser conf) \"1\" --> Ok 1\n\nOur `spaces` parser is set to `succeed ()` and therefore does nothing,\nso trailing spaces are forbidden:\n\n    run (parser conf) \"1 \"\n    --> Err [{ row = 1, col = 2, problem = ExpectingEnd }]\n\nWithout `Parser.end`, the parser will succeed, consuming only the first\nexpression:\n\n    run (expression conf) \"1 2\" --> Ok 1\n\n","type":"Pratt.Config expr -> Parser.Parser expr"},{"name":"infixLeft","comment":" Build a LED parser for an infix expression with a left-associative operator\nand a given _binding power_.\n\nThe `Config` argument is passed automatically by the parser.\n\n    import Parser exposing (..)\n    import Pratt exposing (..)\n\n    nuds : List (Config Float -> Parser Float)\n    nuds =\n        [ always float ]\n\n    leds : List (Config Float -> (Int, Float -> Parser Float))\n    leds =\n        [ infixLeft 1 (symbol \"+\") (+)\n        , infixLeft 1 (symbol \"-\") (-)\n        , infixLeft 2 (symbol \"*\") (*)\n        , infixLeft 2 (symbol \"/\") (/)\n        ]\n\n    conf : Config Float\n    conf =\n        configure\n            { nuds = nuds, leds = leds, spaces = spaces }\n\n    run (expression conf) \"5+4-3*2/1\" --> Ok (5+4-(3*2/1))\n    run (expression conf) \"5+4-3*2/1\" --> Ok 3\n\n","type":"Basics.Int -> Parser.Parser () -> (expr -> expr -> expr) -> Pratt.Config expr -> ( Basics.Int, expr -> Parser.Parser expr )"},{"name":"infixRight","comment":" Build a LED parser for an infix expression with a right-associative operator\nand a given _binding power_.\n\nThe `Config` argument is passed automatically by the parser.\n\n    import Parser exposing (..)\n    import Pratt exposing (..)\n\n    nuds : List (Config Float -> Parser Float)\n    nuds =\n        [ always float ]\n\n    leds : List (Config Float -> (Int, Float -> Parser Float))\n    leds =\n        [ infixRight 4 (symbol \"^\") (^) ]\n\n    conf : Config Float\n    conf =\n        configure\n            { nuds = nuds, leds = leds, spaces = spaces }\n\n    run (expression conf) \"2^2^3\" --> Ok (2^(2^3))\n    run (expression conf) \"2^2^3\" --> Ok 256\n\n**Note:** As usual in Pratt parsers, right-associativity is achieved by parsing the right\nexpression with the _binding power_ of the infix operator minus 1.\n\n","type":"Basics.Int -> Parser.Parser () -> (expr -> expr -> expr) -> Pratt.Config expr -> ( Basics.Int, expr -> Parser.Parser expr )"},{"name":"postfix","comment":" Build a LED parser for a postfix expression with a given _binding power_.\n\nThe `Config` argument is passed automatically by the parser.\n\n    import Parser exposing (..)\n    import Pratt exposing (..)\n\n    nuds : List (Config Float -> Parser Float)\n    nuds =\n        [ always float ]\n\n\n    leds : List (Config Float -> (Int, Float -> Parser Float))\n    leds =\n        [ postfix 6 (symbol \"°\") degrees ]\n\n    conf : Config Float\n    conf =\n        configure\n            { nuds = nuds, leds = leds, spaces = spaces }\n\n    run (expression conf) \"180°\" --> Ok pi\n    run (expression conf) \"360°\" --> Ok (2*pi)\n\n","type":"Basics.Int -> Parser.Parser () -> (expr -> expr) -> Pratt.Config expr -> ( Basics.Int, expr -> Parser.Parser expr )"},{"name":"prefix","comment":" Build a NUD parser for a prefix expression with a given _binding power_.\n\nThe `Config` argument is passed automatically by the parser.\n\n    import Parser exposing (..)\n    import Pratt exposing (..)\n\n    nuds : List (Config Int -> Parser Int)\n    nuds =\n        [ always int\n        , prefix 3 (symbol \"-\") negate\n        , prefix 3 (symbol \"+\") identity\n        ]\n\n    conf : Config Int\n    conf =\n        configure\n            { nuds = nuds, leds = [], spaces = spaces }\n\n    run (expression conf) \"-1\" --> Ok -1\n    run (expression conf) \"--1\" --> Ok 1\n    run (expression conf) \"+1\" --> Ok 1\n    run (expression conf) \"+-+-1\" --> Ok 1\n\n","type":"Basics.Int -> Parser.Parser () -> (expr -> expr) -> Pratt.Config expr -> Parser.Parser expr"},{"name":"subExpression","comment":" Build an expression parser based on the given _binding power_ and\nconfiguration.\n\nThis is the core function of the parser.\nThe [`expression`](#expression) function is actually implemented using\n`subExpression` with a _binding power_ of 0, like this:\n\n    expression : Config expr -> Parser expr\n    expression config =\n        subExpression 0 config\n\n`subExpression` and `expression` are also used to make `LED` and `NUD` helpers.\n\nFor example [`prefix`](#prefix) can be implemented like this:\n\n    prefix : Int -> Parser () -> (e -> e) -> Config expr -> Parser expr\n    prefix bindingPower operator apply config =\n        succeed apply\n            |. operator\n            |= subExpression bindingPower config\n\nOr a parser for sub-expressions between parentheses like this:\n\n    parens : Config Expr -> Parser Expr\n    parens config =\n        succeed identity\n            |. symbol \"(\"\n            |= expression config\n            |. symbol \")\"\n\nOr using `prefix`:\n\n    parens : Config Expr -> Parser Expr\n    parens config =\n        prefix 0 (symbol \"(\") identity config\n            |. symbol \")\"\n\n**Algorithm**:\n\n`subExpression` uses the following algorithm:\n\n1.  Use the `Int` _binding power_ argument as the current _binding power_.\n\n2.  Run the `spaces` parser.\n\n3.  Try `nuds` parsers successively in order using\n    [`Parser.oneOf`](https://package.elm-lang.org/packages/elm/parser/1.1.0/Parser#oneOf)\n    until one is chosen (i.e. until one of them consumes characters).\n    This parser may call `expression` or `subExpression` recursively with\n    different _binding power_ values.\n    If no parser succeeds, the whole parser fails, else the expression returned\n    by the `nud` parser is used as the _left_ expression in the next steps.\n\n4.  Run the `spaces` parser.\n\n5.  Select `leds` parsers that have a _binding power_ above the current one,\n    try them successively using `Parser.oneOf` with the _left_ expression\n    argument until one is chosen. This parser may also call `expression` or\n    `subExpression`recursively with different _binding power_ values.\n\n6.  If no `led` parser succeeds, return the _left_ expression.\n    Else, loop from 4. using the expression just parsed by the `led` parser\n    as the new _left_ expression.\n\n","type":"Basics.Int -> Pratt.Config expr -> Parser.Parser expr"}],"binops":[]},{"name":"Pratt.Advanced","comment":" `Pratt.Advanced` provides the same API as [`Pratt`](Pratt),\nbut for [`Parser.Advanced`](https://package.elm-lang.org/packages/elm/parser/1.1.0/Parser-Advanced). This allows to have custom `context` and `problem` types to improve error messages.\n\n\n# Parser\n\n@docs expression\n\n\n# Configuration\n\n@docs Config, configure\n\n\n# Configuration Helpers\n\n@docs subExpression\n\n\n## NUD Helpers\n\n@docs constant, prefix\n\n\n## LED Helpers\n\n@docs infixLeft, infixRight, postfix\n\n","unions":[{"name":"Config","comment":" An opaque type describing the parser configuration.\nA `Config` is created using [`configure`](#configure).\n","args":["c","x","e"],"cases":[]}],"aliases":[],"values":[{"name":"configure","comment":" Just like [`Pratt.configure`](Pratt#configure).\n","type":"{ nuds : List.List (Pratt.Advanced.Config c x e -> Parser.Advanced.Parser c x e), leds : List.List (Pratt.Advanced.Config c x e -> ( Basics.Int, e -> Parser.Advanced.Parser c x e )), spaces : Parser.Advanced.Parser c x () } -> Pratt.Advanced.Config c x e"},{"name":"constant","comment":" Just like [`Pratt.constant`](Pratt#constant).\n","type":"Parser.Advanced.Parser c x () -> e -> Pratt.Advanced.Config c x e -> Parser.Advanced.Parser c x e"},{"name":"expression","comment":" Just like [`Pratt.parser`](Pratt#parser).\n","type":"Pratt.Advanced.Config c x e -> Parser.Advanced.Parser c x e"},{"name":"infixLeft","comment":" Just like [`Pratt.infixLeft`](Pratt#infixLeft).\n","type":"Basics.Int -> Parser.Advanced.Parser c x () -> (e -> e -> e) -> Pratt.Advanced.Config c x e -> ( Basics.Int, e -> Parser.Advanced.Parser c x e )"},{"name":"infixRight","comment":" Just like [`Pratt.infixRight`](Pratt#infixRight).\n","type":"Basics.Int -> Parser.Advanced.Parser c x () -> (e -> e -> e) -> Pratt.Advanced.Config c x e -> ( Basics.Int, e -> Parser.Advanced.Parser c x e )"},{"name":"postfix","comment":" Just like [`Pratt.postfix`](Pratt#postfix).\n","type":"Basics.Int -> Parser.Advanced.Parser c x () -> (e -> e) -> Pratt.Advanced.Config c x e -> ( Basics.Int, e -> Parser.Advanced.Parser c x e )"},{"name":"prefix","comment":" Just like [`Pratt.prefix`](Pratt#prefix).\n","type":"Basics.Int -> Parser.Advanced.Parser c x () -> (e -> e) -> Pratt.Advanced.Config c x e -> Parser.Advanced.Parser c x e"},{"name":"subExpression","comment":" Just like [`Pratt.expression`](Pratt#expression).\n","type":"Basics.Int -> Pratt.Advanced.Config c x e -> Parser.Advanced.Parser c x e"}],"binops":[]}]