aboutsummaryrefslogtreecommitdiff
path: root/new-luxc/source/luxc/module/descriptor/common.lux
blob: 60a313115f002f9abb70ed81479b3612e238935d (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
(;module:
  lux
  (lux (data [text]
             (text format
                   ["l" lexer "l/" Monad<Lexer>])
             [char]
             (coll [list "L/" Functor<List>]))))

(type: #export Signal Text)

(do-template [<name> <code>]
  [(def: #export <name> Signal (|> <code> char;char char;as-text))]

  [cons-signal +5]
  [nil-signal  +6]
  [stop-signal +7]
  )

(do-template [<name> <code>]
  [(def: #export <name> Signal <code>)]

  [ident-separator ";"]
  )

(def: #export (encode-list encode-elem types)
  (All [a] (-> (-> a Text) (List a) Text))
  (format (|> (L/map encode-elem types)
              (text;join-with cons-signal))
          nil-signal))

(def: #export (decode-list decode-elem)
  (All [a] (-> (l;Lexer a) (l;Lexer (List a))))
  (l;alt (<| (l;after (l;text nil-signal))
             (l/wrap []))
         (<| (l;seq decode-elem)
             (l;after (l;text cons-signal))
             (decode-list decode-elem))))