aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/control/parser/synthesis.lux
blob: 4f8f41124c235259d96aa63a3ba7c833f686b09e (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
(.module:
  [library
   [lux (#- i64 local function loop)
    ["$" documentation (#+ documentation:)]
    [data
     [text (#+ \n)
      ["%" format (#+ format)]]]
    [macro
     ["." template]]]]
  [\\library
   ["." /]])

(documentation: (/.Parser it)
  "A parser for the Lux compiler's synthesis nodes using during optimization.")

(documentation: /.result
  (format "Executes the parser against the inputs."
          \n "Ensures all inputs are consumed by the parser.")
  [(result parser input)])

(documentation: /.any
  "Yields a synthesis node without subjecting it to any analysis.")

(documentation: /.end!
  "Ensures there are no more inputs.")

(documentation: /.end?
  "Checks whether there are no more inputs.")

(template [<query> <assertion>]
  [(`` (documentation: <query>
         (format "Queries for a " (~~ (template.text [<query>])) " synthesis node.")))
   (`` (documentation: <assertion>
         (format "Checks for a specific " (~~ (template.text [<query>])) " synthesis node.")
         [(<assertion> expected)]))]

  [/.bit /.bit!]
  [/.i64 /.i64!]
  [/.f64 /.f64!]
  [/.text /.text!]
  [/.local /.local!]
  [/.foreign /.foreign!]
  [/.constant /.constant!]
  )

(documentation: /.tuple
  "Parses the contents of a tuple."
  [(tuple parser)])

(documentation: /.function
  "Parses the body of a function with the 'expected' arity."
  [(function expected parser)])

(documentation: /.loop
  "Parses the initial values and the body of a loop."
  [(loop init_parsers iteration_parser)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..Parser
             ..result
             ..any
             ..end!
             ..end?

             ..bit ..bit!
             ..i64 ..i64!
             ..f64 ..f64!
             ..text ..text!
             ..local ..local!
             ..foreign ..foreign!
             ..constant ..constant!
             
             ..tuple
             ..function
             ..loop
             ($.default /.cannot_parse)
             ($.default /.unconsumed_input)
             ($.default /.expected_empty_input)
             ($.default /.wrong_arity)
             ($.default /.empty_input)]
            []))