aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/meta/code.lux
blob: 36d3ec0d2d27eb54ea5a55324ae942da02b8db09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
(.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 $.Module)
      ($.module \\parser._
                ""
                [($.definition (\\parser.Parser it)
                   "A Lux code parser.")

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

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

                       [\\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.symbol \\parser.this_symbol]
                       ))

                 ($.definition \\parser.this
                   "Ensures the given Code is the next input."
                   [(this code)])

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

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

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

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

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

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

                 ($.definition \\parser.result
                   "Executes a parser against a stream of code, and verifies all the inputs are consumed."
                   [(result parser inputs)])

                 ($.definition \\parser.locally
                   "Runs parser against the given list of inputs."
                   [(locally inputs parser)])

                 ($.definition \\parser.not
                   "Yields the next Code token if the parser fails."
                   [(not expected_to_fail)])

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

(.def .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [($.default /.bit)
             ($.default /.nat)
             ($.default /.int)
             ($.default /.rev)
             ($.default /.frac)
             ($.default /.text)
             ($.default /.symbol)
             ($.default /.form)
             ($.default /.variant)
             ($.default /.tuple)
             
             ($.default /.equivalence)
             ($.default /.format)

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

             ($.definition /.replaced
               ""
               [(replaced original substitute ast)])]
            [..\\parser]))