-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
gen_ed.ppr
89 lines (75 loc) · 2.25 KB
/
gen_ed.ppr
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
__, Copyright 2012-2019 Dustin DeWeese
| This file is part of PoprC.
|
| PoprC is free software: you can redistribute it and/or modify
| it under the terms of the GNU General Public License as published by
| the Free Software Foundation, either version 3 of the License, or
| (at your option) any later version.
|
| PoprC is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with PoprC. If not, see <http://www.gnu.org/licenses/>.
|______________________________________________________________________
module gen_ed:
imports:
module list
module stack
module control
module num
module logic
module algorithm
module io
dupu: [dup] dip12
__ a [fn] [test]
iterate_linear:
swap [dup [ap12 swap2 drop] dip22] dip23 swap __ a' bool [fn] [test]
[[dup [$] dip21] dip22 iterate_linear] ap20 __ a' bool [[fn] $ [fn] [test] iterate_linear]
[] ifte $
il_test: [3+] [dup 10<] iterate_linear
do_linear: [$keep] dip22 iterate_linear
dl_test: [3+] [dup 10<] do_linear
dl_test2: [] pushl [[3+].] [[dup 10<]. popr] do_linear head
__ {hide}
dl_test3:
[""] ap20
[[[read] dip23 swap].]
[[dup [++] dip21 "" =s not]. popr]
do_linear get3
__ breaks for s/iterate/do/
count_lines:
[0] ap20 __ IO h cnt
[[[getline drop] dip22 1+].]
[[[is_eof] dip23 swap not]. popr]
iterate_linear get3
count_lines_test:
getline_std "in:" swap ++
open count_lines [close] dip21
->str write_std
sum_lines:
[0] ap20 __ IO h cnt
[[[getline <-str] dip23 +].]
[[[is_eof] dip23 swap not]. popr]
iterate_linear get3
sum_lines_test:
getline_std "in:" swap ++
open sum_lines [close] dip21
->str write_std
read_list:
[[]] ap20 __ IO h cnt
[[[getline] dip23 pushl].]
[[[is_eof] dip23 swap not]. popr]
iterate_linear get3
write_list:
[] ap30
[[pull [write "\n" write] dip32].]
[[dup head valid]. popr]
iterate_linear tail get2
__ IO in_stream out_stream
reverse_list:
[read_list reverse] dip23
exch2 [write_list] dip32
swap