aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta/macro/syntax/export.lux
blob: 3ffff3e0563a3f231418979ca2e09f24c5548fb0 (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
(.require
 [library
  [lux (.except with)
   [abstract
    [monad (.only do)]]
   [control
    ["<>" parser]]
   [meta
    ["[0]" code
     ["<[1]>" \\parser (.only Parser)]]]]])

(type .public Policy
  Code)

(def .public default
  Policy
  (` .private))

(`` (def policy
      (Parser Policy)
      (do [! <>.monad]
        [candidate <code>.next]
        (when candidate
          [_ {.#Symbol ["" _]}]
          (in default)

          (,, (with_template [<tag>]
                [[_ {<tag> _}]
                 (do !
                   [_ <code>.any]
                   (in candidate))]

                [.#Bit]
                [.#Symbol]
                ))
          
          _
          (in default)))))

(def .public with
  (All (_ of)
    (-> (Parser of)
        (Parser [Policy of])))
  (<>.and ..policy))