diff --git a/beautiful-racket/br/demo/basic/expander.rkt b/beautiful-racket/br/demo/basic/expander.rkt index 77dbcd7..36fce71 100644 --- a/beautiful-racket/br/demo/basic/expander.rkt +++ b/beautiful-racket/br/demo/basic/expander.rkt @@ -20,7 +20,7 @@ #'(basic-run CR-LINE ...)) (define (basic-run . lines) - (define program-lines (list->vector lines)) + (define program-lines (list->vector (filter (λ(ln) (not (equal? ln "cr"))) lines))) (void (for/fold ([line-idx 0]) ([i (in-naturals)] #:break (= line-idx (vector-length program-lines))) @@ -34,8 +34,8 @@ idx))) (add1 line-idx))))) -(define #'(cr-line "cr" ARG ...) - #'(begin ARG ...)) +(define-cases #'cr-line + [#'(_ ARG ...) #'(begin ARG ...)]) (define #'(line NUMBER STATEMENT ...) #'(cons NUMBER (λ _ STATEMENT ...))) diff --git a/beautiful-racket/br/demo/basic/parser.rkt b/beautiful-racket/br/demo/basic/parser.rkt index 63138ff..e73ffce 100644 --- a/beautiful-racket/br/demo/basic/parser.rkt +++ b/beautiful-racket/br/demo/basic/parser.rkt @@ -1,8 +1,6 @@ #lang ragg -basic-program : cr-line* [CR] - -cr-line : CR line [cr-line] +basic-program : line [CR line]* line: INTEGER statement+ @@ -16,13 +14,13 @@ statement : "END" | "PRINT" print-list | REM-COMMENT -print-list : [expr [";" [print-list]*]] +print-list : [expr [";" [print-list]]] -expr : sum [("=" | "<>" | "><" | ">" | ">=" | "<" | "<=") expr] +expr : sum [("=" | ">" | "<" | "<>") expr] -sum : product [("+" | "-") sum]+ +sum : product [("+" | "-") sum] -product : value [("*" | "/") product]+ +product : value [("*" | "/") product] value : "(" expr ")" | ID ["(" expr* ")"] diff --git a/beautiful-racket/br/demo/basic/reader.rkt b/beautiful-racket/br/demo/basic/reader.rkt index c936ec3..699e020 100644 --- a/beautiful-racket/br/demo/basic/reader.rkt +++ b/beautiful-racket/br/demo/basic/reader.rkt @@ -4,4 +4,4 @@ (define-read-and-read-syntax (source-path input-port) (strip-context #`(module bf-mod br/demo/basic/expander - #,(parse source-path (tokenize input-port))))) + #,(parse source-path (tokenize (open-input-string (string-trim (port->string input-port)))))))) diff --git a/beautiful-racket/br/demo/basic/sinewave.bas b/beautiful-racket/br/demo/basic/sinewave.bas index 2eb140e..4ba83c7 100644 --- a/beautiful-racket/br/demo/basic/sinewave.bas +++ b/beautiful-racket/br/demo/basic/sinewave.bas @@ -1,18 +1,8 @@ #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 \ No newline at end of file + + +10 PRINT 2 + 3 * 10 + 1 + +20 PRINT 6 * 7 / 8 + +