1 | #include <rf_core.hh> |
---|
2 | #include <refal/Access.hh> |
---|
3 | #include <refal/Box.hh> |
---|
4 | #include <refal/Apply.hh> |
---|
5 | #include <refal/Compare.hh> |
---|
6 | #include <refal/StdIO.hh> |
---|
7 | #include <refal/Error.hh> |
---|
8 | #include <refal/Class.hh> |
---|
9 | |
---|
10 | namespace refal |
---|
11 | { |
---|
12 | |
---|
13 | using namespace rfrt; |
---|
14 | |
---|
15 | namespace Stream |
---|
16 | { |
---|
17 | |
---|
18 | RF_DECL (Stream); |
---|
19 | |
---|
20 | RF_DECL (Read_m_Expr); |
---|
21 | |
---|
22 | RF_DECL (Expr_m_Open); |
---|
23 | |
---|
24 | RF_DECL (File_m_Open); |
---|
25 | |
---|
26 | RF_DECL (File_m_Close); |
---|
27 | |
---|
28 | static Expr StdIStream_m_Box; |
---|
29 | |
---|
30 | RF_DECL (StdIStream); |
---|
31 | |
---|
32 | RF_DECL (Getc); |
---|
33 | |
---|
34 | RF_DECL (Gets); |
---|
35 | |
---|
36 | RF_DECL (Ungets); |
---|
37 | |
---|
38 | RF_DECL (Scanc); |
---|
39 | |
---|
40 | RF_DECL (Get_m_Delim); |
---|
41 | |
---|
42 | RF_DECL (Not_m_EOL); |
---|
43 | |
---|
44 | RF_DECL (Get_m_Line); |
---|
45 | |
---|
46 | RF_DECL (Get_m_While); |
---|
47 | |
---|
48 | RF_DECL (End_m_of_m_Stream_q_); |
---|
49 | |
---|
50 | RF_DECL (Prim_m_Read__0); |
---|
51 | |
---|
52 | RF_DECL (Read_m_Expr__0); |
---|
53 | |
---|
54 | RF_DECL (Not_m_EOL__0); |
---|
55 | |
---|
56 | static Expr _c_0; |
---|
57 | |
---|
58 | static Expr _c_1; |
---|
59 | |
---|
60 | static Expr _c_2; |
---|
61 | |
---|
62 | static Expr _c_3; |
---|
63 | |
---|
64 | static Expr _c_4; |
---|
65 | |
---|
66 | static Expr _c_5; |
---|
67 | |
---|
68 | static Expr _c_6; |
---|
69 | |
---|
70 | static Expr _c_7; |
---|
71 | |
---|
72 | static Expr _c_8; |
---|
73 | |
---|
74 | static Expr _c_9; |
---|
75 | |
---|
76 | static Expr _c_10; |
---|
77 | |
---|
78 | static Expr _c_11; |
---|
79 | |
---|
80 | static Expr _c_12; |
---|
81 | |
---|
82 | static Expr _c_13; |
---|
83 | |
---|
84 | static Expr _c_14; |
---|
85 | |
---|
86 | static Expr _c_15; |
---|
87 | |
---|
88 | static Expr _c_16; |
---|
89 | |
---|
90 | static Expr _c_17; |
---|
91 | |
---|
92 | static Expr _c_18; |
---|
93 | |
---|
94 | static Expr _c_19; |
---|
95 | |
---|
96 | static Expr _c_20; |
---|
97 | |
---|
98 | static Expr _c_21; |
---|
99 | |
---|
100 | RF_FUNC (Stream, (RF_ARG _vs_func, _ve_args;;), (RF_RES _v_res1;;)) |
---|
101 | { |
---|
102 | { |
---|
103 | if (!RF_CALL (Class::Func_q_, _vs_func, /*void*/)) |
---|
104 | { |
---|
105 | goto _negation1; |
---|
106 | } |
---|
107 | goto _block1__branch1; |
---|
108 | } |
---|
109 | _negation1: {} |
---|
110 | RF_CALL (Error::Lib_m_Error, (_c_0, _c_1), /*void*/); |
---|
111 | RF_FUNC_ERROR (unexpected_fail); |
---|
112 | } |
---|
113 | _block1__branch1: {} |
---|
114 | RF_TAILCALL (Box::Box, (_c_2 + (_vs_func + _ve_args) ()), _v_res1); |
---|
115 | RF_END |
---|
116 | |
---|
117 | RF_FUNC (Read_m_Expr, (RF_ARG _vs_box;;), (RF_RES _v_res1;;)) |
---|
118 | Expr _v__q_1; |
---|
119 | RF_CALL (Box::_q_, _vs_box, _v__q_1); |
---|
120 | uintptr_t _v_len1 = _v__q_1.get_len (); |
---|
121 | uintptr_t _v_len2 = 0; |
---|
122 | if (((_v_len1 < (_v_len2 + (1 * 1))))) |
---|
123 | { |
---|
124 | RF_RETFAIL; |
---|
125 | } |
---|
126 | if (((_v_len1 - _v_len2) % 1)) |
---|
127 | { |
---|
128 | RF_RETFAIL; |
---|
129 | } |
---|
130 | uintptr_t _v_len__expr = ((_v_len1 - _v_len2) / 1); |
---|
131 | Expr _vv_expr (_v__q_1, 0, _v_len__expr); |
---|
132 | RF_CALL (Box::Store, (_vs_box, empty), /*void*/); |
---|
133 | _v_res1 = _vv_expr; |
---|
134 | RF_END |
---|
135 | |
---|
136 | RF_FUNC (Expr_m_Open, (RF_ARG _ve_xpr;;), (RF_RES _v_res1;;)) |
---|
137 | Expr _vs_box; |
---|
138 | RF_CALL (Box::Box, _ve_xpr, _vs_box); |
---|
139 | RF_TAILCALL (Stream, (_c_3, _vs_box), _v_res1); |
---|
140 | RF_END |
---|
141 | |
---|
142 | RF_FUNC (File_m_Open, (RF_ARG _ve_filename;;), (RF_RES _v_res1;;)) |
---|
143 | Expr _vs_channel; |
---|
144 | RF_CALL (StdIO::Channel, /*void*/, _vs_channel); |
---|
145 | if (!RF_CALL (StdIO::Prim_m_Open_m_File, (_vs_channel, _ve_filename, _c_4), /*void*/)) |
---|
146 | { |
---|
147 | RF_FUNC_ERROR (unexpected_fail); |
---|
148 | } |
---|
149 | RF_TAILCALL (Stream, (_c_5, (_vs_channel + StdIO::Read_m_Chunk_m_Size)), _v_res1); |
---|
150 | RF_END |
---|
151 | |
---|
152 | RF_FUNC (File_m_Close, (RF_ARG _vs_tream;;), RF_VOID) |
---|
153 | { |
---|
154 | { |
---|
155 | Expr _v__q_1; |
---|
156 | RF_CALL (Box::_q_, _vs_tream, _v__q_1); |
---|
157 | if ((_v__q_1.get_len () != 2)) |
---|
158 | { |
---|
159 | goto _block1__branch1; |
---|
160 | } |
---|
161 | if (_v__q_1.symbol_at (0)) |
---|
162 | { |
---|
163 | goto _block1__branch1; |
---|
164 | } |
---|
165 | if (_v__q_1.symbol_at (1)) |
---|
166 | { |
---|
167 | goto _block1__branch1; |
---|
168 | } |
---|
169 | Expr _v_deref___q_1 (_v__q_1, 0); |
---|
170 | Expr _v_deref___q_12 (_v__q_1, 1); |
---|
171 | uintptr_t _v_len1 = _v_deref___q_12.get_len (); |
---|
172 | uintptr_t _v_len2 = 1; |
---|
173 | if ((_v_len1 < _v_len2)) |
---|
174 | { |
---|
175 | goto _block1__branch1; |
---|
176 | } |
---|
177 | uintptr_t _v_len__args = (_v_len1 - _v_len2); |
---|
178 | uintptr_t _v_len3 = _v_deref___q_1.get_len (); |
---|
179 | uintptr_t _v_len4 = 0; |
---|
180 | if ((_v_len3 < _v_len4)) |
---|
181 | { |
---|
182 | goto _block1__branch1; |
---|
183 | } |
---|
184 | uintptr_t _v_len__buf = (_v_len3 - _v_len4); |
---|
185 | if (!_v_deref___q_12.symbol_at (0)) |
---|
186 | { |
---|
187 | goto _block1__branch1; |
---|
188 | } |
---|
189 | Expr _ve_buf (_v_deref___q_1, 0, _v_len__buf); |
---|
190 | Expr _vs_func (_v_deref___q_12, 0, 1); |
---|
191 | Expr _ve_args (_v_deref___q_12, 1, _v_len__args); |
---|
192 | { |
---|
193 | { |
---|
194 | uintptr_t _v_len5 = _v_len__args; |
---|
195 | uintptr_t _v_len6 = 1; |
---|
196 | if ((_v_len5 < _v_len6)) |
---|
197 | { |
---|
198 | goto _block2__branch1; |
---|
199 | } |
---|
200 | uintptr_t _v_len__rest = (_v_len5 - _v_len6); |
---|
201 | if (!_ve_args.symbol_at (0)) |
---|
202 | { |
---|
203 | goto _block2__branch1; |
---|
204 | } |
---|
205 | Expr _vs_ch (_ve_args, 0, 1); |
---|
206 | Expr _ve_rest (_ve_args, 1, _v_len__rest); |
---|
207 | if (!RF_CALL (Class::Channel_q_, _vs_ch, /*void*/)) |
---|
208 | { |
---|
209 | goto _block2__branch1; |
---|
210 | } |
---|
211 | RF_TAILCALL (StdIO::Prim_m_Close_m_Channel, _vs_ch, /*void*/); |
---|
212 | goto _block2; |
---|
213 | } |
---|
214 | _block2__branch1: {} |
---|
215 | RF_CALL (Error::Lib_m_Error, (_c_6, _c_7), /*void*/); |
---|
216 | RF_FUNC_ERROR (unexpected_fail); |
---|
217 | } |
---|
218 | _block2: {} |
---|
219 | goto _block1; |
---|
220 | } |
---|
221 | _block1__branch1: {} |
---|
222 | RF_CALL (Error::Lib_m_Error, (_c_6, _c_8), /*void*/); |
---|
223 | RF_FUNC_ERROR (unexpected_fail); |
---|
224 | } |
---|
225 | _block1: {} |
---|
226 | RF_END |
---|
227 | |
---|
228 | RF_FUNC (StdIStream, RF_VOID, (RF_RES _v_res1;;)) |
---|
229 | { |
---|
230 | { |
---|
231 | Expr _v__q_1; |
---|
232 | RF_CALL (Box::_q_, StdIStream_m_Box, _v__q_1); |
---|
233 | if ((_v__q_1.get_len () != 1)) |
---|
234 | { |
---|
235 | goto _block1__branch1; |
---|
236 | } |
---|
237 | if (!_v__q_1.symbol_at (0)) |
---|
238 | { |
---|
239 | goto _block1__branch1; |
---|
240 | } |
---|
241 | Expr _vs_tream (_v__q_1, 0, 1); |
---|
242 | _v_res1 = _vs_tream; |
---|
243 | goto _block1; |
---|
244 | } |
---|
245 | _block1__branch1: {} |
---|
246 | Expr _vs_tream; |
---|
247 | RF_CALL (Stream, (_c_5, _c_9), _vs_tream); |
---|
248 | RF_CALL (Box::Store, (StdIStream_m_Box, _vs_tream), /*void*/); |
---|
249 | _v_res1 = _vs_tream; |
---|
250 | } |
---|
251 | _block1: {} |
---|
252 | RF_END |
---|
253 | |
---|
254 | RF_FUNC (Getc, (RF_ARG _vs_tream;;), (RF_RES _v_res1;;)) |
---|
255 | Expr _v_Gets1; |
---|
256 | if (!RF_CALL (Gets, (_vs_tream, _c_10), _v_Gets1)) |
---|
257 | { |
---|
258 | RF_RETFAIL; |
---|
259 | } |
---|
260 | if ((_v_Gets1.get_len () != 1)) |
---|
261 | { |
---|
262 | RF_RETFAIL; |
---|
263 | } |
---|
264 | Expr _vt_erm (_v_Gets1, 0, 1); |
---|
265 | _v_res1 = _vt_erm; |
---|
266 | RF_END |
---|
267 | |
---|
268 | RF_FUNC (Gets, (RF_ARG _vs_tream, _vs_n;;), (RF_RES _v_res1;;)) |
---|
269 | { |
---|
270 | { |
---|
271 | Expr _v__q_1; |
---|
272 | RF_CALL (Box::_q_, _vs_tream, _v__q_1); |
---|
273 | if ((_v__q_1.get_len () != (1 + 1))) |
---|
274 | { |
---|
275 | goto _block1__branch1; |
---|
276 | } |
---|
277 | if (_v__q_1.symbol_at (0)) |
---|
278 | { |
---|
279 | goto _block1__branch1; |
---|
280 | } |
---|
281 | if (_v__q_1.symbol_at ((0 + 1))) |
---|
282 | { |
---|
283 | goto _block1__branch1; |
---|
284 | } |
---|
285 | Expr _v_deref___q_1 (_v__q_1, 0); |
---|
286 | Expr _v_deref___q_12 (_v__q_1, (0 + 1)); |
---|
287 | uintptr_t _v_len1 = _v_deref___q_12.get_len (); |
---|
288 | uintptr_t _v_len2 = 1; |
---|
289 | if (((_v_len1 < (_v_len2 + (0 * 1))))) |
---|
290 | { |
---|
291 | goto _block1__branch1; |
---|
292 | } |
---|
293 | if (((_v_len1 - _v_len2) % 1)) |
---|
294 | { |
---|
295 | goto _block1__branch1; |
---|
296 | } |
---|
297 | uintptr_t _v_len__args = ((_v_len1 - _v_len2) / 1); |
---|
298 | uintptr_t _v_len3 = _v_deref___q_1.get_len (); |
---|
299 | uintptr_t _v_len4 = 0; |
---|
300 | if (((_v_len3 < (_v_len4 + (0 * 1))))) |
---|
301 | { |
---|
302 | goto _block1__branch1; |
---|
303 | } |
---|
304 | if (((_v_len3 - _v_len4) % 1)) |
---|
305 | { |
---|
306 | goto _block1__branch1; |
---|
307 | } |
---|
308 | uintptr_t _v_len__buf = ((_v_len3 - _v_len4) / 1); |
---|
309 | if (!_v_deref___q_12.symbol_at (0)) |
---|
310 | { |
---|
311 | goto _block1__branch1; |
---|
312 | } |
---|
313 | Expr _ve_buf (_v_deref___q_1, 0, _v_len__buf); |
---|
314 | Expr _vs_func (_v_deref___q_12, 0, 1); |
---|
315 | Expr _ve_args (_v_deref___q_12, (0 + 1), _v_len__args); |
---|
316 | for ( ; ; ) |
---|
317 | { |
---|
318 | { |
---|
319 | Expr _v_Length1; |
---|
320 | RF_CALL (Access::Length, _ve_buf, _v_Length1); |
---|
321 | if (!RF_CALL (Compare::_gt__eq_, (_v_Length1, _vs_n), /*void*/)) |
---|
322 | { |
---|
323 | goto _iter1; |
---|
324 | } |
---|
325 | Expr _v_Middle1; |
---|
326 | if (!RF_CALL (Access::Middle, (_vs_n, _c_11, _ve_buf), _v_Middle1)) |
---|
327 | { |
---|
328 | RF_RETFAIL; |
---|
329 | } |
---|
330 | RF_CALL (Box::Store, (_vs_tream, (_v_Middle1 () + (_vs_func + _ve_args) ())), /*void*/); |
---|
331 | RF_TAILCALL (Access::Left, (_c_11, _vs_n, _ve_buf), _v_res1); |
---|
332 | goto _exit__iter1; |
---|
333 | } |
---|
334 | _iter1: {} |
---|
335 | { |
---|
336 | { |
---|
337 | Expr _v_Apply1; |
---|
338 | if (!RF_CALL (Apply::Apply, (_vs_func, _ve_args), _v_Apply1)) |
---|
339 | { |
---|
340 | goto _block2__branch1; |
---|
341 | } |
---|
342 | _ve_buf = (_ve_buf + _v_Apply1); |
---|
343 | goto _block2; |
---|
344 | } |
---|
345 | _block2__branch1: {} |
---|
346 | RF_CALL (Box::Store, (_vs_tream, (_ve_buf () + (_vs_func + _ve_args) ())), /*void*/); |
---|
347 | RF_RETFAIL; |
---|
348 | } |
---|
349 | _block2: {} |
---|
350 | } |
---|
351 | _exit__iter1: {} |
---|
352 | goto _block1; |
---|
353 | } |
---|
354 | _block1__branch1: {} |
---|
355 | RF_CALL (Error::Lib_m_Error, (_c_12, _c_8), /*void*/); |
---|
356 | RF_RETFAIL; |
---|
357 | } |
---|
358 | _block1: {} |
---|
359 | RF_END |
---|
360 | |
---|
361 | RF_FUNC (Ungets, (RF_ARG _vs_tream, _ve_xpr;;), RF_VOID) |
---|
362 | { |
---|
363 | { |
---|
364 | Expr _v__q_1; |
---|
365 | RF_CALL (Box::_q_, _vs_tream, _v__q_1); |
---|
366 | if ((_v__q_1.get_len () != 2)) |
---|
367 | { |
---|
368 | goto _block1__branch1; |
---|
369 | } |
---|
370 | if (_v__q_1.symbol_at (0)) |
---|
371 | { |
---|
372 | goto _block1__branch1; |
---|
373 | } |
---|
374 | if (_v__q_1.symbol_at (1)) |
---|
375 | { |
---|
376 | goto _block1__branch1; |
---|
377 | } |
---|
378 | Expr _v_deref___q_1 (_v__q_1, 0); |
---|
379 | Expr _v_deref___q_12 (_v__q_1, 1); |
---|
380 | uintptr_t _v_len1 = _v_deref___q_12.get_len (); |
---|
381 | uintptr_t _v_len2 = 1; |
---|
382 | if ((_v_len1 < _v_len2)) |
---|
383 | { |
---|
384 | goto _block1__branch1; |
---|
385 | } |
---|
386 | uintptr_t _v_len__args = (_v_len1 - _v_len2); |
---|
387 | uintptr_t _v_len3 = _v_deref___q_1.get_len (); |
---|
388 | uintptr_t _v_len4 = 0; |
---|
389 | if ((_v_len3 < _v_len4)) |
---|
390 | { |
---|
391 | goto _block1__branch1; |
---|
392 | } |
---|
393 | uintptr_t _v_len__buf = (_v_len3 - _v_len4); |
---|
394 | if (!_v_deref___q_12.symbol_at (0)) |
---|
395 | { |
---|
396 | goto _block1__branch1; |
---|
397 | } |
---|
398 | Expr _ve_buf (_v_deref___q_1, 0, _v_len__buf); |
---|
399 | Expr _vs_func (_v_deref___q_12, 0, 1); |
---|
400 | Expr _ve_args (_v_deref___q_12, 1, _v_len__args); |
---|
401 | RF_TAILCALL (Box::Store, (_vs_tream, ((_ve_xpr + _ve_buf) () + (_vs_func + _ve_args) ())), /*void*/); |
---|
402 | goto _block1; |
---|
403 | } |
---|
404 | _block1__branch1: {} |
---|
405 | RF_CALL (Error::Lib_m_Error, (_c_13, _c_8), /*void*/); |
---|
406 | RF_FUNC_ERROR (unexpected_fail); |
---|
407 | } |
---|
408 | _block1: {} |
---|
409 | RF_END |
---|
410 | |
---|
411 | RF_FUNC (Scanc, (RF_ARG _vs_tream, _vt_1;;), (RF_RES _v_res1;;)) |
---|
412 | { |
---|
413 | { |
---|
414 | Expr _v_Getc1; |
---|
415 | if (!RF_CALL (Getc, _vs_tream, _v_Getc1)) |
---|
416 | { |
---|
417 | goto _block1__branch1; |
---|
418 | } |
---|
419 | { |
---|
420 | { |
---|
421 | if (!_vt_1.term_eq (_v_Getc1, 0)) |
---|
422 | { |
---|
423 | goto _block2__branch1; |
---|
424 | } |
---|
425 | _v_res1 = _vt_1; |
---|
426 | goto _block2; |
---|
427 | } |
---|
428 | _block2__branch1: {} |
---|
429 | Expr _vt_2 (_v_Getc1, 0, 1); |
---|
430 | RF_CALL (Ungets, (_vs_tream, _vt_2), /*void*/); |
---|
431 | _v_res1 = empty; |
---|
432 | } |
---|
433 | _block2: {} |
---|
434 | goto _block1; |
---|
435 | } |
---|
436 | _block1__branch1: {} |
---|
437 | _v_res1 = empty; |
---|
438 | } |
---|
439 | _block1: {} |
---|
440 | RF_END |
---|
441 | |
---|
442 | RF_FUNC (Get_m_Delim, (RF_ARG _vs_tream, _vt_delim;;), (RF_RES _v_res1;;)) |
---|
443 | { |
---|
444 | { |
---|
445 | Expr _v__q_1; |
---|
446 | RF_CALL (Box::_q_, _vs_tream, _v__q_1); |
---|
447 | if ((_v__q_1.get_len () != 2)) |
---|
448 | { |
---|
449 | goto _block1__branch1; |
---|
450 | } |
---|
451 | if (_v__q_1.symbol_at (0)) |
---|
452 | { |
---|
453 | goto _block1__branch1; |
---|
454 | } |
---|
455 | if (_v__q_1.symbol_at (1)) |
---|
456 | { |
---|
457 | goto _block1__branch1; |
---|
458 | } |
---|
459 | Expr _v_deref___q_1 (_v__q_1, 0); |
---|
460 | Expr _v_deref___q_12 (_v__q_1, 1); |
---|
461 | uintptr_t _v_len1 = _v_deref___q_12.get_len (); |
---|
462 | uintptr_t _v_len2 = 1; |
---|
463 | if ((_v_len1 < _v_len2)) |
---|
464 | { |
---|
465 | goto _block1__branch1; |
---|
466 | } |
---|
467 | uintptr_t _v_len__args = (_v_len1 - _v_len2); |
---|
468 | uintptr_t _v_len3 = _v_deref___q_1.get_len (); |
---|
469 | uintptr_t _v_len4 = 0; |
---|
470 | if ((_v_len3 < _v_len4)) |
---|
471 | { |
---|
472 | goto _block1__branch1; |
---|
473 | } |
---|
474 | uintptr_t _v_len__buf = (_v_len3 - _v_len4); |
---|
475 | if (!_v_deref___q_12.symbol_at (0)) |
---|
476 | { |
---|
477 | goto _block1__branch1; |
---|
478 | } |
---|
479 | Expr _ve_buf (_v_deref___q_1, 0, _v_len__buf); |
---|
480 | Expr _vs_func (_v_deref___q_12, 0, 1); |
---|
481 | Expr _ve_args (_v_deref___q_12, 1, _v_len__args); |
---|
482 | Expr _ve_str (empty); |
---|
483 | Expr _ve_stop_q_ (empty); |
---|
484 | for ( ; ; ) |
---|
485 | { |
---|
486 | { |
---|
487 | if ((_ve_stop_q_.get_len () != 1)) |
---|
488 | { |
---|
489 | goto _iter1; |
---|
490 | } |
---|
491 | if (!_c_14.term_eq (_ve_stop_q_, 0)) |
---|
492 | { |
---|
493 | goto _iter1; |
---|
494 | } |
---|
495 | RF_CALL (Box::Store, (_vs_tream, (_ve_buf () + (_vs_func + _ve_args) ())), /*void*/); |
---|
496 | _v_res1 = _ve_str; |
---|
497 | goto _exit__iter1; |
---|
498 | } |
---|
499 | _iter1: {} |
---|
500 | { |
---|
501 | { |
---|
502 | if ((_ve_buf.get_len () < 1)) |
---|
503 | { |
---|
504 | goto _block2__branch1; |
---|
505 | } |
---|
506 | RF_lsplit (_ve_buf, 0, _ve_1, _v_lsplit__buf); |
---|
507 | for ( ; ; RF_iter(_ve_buf)++) |
---|
508 | { |
---|
509 | { |
---|
510 | if (!RF_iter(_ve_buf)) |
---|
511 | { |
---|
512 | goto _block2__branch1; |
---|
513 | } |
---|
514 | uintptr_t _v_len5 = _v_lsplit__buf.get_len (); |
---|
515 | uintptr_t _v_len6 = 1; |
---|
516 | if ((_v_len5 < _v_len6)) |
---|
517 | { |
---|
518 | goto _block2__branch1; |
---|
519 | } |
---|
520 | uintptr_t _v_len__2 = (_v_len5 - _v_len6); |
---|
521 | if (!_vt_delim.term_eq (_v_lsplit__buf, 0)) |
---|
522 | { |
---|
523 | goto _continue1; |
---|
524 | } |
---|
525 | Expr _ve_2 (_v_lsplit__buf, 1, _v_len__2); |
---|
526 | _ve_str = (_ve_str + _ve_1 + _vt_delim); |
---|
527 | _ve_buf = _ve_2; |
---|
528 | _ve_stop_q_ = _c_14; |
---|
529 | goto _exit1; |
---|
530 | } |
---|
531 | _continue1: {} |
---|
532 | } |
---|
533 | _exit1: {} |
---|
534 | goto _block2; |
---|
535 | } |
---|
536 | _block2__branch1: {} |
---|
537 | { |
---|
538 | Expr _v_Apply1; |
---|
539 | if (!RF_CALL (Apply::Apply, (_vs_func, _ve_args), _v_Apply1)) |
---|
540 | { |
---|
541 | goto _block2__branch2; |
---|
542 | } |
---|
543 | _ve_str = (_ve_str + _ve_buf); |
---|
544 | _ve_buf = _v_Apply1; |
---|
545 | _ve_stop_q_ = empty; |
---|
546 | goto _block2; |
---|
547 | } |
---|
548 | _block2__branch2: {} |
---|
549 | _ve_str = (_ve_str + _ve_buf); |
---|
550 | _ve_buf = empty; |
---|
551 | _ve_stop_q_ = _c_14; |
---|
552 | } |
---|
553 | _block2: {} |
---|
554 | } |
---|
555 | _exit__iter1: {} |
---|
556 | goto _block1; |
---|
557 | } |
---|
558 | _block1__branch1: {} |
---|
559 | RF_CALL (Error::Lib_m_Error, (_c_15, _c_8), /*void*/); |
---|
560 | RF_FUNC_ERROR (unexpected_fail); |
---|
561 | } |
---|
562 | _block1: {} |
---|
563 | RF_END |
---|
564 | |
---|
565 | RF_FUNC (Not_m_EOL, (RF_ARG _vt_1;;), RF_VOID) |
---|
566 | { |
---|
567 | { |
---|
568 | { |
---|
569 | if ((1 != 1)) |
---|
570 | { |
---|
571 | goto _block1__branch1; |
---|
572 | } |
---|
573 | if (!_vt_1.term_eq (_c_16, 0)) |
---|
574 | { |
---|
575 | goto _block1__branch1; |
---|
576 | } |
---|
577 | goto _block1; |
---|
578 | } |
---|
579 | _block1__branch1: {} |
---|
580 | if ((1 != 1)) |
---|
581 | { |
---|
582 | goto _negation1; |
---|
583 | } |
---|
584 | if (!_vt_1.term_eq (_c_17, 0)) |
---|
585 | { |
---|
586 | goto _negation1; |
---|
587 | } |
---|
588 | } |
---|
589 | _block1: {} |
---|
590 | RF_RETFAIL; |
---|
591 | } |
---|
592 | _negation1: {} |
---|
593 | RF_END |
---|
594 | |
---|
595 | RF_FUNC (Get_m_Line, (RF_ARG _vs_tream;;), (RF_RES _v_res1;;)) |
---|
596 | Expr _v_Get_m_While1; |
---|
597 | RF_CALL (Get_m_While, (_vs_tream, _c_18), _v_Get_m_While1); |
---|
598 | Expr _v_Scanc1; |
---|
599 | RF_CALL (Scanc, (_vs_tream, _c_17), _v_Scanc1); |
---|
600 | Expr _v_Scanc2; |
---|
601 | RF_CALL (Scanc, (_vs_tream, _c_16), _v_Scanc2); |
---|
602 | _v_res1 = (_v_Get_m_While1 + _v_Scanc1 + _v_Scanc2); |
---|
603 | RF_END |
---|
604 | |
---|
605 | RF_FUNC (Get_m_While, (RF_ARG _vs_tream, _vs_pred;;), (RF_RES _v_res1;;)) |
---|
606 | { |
---|
607 | { |
---|
608 | Expr _v__q_1; |
---|
609 | RF_CALL (Box::_q_, _vs_tream, _v__q_1); |
---|
610 | if ((_v__q_1.get_len () != 2)) |
---|
611 | { |
---|
612 | goto _block1__branch1; |
---|
613 | } |
---|
614 | if (_v__q_1.symbol_at (0)) |
---|
615 | { |
---|
616 | goto _block1__branch1; |
---|
617 | } |
---|
618 | if (_v__q_1.symbol_at (1)) |
---|
619 | { |
---|
620 | goto _block1__branch1; |
---|
621 | } |
---|
622 | Expr _v_deref___q_1 (_v__q_1, 0); |
---|
623 | Expr _v_deref___q_12 (_v__q_1, 1); |
---|
624 | uintptr_t _v_len1 = _v_deref___q_12.get_len (); |
---|
625 | uintptr_t _v_len2 = 1; |
---|
626 | if ((_v_len1 < _v_len2)) |
---|
627 | { |
---|
628 | goto _block1__branch1; |
---|
629 | } |
---|
630 | uintptr_t _v_len__args = (_v_len1 - _v_len2); |
---|
631 | uintptr_t _v_len3 = _v_deref___q_1.get_len (); |
---|
632 | uintptr_t _v_len4 = 0; |
---|
633 | if ((_v_len3 < _v_len4)) |
---|
634 | { |
---|
635 | goto _block1__branch1; |
---|
636 | } |
---|
637 | uintptr_t _v_len__buf = (_v_len3 - _v_len4); |
---|
638 | if (!_v_deref___q_12.symbol_at (0)) |
---|
639 | { |
---|
640 | goto _block1__branch1; |
---|
641 | } |
---|
642 | Expr _ve_buf (_v_deref___q_1, 0, _v_len__buf); |
---|
643 | Expr _vs_func (_v_deref___q_12, 0, 1); |
---|
644 | Expr _ve_args (_v_deref___q_12, 1, _v_len__args); |
---|
645 | Expr _ve_str (empty); |
---|
646 | Expr _ve_stop_q_ (empty); |
---|
647 | for ( ; ; ) |
---|
648 | { |
---|
649 | { |
---|
650 | if ((_ve_stop_q_.get_len () != 1)) |
---|
651 | { |
---|
652 | goto _iter1; |
---|
653 | } |
---|
654 | if (!_c_14.term_eq (_ve_stop_q_, 0)) |
---|
655 | { |
---|
656 | goto _iter1; |
---|
657 | } |
---|
658 | RF_CALL (Box::Store, (_vs_tream, (_ve_buf () + (_vs_func + _ve_args) ())), /*void*/); |
---|
659 | _v_res1 = _ve_str; |
---|
660 | goto _exit__iter1; |
---|
661 | } |
---|
662 | _iter1: {} |
---|
663 | { |
---|
664 | { |
---|
665 | uintptr_t _v_len5 = _ve_buf.get_len (); |
---|
666 | uintptr_t _v_len6 = 1; |
---|
667 | if ((_v_len5 < _v_len6)) |
---|
668 | { |
---|
669 | goto _block2__branch1; |
---|
670 | } |
---|
671 | uintptr_t _v_len__2 = (_v_len5 - _v_len6); |
---|
672 | Expr _vt_1 (_ve_buf, 0, 1); |
---|
673 | Expr _ve_2 (_ve_buf, 1, _v_len__2); |
---|
674 | { |
---|
675 | { |
---|
676 | Expr _v_Apply1; |
---|
677 | if (!RF_CALL (Apply::Apply, (_vs_pred, _vt_1), _v_Apply1)) |
---|
678 | { |
---|
679 | goto _block3__branch1; |
---|
680 | } |
---|
681 | uintptr_t _v_len7 = _v_Apply1.get_len (); |
---|
682 | uintptr_t _v_len8 = 0; |
---|
683 | if ((_v_len7 < _v_len8)) |
---|
684 | { |
---|
685 | goto _block3__branch1; |
---|
686 | } |
---|
687 | uintptr_t _v_len___e__e_tmp_m_Streamrf_m_134_m_30 = (_v_len7 - _v_len8); |
---|
688 | Expr _ve__e__e_tmp_m_Streamrf_m_134_m_30 (_v_Apply1, 0, _v_len___e__e_tmp_m_Streamrf_m_134_m_30); |
---|
689 | _ve_str = (_ve_str + _vt_1); |
---|
690 | _ve_buf = _ve_2; |
---|
691 | _ve_stop_q_ = empty; |
---|
692 | goto _block3; |
---|
693 | } |
---|
694 | _block3__branch1: {} |
---|
695 | _ve_stop_q_ = _c_14; |
---|
696 | } |
---|
697 | _block3: {} |
---|
698 | goto _block2; |
---|
699 | } |
---|
700 | _block2__branch1: {} |
---|
701 | { |
---|
702 | if (!RF_CALL (Apply::Apply, (_vs_func, _ve_args), _ve_buf)) |
---|
703 | { |
---|
704 | goto _block2__branch2; |
---|
705 | } |
---|
706 | _ve_stop_q_ = empty; |
---|
707 | goto _block2; |
---|
708 | } |
---|
709 | _block2__branch2: {} |
---|
710 | _ve_stop_q_ = _c_14; |
---|
711 | } |
---|
712 | _block2: {} |
---|
713 | } |
---|
714 | _exit__iter1: {} |
---|
715 | goto _block1; |
---|
716 | } |
---|
717 | _block1__branch1: {} |
---|
718 | RF_CALL (Error::Lib_m_Error, (_c_19, _c_8), /*void*/); |
---|
719 | RF_FUNC_ERROR (unexpected_fail); |
---|
720 | } |
---|
721 | _block1: {} |
---|
722 | RF_END |
---|
723 | |
---|
724 | RF_FUNC (End_m_of_m_Stream_q_, (RF_ARG _vs_tream;;), RF_VOID) |
---|
725 | { |
---|
726 | { |
---|
727 | Expr _v__q_1; |
---|
728 | RF_CALL (Box::_q_, _vs_tream, _v__q_1); |
---|
729 | if ((_v__q_1.get_len () != (1 + 1))) |
---|
730 | { |
---|
731 | goto _block1__branch1; |
---|
732 | } |
---|
733 | if (_v__q_1.symbol_at (0)) |
---|
734 | { |
---|
735 | goto _block1__branch1; |
---|
736 | } |
---|
737 | if (_v__q_1.symbol_at ((0 + 1))) |
---|
738 | { |
---|
739 | goto _block1__branch1; |
---|
740 | } |
---|
741 | Expr _v_deref___q_1 (_v__q_1, 0); |
---|
742 | Expr _v_deref___q_12 (_v__q_1, (0 + 1)); |
---|
743 | uintptr_t _v_len1 = _v_deref___q_12.get_len (); |
---|
744 | uintptr_t _v_len2 = 1; |
---|
745 | if (((_v_len1 < (_v_len2 + (0 * 1))))) |
---|
746 | { |
---|
747 | goto _block1__branch1; |
---|
748 | } |
---|
749 | if (((_v_len1 - _v_len2) % 1)) |
---|
750 | { |
---|
751 | goto _block1__branch1; |
---|
752 | } |
---|
753 | uintptr_t _v_len__args = ((_v_len1 - _v_len2) / 1); |
---|
754 | uintptr_t _v_len3 = _v_deref___q_1.get_len (); |
---|
755 | uintptr_t _v_len4 = 0; |
---|
756 | if (((_v_len3 < (_v_len4 + (0 * 1))))) |
---|
757 | { |
---|
758 | goto _block1__branch1; |
---|
759 | } |
---|
760 | if (((_v_len3 - _v_len4) % 1)) |
---|
761 | { |
---|
762 | goto _block1__branch1; |
---|
763 | } |
---|
764 | uintptr_t _v_len__buf = ((_v_len3 - _v_len4) / 1); |
---|
765 | if (!_v_deref___q_12.symbol_at (0)) |
---|
766 | { |
---|
767 | goto _block1__branch1; |
---|
768 | } |
---|
769 | Expr _ve_buf (_v_deref___q_1, 0, _v_len__buf); |
---|
770 | Expr _vs_func (_v_deref___q_12, 0, 1); |
---|
771 | Expr _ve_args (_v_deref___q_12, (0 + 1), _v_len__args); |
---|
772 | { |
---|
773 | { |
---|
774 | Expr _v_buf__1 (_ve_buf); |
---|
775 | for ( ; ; ) |
---|
776 | { |
---|
777 | { |
---|
778 | uintptr_t _v_len5 = _v_buf__1.get_len (); |
---|
779 | uintptr_t _v_len6 = 0; |
---|
780 | if (((_v_len5 < (_v_len6 + (1 * 1))))) |
---|
781 | { |
---|
782 | goto _iter1; |
---|
783 | } |
---|
784 | if (((_v_len5 - _v_len6) % 1)) |
---|
785 | { |
---|
786 | goto _iter1; |
---|
787 | } |
---|
788 | uintptr_t _v_len___e__e_tmp_m_Streamrf_m_155_m_18 = ((_v_len5 - _v_len6) / 1); |
---|
789 | Expr _vv__e__e_tmp_m_Streamrf_m_155_m_18 (_v_buf__1, 0, _v_len___e__e_tmp_m_Streamrf_m_155_m_18); |
---|
790 | RF_CALL (Box::Store, (_vs_tream, (_v_buf__1 () + (_vs_func + _ve_args) ())), /*void*/); |
---|
791 | RF_RETFAIL; |
---|
792 | goto _exit__iter1; |
---|
793 | } |
---|
794 | _iter1: {} |
---|
795 | if (!RF_CALL (Apply::Apply, (_vs_func, _ve_args), _v_buf__1)) |
---|
796 | { |
---|
797 | goto _block2__branch1; |
---|
798 | } |
---|
799 | } |
---|
800 | _exit__iter1: {} |
---|
801 | goto _block2; |
---|
802 | } |
---|
803 | _block2__branch1: {} |
---|
804 | } |
---|
805 | _block2: {} |
---|
806 | goto _block1; |
---|
807 | } |
---|
808 | _block1__branch1: {} |
---|
809 | RF_CALL (Error::Lib_m_Error, (_c_20, _c_8), /*void*/); |
---|
810 | RF_RETFAIL; |
---|
811 | } |
---|
812 | _block1: {} |
---|
813 | RF_END |
---|
814 | |
---|
815 | RF_FUNC (Prim_m_Read__0, (RF_ARG _v_arg1;;), (RF_RES _v_res1;;)) |
---|
816 | if ((_v_arg1.get_len () != (1 + 1))) |
---|
817 | { |
---|
818 | RF_ERROR (_c_21); |
---|
819 | } |
---|
820 | if (!_v_arg1.symbol_at (0)) |
---|
821 | { |
---|
822 | RF_ERROR (_c_21); |
---|
823 | } |
---|
824 | if (!_v_arg1.symbol_at ((0 + 1))) |
---|
825 | { |
---|
826 | RF_ERROR (_c_21); |
---|
827 | } |
---|
828 | Expr _v_stub1 (_v_arg1, 0, 1); |
---|
829 | Expr _v_stub2 (_v_arg1, (0 + 1), 1); |
---|
830 | RF_TAILCALL (StdIO::Prim_m_Read, (_v_stub1, _v_stub2), _v_res1); |
---|
831 | RF_END |
---|
832 | |
---|
833 | RF_FUNC (Read_m_Expr__0, (RF_ARG _v_arg1;;), (RF_RES _v_res1;;)) |
---|
834 | if ((_v_arg1.get_len () != 1)) |
---|
835 | { |
---|
836 | RF_ERROR (_c_21); |
---|
837 | } |
---|
838 | if (!_v_arg1.symbol_at (0)) |
---|
839 | { |
---|
840 | RF_ERROR (_c_21); |
---|
841 | } |
---|
842 | Expr _v_stub1 (_v_arg1, 0, 1); |
---|
843 | if (!RF_CALL (Read_m_Expr, _v_stub1, _v_res1)) |
---|
844 | { |
---|
845 | RF_RETFAIL; |
---|
846 | } |
---|
847 | RF_END |
---|
848 | |
---|
849 | RF_FUNC (Not_m_EOL__0, (RF_ARG _v_arg1;;), (RF_RES _v_res1;;)) |
---|
850 | if ((_v_arg1.get_len () != 1)) |
---|
851 | { |
---|
852 | RF_ERROR (_c_21); |
---|
853 | } |
---|
854 | Expr _v_stub1 (_v_arg1, 0, 1); |
---|
855 | if (!RF_CALL (Not_m_EOL, _v_stub1, /*void*/)) |
---|
856 | { |
---|
857 | RF_RETFAIL; |
---|
858 | } |
---|
859 | _v_res1 = empty; |
---|
860 | RF_END |
---|
861 | |
---|
862 | } |
---|
863 | |
---|
864 | namespace StdIO { extern AtStart init_StdIn; } |
---|
865 | |
---|
866 | namespace Stream |
---|
867 | { |
---|
868 | |
---|
869 | static void init_ () |
---|
870 | { |
---|
871 | StdIO::init_StdIn.invoke(); |
---|
872 | StdIStream_m_Box = Expr::create_sym< rftype::NamedObject<rftype::BoxContents> >(L"StdIStream-Box"); |
---|
873 | _c_0 = Expr::create<Word>("Stream") + Expr::create<Word>("Stream"); |
---|
874 | _c_1 = Expr::create<Word>("Arg 1 is not a Function"); |
---|
875 | _c_2 = (empty) (); |
---|
876 | _c_3 = Expr::create_sym<Func> (Read_m_Expr__0); |
---|
877 | _c_4 = Expr::create<Word>("R"); |
---|
878 | _c_5 = Expr::create_sym<Func> (Prim_m_Read__0); |
---|
879 | _c_6 = Expr::create<Word>("Stream") + Expr::create<Word>("File-Close"); |
---|
880 | _c_7 = Expr::create<Word>("Arg 1 is not a Streamed File"); |
---|
881 | _c_8 = Expr::create<Word>("Arg 1 is not a Stream"); |
---|
882 | _c_9 = StdIO::StdIn + Expr::create<Integer>("1"); |
---|
883 | _c_10 = Expr (_c_9, 1, 1); |
---|
884 | _c_11 = Expr::create<Integer>("0"); |
---|
885 | _c_12 = Expr::create<Word>("Stream") + Expr::create<Word>("Gets"); |
---|
886 | _c_13 = Expr::create<Word>("Stream") + Expr::create<Word>("Ungets"); |
---|
887 | _c_14 = Expr::create<Word>("Stop"); |
---|
888 | _c_15 = Expr::create<Word>("Stream") + Expr::create<Word>("Get-Delim"); |
---|
889 | _c_16 = Char::create_expr (L"\n"); |
---|
890 | _c_17 = Char::create_expr (L"\r"); |
---|
891 | _c_18 = Expr::create_sym<Func> (Not_m_EOL__0); |
---|
892 | _c_19 = Expr::create<Word>("Stream") + Expr::create<Word>("Get-While"); |
---|
893 | _c_20 = Expr::create<Word>("Stream") + Expr::create<Word>("End-of-Stream?"); |
---|
894 | _c_21 = Expr::create<Word>("Apply") + Expr::create<Word>("Apply") + Expr::create<Word>("Unexpected fail"); |
---|
895 | } |
---|
896 | |
---|
897 | static AtStart init_registrator_ (&init_); |
---|
898 | |
---|
899 | } |
---|
900 | |
---|
901 | } |
---|