(.require
 [library
  [lux (.except)
   ["$" documentation]
   [data
    [text (.only \n)
     ["%" \\format (.only format)]]
    [collection
     ["[0]" list]]]
   [meta
    [macro
     ["[0]" template]]]]]
 ["[0]" \\parser]
 [\\library
  ["[0]" /]])

(`` (def \\parser
      (List $.Documentation)
      (list ($.module \\parser._
                      "")

            ($.definition \\parser.cannot_parse)
            ($.definition \\parser.unconsumed_input)

            ($.definition (\\parser.Parser it)
              "A parser for Lux code analysis nodes.")

            ($.definition \\parser.result
              "Executes a parser and makes sure no inputs go unconsumed."
              [(result parser input)])

            ($.definition \\parser.any
              "Matches any value, without discrimination.")

            ($.definition \\parser.end
              "Ensures there are no more inputs.")

            ($.definition \\parser.end?
              "Checks whether there are no more inputs.")

            (,, (with_template [<query> <assertion>]
                  [($.definition <query>
                     (format "Queries for a " (template.text [<query>]) " value."))
                   ($.definition <assertion>
                     (format "Assert a specific " (template.text [<query>]) " value."))]

                  [\\parser.bit \\parser.this_bit]
                  [\\parser.nat \\parser.this_nat]
                  [\\parser.int \\parser.this_int]
                  [\\parser.rev \\parser.this_rev]
                  [\\parser.frac \\parser.this_frac]
                  [\\parser.text \\parser.this_text]
                  [\\parser.local \\parser.this_local]
                  [\\parser.foreign \\parser.this_foreign]
                  [\\parser.constant \\parser.this_constant]
                  ))

            ($.definition \\parser.tuple
              "Parses only within the context of a tuple's contents."
              [(tuple parser)])
            )))

(def .public documentation
  (List $.Documentation)
  (list.partial ($.module /._
                          "")

                ($.definition /.Branch')
                ($.definition /.Match')
                ($.definition /.Environment)
                ($.definition /.Analysis)
                ($.definition /.Branch)
                ($.definition /.Match)
                ($.definition /.equivalence)
                ($.definition /.when)
                ($.definition /.unit)
                ($.definition /.bit)
                ($.definition /.nat)
                ($.definition /.int)
                ($.definition /.rev)
                ($.definition /.frac)
                ($.definition /.text)
                ($.definition /.no_op)
                ($.definition /.variable)
                ($.definition /.constant)
                ($.definition /.local)
                ($.definition /.foreign)
                ($.definition /.variant)
                ($.definition /.tuple)
                ($.definition /.format)
                ($.definition /.State+)
                ($.definition /.Operation)
                ($.definition /.Phase)
                ($.definition /.Handler)
                ($.definition /.Bundle)
                ($.definition /.with_source_code)
                ($.definition /.with_current_module)
                ($.definition /.with_location)
                ($.definition /.failure)
                ($.definition /.except)
                ($.definition /.assertion)
                ($.definition /.with_exception)
                ($.definition /.set_state)
                ($.definition /.set_source_code)
                ($.definition /.set_current_module)
                ($.definition /.set_location)
                ($.definition /.location)
                ($.definition /.source)
                ($.definition /.info)
                ($.definition /.state)

                ..\\parser
                ))
