diff --git a/beautiful-racket-demo/bf-demo/expander-imperative.rkt b/beautiful-racket-demo/bf-demo/expander-imperative.rkt index a2a78c9..050e42c 100644 --- a/beautiful-racket-demo/bf-demo/expander-imperative.rkt +++ b/beautiful-racket-demo/bf-demo/expander-imperative.rkt @@ -9,19 +9,19 @@ #'(void OP-OR-LOOP-ARG ...)) (provide bf-program) -(define-macro (loop "[" OP-OR-LOOP-ARG ... "]") +(define-macro (bf-loop "[" OP-OR-LOOP-ARG ... "]") #'(until (zero? (current-byte)) OP-OR-LOOP-ARG ...)) -(provide loop) +(provide bf-loop) -(define-macro-cases op - [(op ">") #'(gt)] - [(op "<") #'(lt)] - [(op "+") #'(plus)] - [(op "-") #'(minus)] - [(op ".") #'(period)] - [(op ",") #'(comma)]) -(provide op) +(define-macro-cases bf-op + [(bf-op ">") #'(gt)] + [(bf-op "<") #'(lt)] + [(bf-op "+") #'(plus)] + [(bf-op "-") #'(minus)] + [(bf-op ".") #'(period)] + [(bf-op ",") #'(comma)]) +(provide bf-op) (define arr (make-vector 30000 0)) (define ptr 0) diff --git a/beautiful-racket-demo/bf-demo/expander-slow.rkt b/beautiful-racket-demo/bf-demo/expander-slow.rkt index 51e8bd4..57b301d 100644 --- a/beautiful-racket-demo/bf-demo/expander-slow.rkt +++ b/beautiful-racket-demo/bf-demo/expander-slow.rkt @@ -16,23 +16,23 @@ (void (fold-funcs first-apl (list OP-OR-LOOP-ARG ...))))) (provide bf-program) -(define-macro (loop "[" OP-OR-LOOP-ARG ... "]") +(define-macro (bf-loop "[" OP-OR-LOOP-ARG ... "]") #'(lambda (arr ptr) (for/fold ([current-apl (list arr ptr)]) ([i (in-naturals)] #:break (zero? (apply current-byte current-apl))) (fold-funcs current-apl (list OP-OR-LOOP-ARG ...))))) -(provide loop) - -(define-macro-cases op - [(op ">") #'gt] - [(op "<") #'lt] - [(op "+") #'plus] - [(op "-") #'minus] - [(op ".") #'period] - [(op ",") #'comma]) -(provide op) +(provide bf-loop) + +(define-macro-cases bf-op + [(bf-op ">") #'gt] + [(bf-op "<") #'lt] + [(bf-op "+") #'plus] + [(bf-op "-") #'minus] + [(bf-op ".") #'period] + [(bf-op ",") #'comma]) +(provide bf-op) (define (current-byte arr ptr) (vector-ref arr ptr)) diff --git a/beautiful-racket-demo/bf-demo/expander.rkt b/beautiful-racket-demo/bf-demo/expander.rkt index b744172..6054e2e 100644 --- a/beautiful-racket-demo/bf-demo/expander.rkt +++ b/beautiful-racket-demo/bf-demo/expander.rkt @@ -16,23 +16,23 @@ (void (fold-funcs first-apl (list OP-OR-LOOP-ARG ...))))) (provide bf-program) -(define-macro (loop "[" OP-OR-LOOP-ARG ... "]") +(define-macro (bf-loop "[" OP-OR-LOOP-ARG ... "]") #'(lambda (arr ptr) (for/fold ([current-apl (list arr ptr)]) ([i (in-naturals)] #:break (zero? (apply current-byte current-apl))) (fold-funcs current-apl (list OP-OR-LOOP-ARG ...))))) -(provide loop) - -(define-macro-cases op - [(op ">") #'gt] - [(op "<") #'lt] - [(op "+") #'plus] - [(op "-") #'minus] - [(op ".") #'period] - [(op ",") #'comma]) -(provide op) +(provide bf-loop) + +(define-macro-cases bf-op + [(bf-op ">") #'gt] + [(bf-op "<") #'lt] + [(bf-op "+") #'plus] + [(bf-op "-") #'minus] + [(bf-op ".") #'period] + [(bf-op ",") #'comma]) +(provide bf-op) (define (current-byte arr ptr) (vector-ref arr ptr)) diff --git a/beautiful-racket-demo/bf-demo/parser.rkt b/beautiful-racket-demo/bf-demo/parser.rkt index d60349f..8e211e5 100644 --- a/beautiful-racket-demo/bf-demo/parser.rkt +++ b/beautiful-racket-demo/bf-demo/parser.rkt @@ -1,4 +1,4 @@ #lang brag -bf-program : (op | loop)* -op : ">" | "<" | "+" | "-" | "." | "," -loop : "[" (op | loop)* "]" \ No newline at end of file +bf-program : (bf-op | bf-loop)* +bf-op : ">" | "<" | "+" | "-" | "." | "," +bf-loop : "[" (bf-op | bf-loop)* "]" \ No newline at end of file