prelim jumping
This commit is contained in:
parent
d6baa0508e
commit
9ceef60254
|
@ -17,7 +17,7 @@
|
||||||
(procedure-rename (λ xs (cons 'id xs)) (format-datum "undefined:~a" 'id))))
|
(procedure-rename (λ xs (cons 'id xs)) (format-datum "undefined:~a" 'id))))
|
||||||
|
|
||||||
(define #'(basic-program CR-LINE ...)
|
(define #'(basic-program CR-LINE ...)
|
||||||
#'(begin CR-LINE ...))
|
#'(basic-run CR-LINE ...))
|
||||||
|
|
||||||
(define (basic-run . lines)
|
(define (basic-run . lines)
|
||||||
(define program-lines (list->vector lines))
|
(define program-lines (list->vector lines))
|
||||||
|
@ -34,23 +34,23 @@
|
||||||
idx)))
|
idx)))
|
||||||
(add1 line-idx)))))
|
(add1 line-idx)))))
|
||||||
|
|
||||||
(define-cases #'cr-line ; erases "cr"s
|
(define #'(cr-line "cr" ARG ...)
|
||||||
[#'(_ "cr" LINE) #'LINE]
|
#'(begin ARG ...))
|
||||||
[#'(_ "cr") #'(begin)])
|
|
||||||
|
|
||||||
(define #'(line NUMBER STATEMENT ...)
|
(define #'(line NUMBER STATEMENT ...)
|
||||||
#'(begin STATEMENT ...))
|
#'(cons NUMBER (λ _ STATEMENT ...)))
|
||||||
|
|
||||||
|
|
||||||
|
(define vars (make-hasheq))
|
||||||
|
|
||||||
(define-cases #'statement
|
(define-cases #'statement
|
||||||
[#'(statement ID "=" EXPR) (if (identifier-binding #'ID)
|
[#'(statement ID "=" EXPR) #'(hash-set! vars 'ID EXPR)]
|
||||||
#'(set! ID EXPR)
|
|
||||||
#'(define ID EXPR))]
|
|
||||||
[#'(statement PROC ARG ...) #'(PROC ARG ...)])
|
[#'(statement PROC ARG ...) #'(PROC ARG ...)])
|
||||||
|
|
||||||
(define-cases #'value
|
(define-cases #'value
|
||||||
[#'(value "(" EXPR ")") #'EXPR]
|
[#'(value "(" EXPR ")") #'EXPR]
|
||||||
[#'(value ID "(" ARG ... ")") #'(ID ARG ...)]
|
[#'(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)
|
(define #'(expr EXPR) #'EXPR)
|
||||||
|
|
||||||
|
@ -77,4 +77,7 @@
|
||||||
(define (INT num) (inexact->exact (round num)))
|
(define (INT num) (inexact->exact (round num)))
|
||||||
(define (SIN num) (sin num))
|
(define (SIN num) (sin num))
|
||||||
|
|
||||||
|
(define (GOTO where)
|
||||||
|
where)
|
||||||
|
|
||||||
(define (comment . args) void)
|
(define (comment . args) void)
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
#lang br/demo/basic
|
#lang br/demo/basic
|
||||||
10 PRINT TAB(30);"SINE WAVE"
|
10 PRINT TAB(30);"SINE WAVE"
|
||||||
20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
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…
Reference in New Issue
Block a user