(.using
  [library
   [lux {"-" or and not}
    ["$" documentation {"+" documentation:}]
    [data
     [text {"+" \n}
      ["%" format {"+" format}]]]
    [macro
     ["[0]" template]]]]
  [\\library
   ["[0]" /]]
  ["[0]" / "_"
   ["[1][0]" analysis]
   ["[1][0]" binary]
   ["[1][0]" cli]
   ["[1][0]" code]
   ["[1][0]" environment]
   ["[1][0]" json]
   ["[1][0]" synthesis]
   ["[1][0]" text]
   ["[1][0]" tree]
   ["[1][0]" type]
   ["[1][0]" xml]])

(documentation: (/.Parser state it)
  "A generic parser.")

(documentation: /.assertion
  "Fails with the given message if the test is #0."
  [(assertion message test)])

(documentation: /.maybe
  "Optionality combinator."
  [(maybe parser)])

(documentation: /.result
  (format "Executes the parser on the input."
          \n "Does not verify that all of the input has been consumed by the parser."
          \n "Returns both the parser's output, and a value that represents the remaining input.")
  [(result parser input)])

(documentation: /.and
  "Sequencing combinator."
  [(and first second)])

(documentation: /.or
  "Heterogeneous alternative combinator."
  [(or left right)])

(documentation: /.either
  "Homogeneous alternative combinator."
  [(either this that)])

(documentation: /.some
  "0-or-more combinator."
  [(some parser)])

(documentation: /.many
  "1-or-more combinator."
  [(many parser)])

(documentation: /.exactly
  "Parse exactly N times."
  [(exactly amount parser)])

(documentation: /.at_least
  "Parse at least N times."
  [(at_least amount parser)])

(documentation: /.at_most
  "Parse at most N times."
  [(at_most amount parser)])

(documentation: /.between
  ""
  [(between minimum additional parser)])

(documentation: /.separated_by
  "Parses instances of 'parser' that are separated by instances of 'separator'."
  [(separated_by separator parser)])

(documentation: /.not
  "Only succeeds when the underlying parser fails."
  [(not parser)])

(documentation: /.failure
  "Always fail with this 'message'."
  [(failure message)])

(documentation: /.lifted
  "Lift a potentially failed computation into a parser."
  [(lifted operation)])

(documentation: /.else
  "If the given parser fails, returns the default value."
  [(else value parser)])

(documentation: /.remaining
  "Yield the remaining input (without consuming it).")

(documentation: /.rec
  "Combinator for recursive parsers."
  [(rec parser)])

(documentation: /.after
  "Run the parser after another one (whose output is ignored)."
  [(after param subject)])

(documentation: /.before
  "Run the parser before another one (whose output is ignored)."
  [(before param subject)])

(documentation: /.only
  "Only succeed when the parser's output passes a test."
  [(only test parser)])

(documentation: /.parses?
  "Ignore a parser's output and just verify that it succeeds."
  [(parses? parser)])

(documentation: /.parses
  "Ignore a parser's output and just execute it."
  [(parses parser)])

(documentation: /.speculative
  (format "Executes a parser, without actually consuming the input."
          \n "That way, the same input can be consumed again by another parser.")
  [(speculative parser)])

(documentation: /.codec
  "Decode the output of a parser using a codec."
  [(codec codec parser)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Parser
             ..assertion
             ..maybe
             ..result
             ..and
             ..or
             ..either
             ..some
             ..many
             ..exactly
             ..at_least
             ..at_most
             ..between
             ..separated_by
             ..not
             ..failure
             ..lifted
             ..else
             ..remaining
             ..rec
             ..after
             ..before
             ..only
             ..parses?
             ..parses
             ..speculative
             ..codec
             ($.default /.functor)
             ($.default /.apply)
             ($.default /.monad)]
            [/analysis.documentation
             /binary.documentation
             /cli.documentation
             /code.documentation
             /environment.documentation
             /json.documentation
             /synthesis.documentation
             /text.documentation
             /tree.documentation
             /type.documentation
             /xml.documentation]))
