prelim jumping

dev-elider-3
Matthew Butterick 9 years ago
parent d6baa0508e
commit 9ceef60254

@ -17,7 +17,7 @@
(procedure-rename (λ xs (cons 'id xs)) (format-datum "undefined:~a" 'id))))
(define #'(basic-program CR-LINE ...)
#'(begin CR-LINE ...))
#'(basic-run CR-LINE ...))
(define (basic-run . lines)
(define program-lines (list->vector lines))
@ -34,23 +34,23 @@
idx)))
(add1 line-idx)))))
(define-cases #'cr-line ; erases "cr"s
[#'(_ "cr" LINE) #'LINE]
[#'(_ "cr") #'(begin)])
(define #'(cr-line "cr" ARG ...)
#'(begin ARG ...))
(define #'(line NUMBER STATEMENT ...)
#'(begin STATEMENT ...))
#'(cons NUMBER (λ _ STATEMENT ...)))
(define vars (make-hasheq))
(define-cases #'statement
[#'(statement ID "=" EXPR) (if (identifier-binding #'ID)
#'(set! ID EXPR)
#'(define ID EXPR))]
[#'(statement ID "=" EXPR) #'(hash-set! vars 'ID EXPR)]
[#'(statement PROC ARG ...) #'(PROC ARG ...)])
(define-cases #'value
[#'(value "(" EXPR ")") #'EXPR]
[#'(value ID "(" ARG ... ")") #'(ID ARG ...)]
[#'(value DATUM) #'DATUM])
[#'(value ID-OR-DATUM) #'(hash-ref vars 'ID-OR-DATUM (λ _ ID-OR-DATUM))])
(define #'(expr EXPR) #'EXPR)
@ -77,4 +77,7 @@
(define (INT num) (inexact->exact (round num)))
(define (SIN num) (sin num))
(define (GOTO where)
where)
(define (comment . args) void)

@ -1,3 +1,18 @@
#lang br/demo/basic
10 PRINT TAB(30);"SINE WAVE"
20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
30 PRINT: PRINT: PRINT: PRINT: PRINT
40 REMARKABLE PROGRAM BY DAVID AHL
50 B=0
100 REM START LONG LOOP
110 FOR T=0 TO 40 STEP .25
120 A=INT(26+25*SIN(T))
130 PRINT TAB(A);
140 IF B=1 THEN 180
150 PRINT "CREATIVE"
160 B=1
170 GOTO 200
180 PRINT "COMPUTING"
190 B=0
200 NEXT T
999 END
Loading…
Cancel
Save