blob: 794d4aff26527a8bed8cff09713d66e71818c711 (
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
|
(.module:
[lux #*
[abstract
["." monad (#+ do)]]
[control
["." function]
["<>" parser
["<s>" synthesis (#+ Parser)]]]
[data
[collection
["." dictionary]
["." list]]
[text
["%" format (#+ format)]]]
[target
["_" php (#+ Var Expression)]]]
["." // #_
["#." common (#+ custom)]
["//#" /// #_
["/" bundle]
["/#" // #_
["." extension]
[generation
[extension (#+ Nullary Unary Binary Trinary
nullary unary binary trinary)]
["." reference]
["//" php #_
["#." runtime (#+ Operation Phase Handler Bundle
with_vars)]]]
["/#" // #_
["." generation]
["//#" /// #_
["#." phase]]]]]])
(def: (array::new size)
(Unary Expression)
(//runtime.tuple//make size (_.array_fill/3 [(_.int +0) size _.null])))
(def: (array::read [indexG arrayG])
(Binary Expression)
(_.nth indexG arrayG))
(def: (array::write [indexG valueG arrayG])
(Trinary Expression)
(//runtime.array//write indexG valueG arrayG))
(def: (array::delete [indexG arrayG])
(Binary Expression)
(//runtime.array//write indexG _.null arrayG))
(def: array
Bundle
(<| (/.prefix "array")
(|> /.empty
(/.install "new" (unary array::new))
(/.install "length" (unary //runtime.array//length))
(/.install "read" (binary array::read))
(/.install "write" (trinary array::write))
(/.install "delete" (binary array::delete))
)))
(def: object::get
Handler
(custom
[($_ <>.and <s>.text <s>.any)
(function (_ extension phase archive [fieldS objectS])
(do ////////phase.monad
[objectG (phase archive objectS)]
(wrap (_.the fieldS objectG))))]))
(def: object::do
Handler
(custom
[($_ <>.and <s>.text <s>.any (<>.some <s>.any))
(function (_ extension phase archive [methodS objectS inputsS])
(do {! ////////phase.monad}
[objectG (phase archive objectS)
inputsG (monad.map ! (phase archive) inputsS)]
(wrap (_.do methodS inputsG objectG))))]))
(template [<!> <?> <unit>]
[(def: <!> (Nullary Expression) (function.constant <unit>))
(def: <?> (Unary Expression) (_.=== <unit>))]
[object::null object::null? _.null]
)
(def: object
Bundle
(<| (/.prefix "object")
(|> /.empty
(/.install "get" object::get)
(/.install "do" object::do)
(/.install "null" (nullary object::null))
(/.install "null?" (unary object::null?))
)))
(def: php::constant
(custom
[<s>.text
(function (_ extension phase archive name)
(\ ////////phase.monad wrap (_.constant name)))]))
(def: php::apply
(custom
[($_ <>.and <s>.any (<>.some <s>.any))
(function (_ extension phase archive [abstractionS inputsS])
(do {! ////////phase.monad}
[abstractionG (phase archive abstractionS)
inputsG (monad.map ! (phase archive) inputsS)]
(wrap (_.apply/* inputsG abstractionG))))]))
(def: php::pack
(custom
[($_ <>.and <s>.any <s>.any)
(function (_ extension phase archive [formatS dataS])
(do {! ////////phase.monad}
[formatG (phase archive formatS)
dataG (phase archive dataS)]
(wrap (_.pack/2 [formatG (_.splat dataG)]))))]))
(def: #export bundle
Bundle
(<| (/.prefix "php")
(|> /.empty
(dictionary.merge ..array)
(dictionary.merge ..object)
(/.install "constant" php::constant)
(/.install "apply" php::apply)
(/.install "pack" php::pack)
(/.install "script universe" (nullary (function.constant (_.bool reference.universe))))
)))
|