-
Notifications
You must be signed in to change notification settings - Fork 0
/
cozd.red
280 lines (239 loc) · 7.69 KB
/
cozd.red
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
Red [
title: "Coz"
author: "Abdullah Yiğiterol"
version: 0.4.0
;needs: 'view ;windowsta
]
#include %red-common/search.red
COZ: context [
VERSIYON: "0.4.test8"
DEGISKEN: [
["z"]
["coz"]
]
ORTAC: []
DURAK: []
SONBELLEK: []
SATIR: 0
LIMIT: 5
]
BLOK_AYIR: function [blok [block!] /local b] [
b: copy blok
either (length? b) > 0 [
forall b [if not last? b [b: next b insert b '|]]
return b
][
return false
]
]
SIRA_BUL: function [a [block!] i] [
return (length? a) - (length? find a i) + 1
]
SONBELLEKLE: function[d] [
insert coz/sonbellek d
if (length? coz/sonbellek) > (coz/limit) [
coz/sonbellek: reverse (remove reverse coz/sonbellek)
]
]
_SATIR: [
[newline | end | "^M" | "^/"] (
coz/SATIR: coz/SATIR + 1
)
]
_harf: complement charset {"}
_metin: [any _harf]
_dizgi: [
copy c_m [{"} thru {"}] (
SONBELLEKLE (do c_m) ;append
if (length? coz/durak) > 0 [
durak_: copy coz/durak/1
clear coz/durak
tara reverse remove (reverse(remove mold coz/degisken/2/(SIRA_BUL coz/degisken/1 durak_)))
durak_: copy ""
]
)
]
_harf: complement charset {"[]}
_fume: ["[" any [_harf | {"} thru {"} | _fume] "]"]
_kume: [
copy c_k [
"["
any [
_fume
;"[" any [ _harf | {"} thru {"} | "[" any [_harf | {"} thru {"} | "[" thru "]"] "]"] "]"
| [{"} thru {"}]
| _harf
]
"]"
] (
kume_: copy do c_k
insert/only coz/sonbellek kume_
if (length? coz/sonbellek) > (coz/limit) [
coz/sonbellek: reverse (remove reverse coz/sonbellek)
]
if (length? coz/durak) > 0 [
durak_: copy coz/durak/1
clear coz/durak
tara reverse remove (reverse(remove mold coz/degisken/2/(SIRA_BUL coz/degisken/1 durak_)))
durak_: copy ""
]
)
]
_SAYI19: charset "123456789"
_SAYI09: charset "0123456789"
_SAYI: [
copy c_s [["0" | _SAYI19 any _SAYI09] "." any _SAYI09 | "0" | [_SAYI19 any _SAYI09]] (
SONBELLEKLE to float! c_s
if (length? coz/durak) > 0 [
durak_: copy coz/durak/1
clear coz/durak
tara reverse remove (reverse(remove mold coz/degisken/2/(SIRA_BUL coz/degisken/1 durak_)))
durak_: copy ""
]
)
]
_bosluk: [some space]
_olsun: ["olsun" (
either find coz/degisken/1 coz/sonbellek/2 [
degisken_uzunluk: length? coz/degisken/1
degisken_sira: degisken_uzunluk - ((length? find coz/degisken/1 coz/sonbellek/2) - 1)
coz/degisken/2/(degisken_sira): coz/sonbellek/1
][
either (length? coz/degisken/1) < 2 [ ;false
either (length? coz/degisken/1) = 0 [
insert/only coz/degisken/1 coz/sonbellek/2
insert/only coz/degisken/2 coz/sonbellek/1
][
either (length? coz/sonbellek/2) > (length? coz/degisken/1/1)[
insert/only coz/degisken/1 coz/sonbellek/2
insert/only coz/degisken/2 coz/sonbellek/1
][
append/only coz/degisken/1 coz/sonbellek/2
append/only coz/degisken/2 coz/sonbellek/1
]
]
][
set [i1: len1: i2: len2:]
search/for i: 1 length? coz/degisken/1 [length? coz/degisken/1/:i] length? coz/sonbellek/2
insert/only at coz/degisken/1 i2 coz/sonbellek/2
insert/only at coz/degisken/2 i2 coz/sonbellek/1
;coz/degisken/1: copy coz/degisken/1
;coz/degisken/2: copy coz/degisken/2
comment {
yeni_degisken_uzunluk: length? coz/sonbellek/2
yeni_sira: 0
yeni_degisken: copy [
[]
[]
]
eklenmedi: true
foreach i coz/degisken/1 [
either (length? i) > yeni_degisken_uzunluk [
append yeni_degisken/1 i
append yeni_degisken/2 coz/degisken/2/(SIRA_BUL yeni_degisken/1 i)
][
either eklenmedi [
append yeni_degisken/1 coz/sonbellek/2
append yeni_degisken/2 coz/sonbellek/1
][
append yeni_degisken/1 i
append yeni_degisken/2 coz/degisken/2/(SIRA_BUL yeni_degisken/1 i)
]
eklenmedi: false
]
]
probe yeni_degisken
coz/degisken: copy yeni_degisken
}
]
]
)]
_degisken: [
(_AYRI_DEGISKEN: BLOK_AYIR coz/degisken/1)
copy c_a _AYRI_DEGISKEN
(
either (type? coz/degisken/2/(SIRA_BUL coz/degisken/1 c_a)) = block! [
either find coz/ortac c_a [
;either find coz/durak c_a [
; tara reverse remove (reverse(remove mold coz/degisken/2/(SIRA_BUL coz/degisken/1 c_a)))
; clear coz/durak
;][
insert coz/durak c_a
;]
][
tara reverse remove (reverse(remove mold coz/degisken/2/(SIRA_BUL coz/degisken/1 c_a)))
]
][
SONBELLEKLE coz/degisken/2/(SIRA_BUL coz/degisken/1 c_a)
if (length? coz/durak) > 0 [
durak_: copy coz/durak/1
clear coz/durak
tara reverse remove (reverse(remove mold coz/degisken/2/(SIRA_BUL coz/degisken/1 durak_)))
durak_: copy ""
]
]
)
]
_ilintile: [
"ilintile" (
ilinti_: coz/sonbellek/1
remove coz/sonbellek
do ilinti_
)
]
_ata: ["ata" (
either find coz/degisken/1 coz/sonbellek/2 [
degisken_uzunluk: length? coz/degisken/1
degisken_sira: degisken_uzunluk - ((length? find coz/degisken/1 coz/sonbellek/2) - 1)
coz/degisken/2/(degisken_sira): coz/sonbellek/1
][
either (length? coz/degisken/1) < 2 [ ;false
either (length? coz/degisken/1) = 0 [
insert/only coz/degisken/1 coz/sonbellek/2
insert/only coz/degisken/2 coz/sonbellek/1
][
either (length? coz/sonbellek/2) > (length? coz/degisken/1/1)[
insert/only coz/degisken/1 coz/sonbellek/2
insert/only coz/degisken/2 coz/sonbellek/1
][
append/only coz/degisken/1 coz/sonbellek/2
append/only coz/degisken/2 coz/sonbellek/1
]
]
][
set [i1: len1: i2: len2:]
search/for i: 1 length? coz/degisken/1 [length? coz/degisken/1/:i] length? coz/sonbellek/2
insert/only at coz/degisken/1 i2 coz/sonbellek/1
insert/only at coz/degisken/2 i2 coz/sonbellek/2
]
]
)]
tara: function[t [string!]][
parse t [
any [
_SATIR
| _kume
| _olsun
| _ata
| _dizgi
| _SAYI
| _ilintile
| _degisken
| _bosluk
| "kapat" (quit)
| "!" (coz/sonbellek: copy reverse (remove reverse coz/sonbellek))
| skip
]
]
]
tara read %coz.coz
either system/options/args/1 [
dosya: read/lines rejoin[%./ system/options/args/1]
foreach d dosya [
tara d
]
][
prin " Coz " print coz/versiyon print "^[[0;34m 2018-2023" print ""
coz/SATIR: 0
print "dosya ismi yazın"
]