... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

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

(`` (the \\projection
      (List $.Documentation)
      (list ($.module \\projection._
                      "")

            ($.definition (\\projection.Projection it)
              "A Lux code projection.")

            ($.definition \\projection.any
              "Yields the next input without applying any logic.")

            (,, (template.with [<query> <check>]
                  [(`` ($.definition <query>
                         (%.message "Parses the next " (,, (template.text [<query>])) " input.")))
                   (`` ($.definition <check>
                         (%.message "Checks for a specific " (,, (template.text [<query>])) " input.")))]

                  [\\projection.bit \\projection.this_bit]
                  [\\projection.natural \\projection.this_natural]
                  [\\projection.integer \\projection.this_integer]
                  [\\projection.revolution \\projection.this_revolution]
                  [\\projection.decimal \\projection.this_decimal]
                  [\\projection.text \\projection.this_text]
                  [\\projection.symbol \\projection.this_symbol]
                  ))

            ($.definition \\projection.this
              "Ensures the given Code is the next input."
              ($.example (' (this code))))

            (,, (template.with [<query> <check> <desc>]
                  [($.definition <query>
                     (%.message "Parse a local " <desc> " (a " <desc> " that has no module prefix)."))
                   ($.definition <check>
                     (%.message "Checks for a specific local " <desc> " (a " <desc> " that has no module prefix)."))]

                  [\\projection.local \\projection.this_local "local symbol"]
                  ))

            (,, (template.with [<name>]
                  [(`` ($.definition <name>
                         (%.message "Parses the contents of a " (,, (template.text [<name>])) ".")))]

                  [\\projection.form]
                  [\\projection.variant]
                  [\\projection.tuple]
                  ))

            ($.definition \\projection.end
              "Verifies there are no more inputs.")

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

            ($.definition \\projection.value
              "Executes a projection against a stream of code, and verifies all the inputs are consumed."
              ($.example (' (value projection inputs))))

            ($.definition \\projection.locally
              "Runs projection against the given list of inputs."
              ($.example (' (locally inputs projection))))

            ($.definition \\projection.not
              "Yields the next Code token if the projection fails."
              ($.example (' (not expected_to_fail))))

            ($.definition \\projection.next
              "Yields the next Code token without consuming it from the input stream.")
            )))

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

                ($.definition /.bit)
                ($.definition /.natural)
                ($.definition /.integer)
                ($.definition /.revolution)
                ($.definition /.decimal)
                ($.definition /.text)
                ($.definition /.symbol)
                ($.definition /.form)
                ($.definition /.variant)
                ($.definition /.tuple)
                
                ($.definition /.equivalence)
                ($.definition /.injection)

                ($.definition /.local
                  "Produces a local symbol (an symbol with no module prefix).")

                ($.definition /.replaced
                  ""
                  ($.example (' (replaced original substitute ast))))

                ..\\projection
                ))
