Skip to content

Commit 90d0fd5

Browse files
now we can properly have ENDPROC instead of RETPROC
1 parent b9dbb18 commit 90d0fd5

File tree

12 files changed

+162
-163
lines changed

12 files changed

+162
-163
lines changed

include/basic/flow_control.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ void def_statement(struct basic_ctx* ctx);
2424
void proc_statement(struct basic_ctx* ctx);
2525

2626
/**
27-
* @brief Handles the RETPROC statement in BASIC, used for returning from a procedure.
27+
* @brief Handles the ENDPROC statement in BASIC, used for returning from a procedure.
2828
*
29-
* The RETPROC statement is used to return control from a procedure to the calling location.
29+
* The ENDPROC statement is used to return control from a procedure to the calling location.
3030
*
3131
* @param ctx The current BASIC program context.
3232
*/
33-
void retproc_statement(struct basic_ctx* ctx);
33+
void endproc_statement(struct basic_ctx* ctx);
3434

3535
/**
3636
* @brief Begins parsing a function's comma-separated parameter list.

include/basic/tokenizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
T(EOF) \
8181
T(DEF) \
8282
T(PROC) \
83-
T(RETPROC) \
83+
T(ENDPROC) \
8484
T(FN) \
8585
T(END) \
8686
T(REM) \

os/programs/dir.rrbasic

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ DEF PROCreport
3131
IF DIR$ = "" THEN DIR$ = CSD$
3232
COLOR 7
3333
PRINT N; " items in " + DIR$
34-
RETPROC
34+
ENDPROC

os/programs/edit.rrbasic

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ END
1818
REM clear line from cursor to right
1919
DEF PROCclearLineFromCursor
2020
PRINT CHR$(27) + "[0K";
21-
RETPROC
21+
ENDPROC
2222

2323
REM draw UI around editor window
2424
DEF PROCdraw
@@ -37,7 +37,7 @@ DEF PROCdraw
3737
COLOUR 7
3838
BACKGROUND 0
3939
CURSOR 1, 2
40-
RETPROC
40+
ENDPROC
4141

4242
REM Display prompt in bottom section of screen
4343
DEF PROCprompt(prompt$)
@@ -48,23 +48,23 @@ DEF PROCprompt(prompt$)
4848
PROCclearLineFromCursor
4949
CURSOR 2, TERMHEIGHT
5050
PRINT prompt$; ": ";
51-
RETPROC
51+
ENDPROC
5252

5353
REM clear prompt
5454
DEF PROCendPrompt
5555
CLS
5656
PROCtext
57-
RETPROC
57+
ENDPROC
5858

5959
REM hide text cursor
6060
DEF PROChideCursor
6161
PRINT CHR$(27);"[?25l";
62-
RETPROC
62+
ENDPROC
6363

6464
REM show text cursor
6565
DEF PROCshowCursor
6666
PRINT CHR$(27);"[?25h";
67-
RETPROC
67+
ENDPROC
6868

6969
REM display text to editor window
7070
DEF PROCtext
@@ -76,11 +76,11 @@ DEF PROCtext
7676
IF l < max THEN PRINT LEFT$(content$(l), TERMWIDTH)
7777
NEXT
7878
PROCshowCursor
79-
RETPROC
79+
ENDPROC
8080

8181
REM load a file into the array, translating TAB to four spaces
8282
DEF PROCload(file$)
83-
IF file$ = "" THEN RETPROC
83+
IF file$ = "" THEN ENDPROC
8484
FH = OPENIN(file$)
8585
IF FH < 0 THEN PROCfail
8686
lines = 0
@@ -97,19 +97,19 @@ DEF PROCload(file$)
9797
IF lines = max THEN PROCgrow
9898
UNTIL EOF(FH) = 1
9999
CLOSE FH
100-
RETPROC
100+
ENDPROC
101101

102102
REM increase array used to store text
103103
DEF PROCgrow
104104
max = max + 100
105105
REDIM content$, max
106-
RETPROC
106+
ENDPROC
107107

108108
REM error handler
109109
DEF PROCfail
110110
PRINT "Could not open file: "; ARGS$
111111
END
112-
RETPROC
112+
ENDPROC
113113

114114
REM handle editor input loop
115115
DEF PROCedit
@@ -118,14 +118,14 @@ DEF PROCedit
118118
KGET key$
119119
PROCprocessKey(ASC(key$))
120120
UNTIL FALSE
121-
RETPROC
121+
ENDPROC
122122

123123
REM handle keypress
124124
DEF PROCprocessKey(in)
125125
incopy = in
126126
ctrl = CTRLKEY
127127
IF ctrl = TRUE THEN PROCctrl(CHR$(incopy))
128-
IF ctrl = TRUE THEN RETPROC
128+
IF ctrl = TRUE THEN ENDPROC
129129
IF in = 27 THEN PROCquit
130130
IF in = 13 THEN PROCenter
131131
IF in = 250 THEN PROCup
@@ -142,7 +142,7 @@ DEF PROCprocessKey(in)
142142
cx = LEN(content$(top + currenty))
143143
IF currentx > cx THEN currentx = cx
144144
IF (currenty + top) > (lines - 1) THEN currenty = lines - top - 1
145-
RETPROC
145+
ENDPROC
146146

147147
REM insert character at current position and advance right
148148
DEF PROCinsertChar(i)
@@ -152,63 +152,63 @@ DEF PROCinsertChar(i)
152152
currentx = currentx + 1
153153
dirty = TRUE
154154
PROCtext
155-
RETPROC
155+
ENDPROC
156156

157157
REM handle CTRL+key
158158
DEF PROCctrl(ctrlkey$)
159159
IF UPPER$(ctrlkey$) = "S" THEN PROCsave
160160
IF UPPER$(ctrlkey$) = "W" THEN PROCsearch
161161
IF UPPER$(ctrlkey$) = "R" THEN PROCreplace
162162
PROCtext
163-
RETPROC
163+
ENDPROC
164164

165165
REM handle save
166166
DEF PROCsave
167167
IF ARGS$ = "" THEN PROCsaveNew
168-
IF ARGS$ = "" THEN RETPROC
168+
IF ARGS$ = "" THEN ENDPROC
169169
PROCsaveAs
170-
RETPROC
170+
ENDPROC
171171

172172
REM handle save over existing file
173173
DEF PROCsaveAs
174174
PROCprompt("Save as [" + ARGS$ + "]")
175175
INPUT file$
176176
IF file$ = "" THEN file$ = ARGS$
177177
PROCdoSave(file$)
178-
RETPROC
178+
ENDPROC
179179

180180
REM handle save to new file
181181
DEF PROCsaveNew
182182
PROCprompt("Save as")
183183
INPUT file$
184184
PROCdoSave(file$)
185-
RETPROC
185+
ENDPROC
186186

187187
REM save file
188188
DEF PROCdoSave(saveFileName$)
189189
FH = OPENOUT(saveFileName$)
190190
IF FH < 0 THEN PROCsaveError(saveFileName$)
191-
IF FH < 0 THEN RETPROC
191+
IF FH < 0 THEN ENDPROC
192192
REM write file line by line
193193
FOR X = 0 TO lines - 1
194194
WRITE FH, content$(X)
195195
NEXT
196196
CLOSE FH
197197
dirty = FALSE
198-
RETPROC
198+
ENDPROC
199199

200200
REM display save error
201201
DEF PROCsaveError
202202
PROCprompt("Unable to save file! Press any key to continue")
203203
REPEAT
204204
UNTIL INKEY$ > ""
205-
RETPROC
205+
ENDPROC
206206

207207
REM text search
208208
DEF PROCsearch
209209
PROCprompt("Search text")
210210
INPUT find$
211-
RETPROC
211+
ENDPROC
212212

213213
REM search and replace
214214
DEF PROCreplace
@@ -217,96 +217,96 @@ DEF PROCreplace
217217
PROCprompt("Replace text")
218218
INPUT replace$
219219
dirty = TRUE
220-
RETPROC
220+
ENDPROC
221221

222222
REM handle escape key
223223
DEF PROCquit
224224
IF dirty = TRUE THEN PROCconfirm
225-
IF dirty = TRUE THEN RETPROC
225+
IF dirty = TRUE THEN ENDPROC
226226
CLS
227227
END
228-
RETPROC
228+
ENDPROC
229229

230230
REM confirm exit if file contents changed
231231
DEF PROCconfirm
232232
PROCprompt("Contents changed. Are you sure?")
233233
KGET input$
234234
PROCtext
235-
IF UPPER$(input$) = "N" THEN RETPROC
235+
IF UPPER$(input$) = "N" THEN ENDPROC
236236
CLS
237237
END
238-
RETPROC
238+
ENDPROC
239239

240240
REM handle cursor left key
241241
DEF PROCleft
242242
currentx = currentx - 1
243243
IF currentx < 0 THEN currentx = 0
244244
PROCtext
245-
RETPROC
245+
ENDPROC
246246

247247
REM handle cursor up key
248248
DEF PROCup
249249
currenty = currenty - 1
250250
IF currenty < 0 THEN PROCscrollUp
251251
PROCtext
252-
RETPROC
252+
ENDPROC
253253

254254
REM handle cursor down key
255255
DEF PROCdown
256256
currenty = currenty + 1
257257
IF currenty > (TERMHEIGHT - 3) THEN PROCscrollDown
258258
PROCtext
259-
RETPROC
259+
ENDPROC
260260

261261
REM scroll screen down one line
262262
DEF PROCscrollDown
263263
currenty = TERMHEIGHT - 3
264264
top = top + 1
265265
IF top > (TERMHEIGHT - 2 + lines) THEN top = TERMHEIGHT - 2 + lines
266266
PROCtext
267-
RETPROC
267+
ENDPROC
268268

269269
REM Scroll screen up one line
270270
DEF PROCscrollUp
271271
currenty = 0
272272
top = top - 1
273273
IF top < 0 THEN top = 0
274-
RETPROC
274+
ENDPROC
275275

276276
REM handle cursor right key
277277
DEF PROCright
278278
currentx = currentx + 1
279279
IF currentx > (TERMWIDTH - 1) THEN currentx = TERMWIDTH - 1
280280
PROCtext
281-
RETPROC
281+
ENDPROC
282282

283283
REM handle end key
284284
DEF PROCend
285285
currentx = LEN(content$(top + currenty))
286286
IF currentx > (TERMWIDTH - 1) THEN currentx = TERMWIDTH - 1
287287
PROCtext
288-
RETPROC
288+
ENDPROC
289289

290290
REM handle home key
291291
DEF PROChome
292292
currentx = 0
293293
PROCtext
294-
RETPROC
294+
ENDPROC
295295

296296
REM handle page up key
297297
DEF PROCpageUp
298298
top = top - TERMHEIGHT - 2
299299
IF top < 0 THEN top = 0
300300
PROCtext
301-
RETPROC
301+
ENDPROC
302302

303303
REM handle page down key
304304
DEF PROCpageDown
305-
IF (top + currenty + TERMHEIGHT - 2) > (lines - 1) THEN RETPROC
305+
IF (top + currenty + TERMHEIGHT - 2) > (lines - 1) THEN ENDPROC
306306
top = top + TERMHEIGHT - 2
307307
IF top > (TERMHEIGHT - 2 + lines) THEN top = TERMHEIGHT - 2 + lines
308308
PROCtext
309-
RETPROC
309+
ENDPROC
310310

311311
REM handle enter key, split line if neccessary
312312
DEF PROCenter
@@ -324,7 +324,7 @@ DEF PROCenter
324324
IF currenty > (TERMHEIGHT - 3) THEN PROCscrollDown
325325
dirty = TRUE
326326
PROCtext
327-
RETPROC
327+
ENDPROC
328328

329329
REM handle delete key, join line if neccessary
330330
DEF PROCdelete
@@ -334,7 +334,7 @@ DEF PROCdelete
334334
IF currentx < len THEN PROCdeleteRight
335335
dirty = TRUE
336336
PROCtext
337-
RETPROC
337+
ENDPROC
338338

339339
REM handle backspace
340340
DEF PROCbackSpace
@@ -343,40 +343,40 @@ DEF PROCbackSpace
343343
IF cx > 0 THEN PROCdeleteLeft
344344
dirty = TRUE
345345
PROCtext
346-
RETPROC
346+
ENDPROC
347347

348348
REM delete character to left of cursor, advance left
349349
DEF PROCdeleteLeft
350350
start$ = MID$(content$(top + currenty), 0, currentx - 1)
351351
end$ = MID$(content$(top + currenty), currentx, LEN(content$(top + currenty)))
352352
content$(top + currenty) = start$ + end$
353353
currentx = currentx - 1
354-
RETPROC
354+
ENDPROC
355355

356356
REM delete one character to the right
357357
DEF PROCdeleteRight
358358
start$ = MID$(content$(top + currenty), 0, currentx)
359359
end$ = MID$(content$(top + currenty), currentx + 1, LEN(content$(top + currenty)))
360360
content$(top + currenty) = start$ + end$
361-
RETPROC
361+
ENDPROC
362362

363363
REM join the end of the current line to the line below, moving lines up
364364
DEF PROCjoin
365-
IF currenty = (lines - 1) THEN RETPROC
365+
IF currenty = (lines - 1) THEN ENDPROC
366366
content$(top + currenty) = content$(top + currenty) + content$(top + currenty + 1)
367367
POP content$, top + currenty + 1
368368
content$(lines - 1) = ""
369369
lines = lines - 1
370-
RETPROC
370+
ENDPROC
371371

372372
REM join the start of the current line to the line above, moving lines up
373373
DEF PROCjoinAbove
374-
IF currenty = 0 THEN RETPROC
374+
IF currenty = 0 THEN ENDPROC
375375
newcurrentx = LEN(content$(top + currenty - 1))
376376
content$(top + currenty - 1) = content$(top + currenty - 1) + content$(top + currenty)
377377
POP content$, top + currenty
378378
content$(lines - 1) = ""
379379
currentx = newcurrentx
380380
currenty = currenty - 1
381381
lines = lines - 1
382-
RETPROC
382+
ENDPROC

0 commit comments

Comments
 (0)