electricwah gist felülvizsgálása . Revízióhoz ugrás
1 file changed, 394 insertions
latest-compiler-progress.nv(fájl létrehozva)
@@ -0,0 +1,394 @@ | |||
1 | + | || '@include' (lib/platforms/browser_dom.nv lib/math.nv) | |
2 | + | ||
3 | + | || :DOM: ( <query #code-actions <@after #out or textarea id = out value = [] ) | |
4 | + | | :: output :current dom element: $out? | | |
5 | + | :@js: $out.value += (stacks['final out'].map(x=>x.join(' ')).toReversed().join('\n')+'\n'); delete stacks['final out']; | |
6 | + | ||
7 | + | | :: breakpoint | | |
8 | + | | :: breakpoint | :@js: me.gas = 0; | |
9 | + | ||
10 | + | | :: get cause 1 | | |
11 | + | :stack: A | |
12 | + | :pattern: . a | |
13 | + | . b | |
14 | + | . variable c | |
15 | + | . d | |
16 | + | . variable e | |
17 | + | :index: ( 0 1 2 3 4 ) | |
18 | + | | :: get cause 2 | | |
19 | + | :stack: A | |
20 | + | :pattern: . stride | |
21 | + | . test | |
22 | + | :index: ( 0 1 ) | |
23 | + | | :: get cause 3 | | |
24 | + | :stack: B | |
25 | + | :pattern: . other | |
26 | + | . cause | |
27 | + | . match | |
28 | + | . variable c | |
29 | + | :index: ( 0 1 2 3 ) | |
30 | + | | :: get effect 1 | | |
31 | + | :stack: out_A | |
32 | + | :items: . output | |
33 | + | . one | |
34 | + | . variable c | |
35 | + | :index: ( 0 1 2 ) | |
36 | + | | :: get effect 2 | | |
37 | + | :stack: out_B | |
38 | + | :items: . output | |
39 | + | . 2 | |
40 | + | . variable e | |
41 | + | :index: ( 0 1 2 ) | |
42 | + | ||
43 | + | | :: get rule 1 | | |
44 | + | :causes: ( 1 2 3 ) | |
45 | + | :effects: ( 1 2 ) | |
46 | + | ||
47 | + | | :: get cause 4 | | |
48 | + | :stack: ohnoes | |
49 | + | :pattern: . a | |
50 | + | . second | |
51 | + | . rule | |
52 | + | :index: ( 0 1 2 ) | |
53 | + | | :: get effect 3 | | |
54 | + | :stack: x | |
55 | + | :items: . what | |
56 | + | . shall | |
57 | + | . we | |
58 | + | . do | |
59 | + | :index: ( 0 1 2 3 ) | |
60 | + | ||
61 | + | | :: get rule 2 | | |
62 | + | :causes: ( 4 ) | |
63 | + | :effects: ( 3 ) | |
64 | + | ||
65 | + | | :: get effect 4 | | |
66 | + | :stack: ohnoes | |
67 | + | :items: . a | |
68 | + | . second | |
69 | + | . rule | |
70 | + | :index: ( 0 1 2 ) | |
71 | + | ||
72 | + | | :: get rule 3 | | |
73 | + | :causes: ( ) | |
74 | + | :effects: ( 4 ) | |
75 | + | ||
76 | + | | :rules: breakpoint | :: breakpoint | |
77 | + | || :rules: ( 1 2 3 breakpoint) | |
78 | + | ||
79 | + | |#==============================#| | |
80 | + | || | |
81 | + | :: emit header | |
82 | + | :: process rules | |
83 | + | :: emit step function | |
84 | + | :: process init effects | |
85 | + | :: emit footer | |
86 | + | :: translate :: output | |
87 | + | |:/:| :: process rules | |
88 | + | ||
89 | + | | :: emit header | :out: spacer :out: header | |
90 | + | | :: emit steps func | :out: steps func | |
91 | + | | :: emit footer | :out: footer | |
92 | + | |#==============================#| | |
93 | + | | :: process rules? :rules: $ruleid | | |
94 | + | :: get rule $ruleid | |
95 | + | :: if no causes handle init rule, else process rule $ruleid | |
96 | + | | :: process rules | | |
97 | + | ||
98 | + | | :: if no causes handle init rule, else process rule $ruleid :causes: | :: handle init rule $ruleid | |
99 | + | | :: if no causes handle init rule, else process rule $ruleid :causes: $cause? | :: process rule $ruleid | |
100 | + | ||
101 | + | | :: handle init rule $ruleid? :effects: $effect | | |
102 | + | :init effects: $effect | |
103 | + | | :: handle init rule $ruleid | | |
104 | + | ||
105 | + | | :: process rule $ruleid | | |
106 | + | :try rules: try rule $ruleid | |
107 | + | :: process causes | |
108 | + | :: process effects | |
109 | + | :: emit rule $ruleid | |
110 | + | :: clear rule temp state | |
111 | + | ||
112 | + | ||
113 | + | | :: clear rule temp state? :stack: $stack | | |
114 | + | | :: clear rule temp state? :vars: variable $x = index $y of stack $z at depth $q | | |
115 | + | | :: clear rule temp state | | |
116 | + | ||
117 | + | ||
118 | + | | :: process causes? :causes: $causeid | | |
119 | + | :: get cause $causeid :length: 0 | |
120 | + | :: check stack | |
121 | + | :: process pattern | |
122 | + | :: check fact lengths | |
123 | + | :: pop cause | |
124 | + | | :: process causes | :: clear causes temp state | |
125 | + | ||
126 | + | ||
127 | + | | :: check stack :stack: $stack? | |
128 | + | | :: add stack $stack | |
129 | + | ||
130 | + | | :: check fact lengths | |
131 | + | :stack: $stack? | |
132 | + | :current stride depth: $depth ? | |
133 | + | :length: $length | | |
134 | + | :check fact lengths: check stack $stack depth $depth has length $length | |
135 | + | ||
136 | + | | :: pop cause | |
137 | + | :stack: $stack | | |
138 | + | :pop causes: pop $stack | |
139 | + | ||
140 | + | | :: clear causes temp state :current stride depth: $n | | |
141 | + | ||
142 | + | ||
143 | + | | :: process init effects | | |
144 | + | :: init effects -> effects | |
145 | + | :: process effects | |
146 | + | :: emit :emit: push effects | |
147 | + | ||
148 | + | | :: init effects -> effects? :init effects: $e | :effects: $e | |
149 | + | | :: init effects -> effects | | |
150 | + | ||
151 | + | ||
152 | + | |------------------------------| | |
153 | + | ||
154 | + | | :: add stack $stack? | |
155 | + | :current stride depth: $n | | |
156 | + | ||
157 | + | | :: add stack $stack :@math: $depth | | |
158 | + | :current stride depth: $depth | |
159 | + | :strides: check stack $stack has at least depth $depth | |
160 | + | :: strides temp -> strides | |
161 | + | ||
162 | + | | :: add stack $stack? :strides: check stack $stack has at least depth $depth | | |
163 | + | :@math: add $depth 1 | |
164 | + | ||
165 | + | ||
166 | + | | :: add stack $stack? :strides: check stack $different has at least depth $depth | | |
167 | + | :strides temp: check stack $different has at least depth $depth | |
168 | + | ||
169 | + | | :: add stack $stack | | |
170 | + | :current stride depth: 1 | |
171 | + | :strides temp: check stack $stack has at least depth 1 | |
172 | + | :: strides temp -> strides | |
173 | + | ||
174 | + | | :: strides temp -> strides? | |
175 | + | :strides temp: check stack $stack has at least depth $depth | | |
176 | + | :strides: check stack $stack has at least depth $depth | |
177 | + | ||
178 | + | | :: strides temp -> strides | | |
179 | + | ||
180 | + | |------------------------------| | |
181 | + | ||
182 | + | | :: increment length :length: $old :@math: $n | :length: $n | |
183 | + | | :: increment length? :length: $n? | :@math: add $n 1 | |
184 | + | ||
185 | + | ||
186 | + | | | |
187 | + | :: process pattern? | |
188 | + | :stack: $stack? | |
189 | + | :pattern: variable $name | |
190 | + | :index: $i | |
191 | + | :current stride depth: $depth? | |
192 | + | | | |
193 | + | :: do variable $name at index $i of stack $stack at depth $depth | |
194 | + | :: increment length | |
195 | + | ||
196 | + | |- var is already declared -| | |
197 | + | | :: do variable $name at index $i of stack $stack at depth $depth | |
198 | + | :vars: variable $name = index $j of stack $stack2 at depth $depth2? | |
199 | + | | | |
200 | + | :check vars: check index $i of top of stack $stack at depth $depth equals value of var $name | |
201 | + | :: vars temp -> vars | |
202 | + | ||
203 | + | |# can also do this to give more information #| | |
204 | + | :check vars: check index $i of top of stack $stack at depth $depth equals | |
205 | + | var $name stack $stack2 depth $depth2 index $index2 | |
206 | + | ||
207 | + | |- not the right var, check next -| | |
208 | + | | :: do variable $name at index $i of stack $stack at depth $depth? | |
209 | + | :vars: variable $different = index $j of stack $stack2 at depth $depth2 | |
210 | + | | | |
211 | + | :vars temp: variable $different = index $j of stack $stack2 at depth $depth2 | |
212 | + | ||
213 | + | ||
214 | + | |- variable isn't declared yet, so declare it -| | |
215 | + | | :: do variable $name at index $i of stack $stack at depth $depth | | |
216 | + | :set vars: declare variable $name = index $i of stack $stack at depth $depth | |
217 | + | :vars: variable $name = index $i of stack $stack at depth $depth | |
218 | + | :: vars temp -> vars | |
219 | + | ||
220 | + | ||
221 | + | ||
222 | + | | :: vars temp -> vars | |
223 | + | :vars temp: variable $name = index $i of stack $stack at depth $depth | |
224 | + | | | |
225 | + | :vars: variable $name = index $i of stack $stack at depth $depth | |
226 | + | ||
227 | + | | :: vars temp -> vars | | |
228 | + | ||
229 | + | | | |
230 | + | :: process pattern? | |
231 | + | :stack: $stack? | |
232 | + | :pattern: $symbol | |
233 | + | :index: $i | |
234 | + | :current stride depth: $depth? | |
235 | + | | | |
236 | + | :check facts: check stack $stack at depth $depth matches symbol $symbol at index $i | |
237 | + | :: increment length | |
238 | + | ||
239 | + | | :: process pattern | | |
240 | + | ||
241 | + | |--------------------| | |
242 | + | ||
243 | + | ||
244 | + | | :: process effects? :effects: $effectid | | |
245 | + | :: get effect $effectid | |
246 | + | :: push effects start | |
247 | + | :: process stack | |
248 | + | :: process items | |
249 | + | :: push effects end | |
250 | + | ||
251 | + | | :: process effects | | |
252 | + | ||
253 | + | | :: push effects start | :push effects: start fact to push | |
254 | + | | :: push effects end | :push effects: end fact to push | |
255 | + | ||
256 | + | | | |
257 | + | :: process stack | |
258 | + | :stack: $stack? | |
259 | + | :items: $symbol? | |
260 | + | :index: $i? | |
261 | + | | | |
262 | + | :push effects: stack $stack | |
263 | + | ||
264 | + | ||
265 | + | | | |
266 | + | :: process items? | |
267 | + | :stack: $stack? | |
268 | + | :items: $symbol | |
269 | + | :index: $i | |
270 | + | | | |
271 | + | :push effects: symbol $symbol | |
272 | + | ||
273 | + | | | |
274 | + | :: process items? | |
275 | + | :stack: $stack? | |
276 | + | :items: variable $name | |
277 | + | :index: $i | |
278 | + | | | |
279 | + | :push effects: variable $name | |
280 | + | ||
281 | + | | :: process items | | |
282 | + | |--------------------| | |
283 | + | ||
284 | + | | :emit: rule header $ruleid | |
285 | + | | :out: rule header $ruleid | |
286 | + | ||
287 | + | | :emit: check stack heights? | |
288 | + | :strides: check stack $stack has at least depth $depth | |
289 | + | | :out: check stack $stack has at least depth $depth | |
290 | + | | :emit: check stack heights | | |
291 | + | ||
292 | + | | :emit: check facts lengths? | |
293 | + | :check fact lengths: check stack $stack depth $depth has length $length | |
294 | + | | :out: check stack $stack depth $depth has length $length | |
295 | + | | :emit: check facts lengths | | |
296 | + | ||
297 | + | | :emit: check facts constant symbol matches? | |
298 | + | :check facts: check stack $stack at depth $depth matches symbol $symbol at index $index | |
299 | + | | :out: check stack $stack at depth $depth matches symbol $symbol at index $index | |
300 | + | | :emit: check facts constant symbol matches | | |
301 | + | ||
302 | + | | :emit: set variables? | |
303 | + | :set vars: declare variable $name = index $i of stack $stack at depth $depth | |
304 | + | | :out: declare variable $name = index $i of stack $stack at depth $depth | |
305 | + | | :emit: set variables | | |
306 | + | ||
307 | + | | :emit: check variables equality? | |
308 | + | :check vars: check index $i of top of stack $stack at depth $depth equals value of var $name | |
309 | + | | :out: check index $i of top of stack $stack at depth $depth equals value of var $name | |
310 | + | | :emit: check variables equality | | |
311 | + | ||
312 | + | | :emit: pop causes ? :pop causes: $a $b | :out: $a $b | |
313 | + | ||
314 | + | | :emit: pop causes | | |
315 | + | ||
316 | + | ||
317 | + | | :emit: push effects -> push effects reversed? :push effects: $a | :push effects reversed: $a | |
318 | + | | :emit: push effects -> push effects reversed? :push effects: $a $b | :push effects reversed: $a $b | |
319 | + | | :emit: push effects -> push effects reversed? :push effects: $a $b $c $d | :push effects reversed: $a $b $c $d | |
320 | + | | :emit: push effects -> push effects reversed | | |
321 | + | ||
322 | + | | :emit: push effects reversed -> out? :push effects reversed: $a $b $c $d | :out: $a $b $c $d | |
323 | + | | :emit: push effects reversed -> out? :push effects reversed: $a $b | :out: $a $b | |
324 | + | | :emit: push effects reversed -> out? :push effects reversed: $a | :out: $a | |
325 | + | | :emit: push effects reversed -> out | | |
326 | + | ||
327 | + | | :emit: push effects | | |
328 | + | :emit: push effects -> push effects reversed | |
329 | + | :emit: push effects reversed -> out | |
330 | + | ||
331 | + | | :emit: rule footer | :out: spacer :out: rule footer | |
332 | + | ||
333 | + | | :: emit rule $ruleid | | |
334 | + | :: emit | |
335 | + | :emit: | |
336 | + | . rule header $ruleid | |
337 | + | . check stack heights | |
338 | + | . check facts lengths | |
339 | + | . check facts constant symbol matches | |
340 | + | . set variables | |
341 | + | . check variables equality | |
342 | + | . pop causes | |
343 | + | . push effects | |
344 | + | . rule footer | |
345 | + | ||
346 | + | ||
347 | + | | :: emit step function | | |
348 | + | :emit: | |
349 | + | . step function header | |
350 | + | . try each rule | |
351 | + | . step function footer | |
352 | + | ||
353 | + | | :emit: step function header | :out: step function header :out: spacer | |
354 | + | | :emit: step function footer | :out: spacer :out: step function footer | |
355 | + | ||
356 | + | | :emit: try each rule? | |
357 | + | :try rules: try rule $ruleid | |
358 | + | | :out: try rule $ruleid | |
359 | + | | :emit: try each rule | | |
360 | + | ||
361 | + | | :: emit | | |
362 | + | ||
363 | + | |- :vim:sw=3:ts=3:et: -| | |
364 | + | ||
365 | + | ||
366 | + | ||
367 | + | |#===============#| | |
368 | + | ||
369 | + | | :: translate? :out: spacer | | |
370 | + | :final out: [] | |
371 | + | ||
372 | + | | :: translate? :out: $a | :final out: $a | |
373 | + | | :: translate? :out: $a $b | :final out: $a $b | |
374 | + | | :: translate? :out: $a $b $c | :final out: $a $b $c | |
375 | + | | :: translate? :out: $a $b $c $d | :final out: $a $b $c $d | |
376 | + | | :: translate? :out: $a $b $c $d $e | :final out: $a $b $c $d $e | |
377 | + | | :: translate? :out: $a $b $c $d $e $f | :final out: $a $b $c $d $e $f | |
378 | + | | :: translate? :out: $a $b $c $d $e $f $g | :final out: $a $b $c $d $e $f $g | |
379 | + | | :: translate? :out: $a $b $c $d $e $f $g $h | :final out: $a $b $c $d $e $f $g $h | |
380 | + | | :: translate? :out: $a $b $c $d $e $f $g $h $i | :final out: $a $b $c $d $e $f $g $h $i | |
381 | + | | :: translate? :out: $a $b $c $d $e $f $g $h $i $j | :final out: $a $b $c $d $e $f $g $h $i $j | |
382 | + | | :: translate? :out: $a $b $c $d $e $f $g $h $i $j $k | :final out: $a $b $c $d $e $f $g $h $i $j $k | |
383 | + | | :: translate? :out: $a $b $c $d $e $f $g $h $i $j $k $l | :final out: $a $b $c $d $e $f $g $h $i $j $k $l | |
384 | + | | :: translate? :out: $a $b $c $d $e $f $g $h $i $j $k $l $m | :final out: $a $b $c $d $e $f $g $h $i $j $k $l $m | |
385 | + | | :: translate? :out: $a $b $c $d $e $f $g $h $i $j $k $l $m $n | :final out: $a $b $c $d $e $f $g $h $i $j $k $l $m $n | |
386 | + | | :: translate? :out: $a $b $c $d $e $f $g $h $i $j $k $l $m $n $o | :final out: $a $b $c $d $e $f $g $h $i $j $k $l $m $n $o | |
387 | + | | :: translate? :out: $a $b $c $d $e $f $g $h $i $j $k $l $m $n $o $p | :final out: $a $b $c $d $e $f $g $h $i $j $k $l $m $n $o $p | |
388 | + | | :: translate? :out: $a $b $c $d $e $f $g $h $i $j $k $l $m $n $o $p $q | :final out: $a $b $c $d $e $f $g $h $i $j $k $l $m $n $o $p $q | |
389 | + | | :: translate | | |
390 | + | ||
391 | + | ||
392 | + | |#========#| | |
393 | + | ||
394 | + | ||«@js« window.init && window.init(`{"sections":3,"stacks1":["try rules","check fact lengths","check facts","set vars","pop causes","strides"],"stacks2":["out"]}`) |
Újabb
Régebbi