aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/control/parser.lux
blob: 081c5a792f15db7cc39a8db01f0d79564a6fd8cb (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
(.module:
  [library
   [lux (#- or and not)
    ["$" documentation (#+ documentation:)]
    [data
     [text (#+ \n)
      ["%" format (#+ format)]]]
    [macro
     ["." template]]]]
  [\\library
   ["." /]]
  ["." / #_
   ["#." analysis]
   ["#." binary]
   ["#." cli]
   ["#." code]
   ["#." environment]
   ... ["#." json]
   ... ["#." synthesis]
   ... ["#." text]
   ... ["#." tree]
   ... ["#." type]
   ... ["#." xml]
   ])

(documentation: /.Parser
  "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
             ]))