touchups
parent
b689315686
commit
e0ab0660f6
@ -1,26 +0,0 @@
|
||||
#lang br
|
||||
(provide (rename-out [bf-module-begin #%module-begin])
|
||||
#%top-interaction bf-program op loop)
|
||||
|
||||
(define #'bf-module-begin #'#%module-begin)
|
||||
|
||||
(define #'(bf-program <op-or-loop> ...)
|
||||
#'(begin <op-or-loop> ...))
|
||||
|
||||
(define-cases #'op
|
||||
[#'(_ ">") #'(move-pointer 1)]
|
||||
[#'(_ "<") #'(move-pointer -1)]
|
||||
[#'(_ "+") #'(set-pointer-byte! (add1 (get-pointer-byte)))]
|
||||
[#'(_ "-") #'(set-pointer-byte! (sub1 (get-pointer-byte)))]
|
||||
[#'(_ ".") #'(write-byte (get-pointer-byte))]
|
||||
[#'(_ ",") #'(set-pointer-byte! (read-byte))])
|
||||
|
||||
(define #'(loop "[" <op-or-loop> ... "]")
|
||||
#'(until (zero? (get-pointer-byte))
|
||||
<op-or-loop> ...))
|
||||
|
||||
(define bf-vector (make-vector 1000 0))
|
||||
(define bf-pointer 0)
|
||||
(define (get-pointer-byte) (vector-ref bf-vector bf-pointer))
|
||||
(define (set-pointer-byte! val) (vector-set! bf-vector bf-pointer val))
|
||||
(define (move-pointer how-far) (set! bf-pointer (+ bf-pointer how-far)))
|
@ -1,12 +0,0 @@
|
||||
#lang br-bf
|
||||
+++++++++++
|
||||
>+>>>>++++++++++++++++++++++++++++++++++++++++++++
|
||||
>++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+>
|
||||
+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[-
|
||||
<-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<<
|
||||
-]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]
|
||||
>[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++
|
||||
+++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++
|
||||
++++++++++++++++++++++++++++++++++++++++++++.[-]<<
|
||||
<<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<
|
||||
[-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]
|
@ -1,4 +0,0 @@
|
||||
#lang racket
|
||||
(require "tokenizer.rkt" "parser.rkt" ragg/support)
|
||||
|
||||
(syntax->datum (parse (tokenize (open-input-string "[+-]>"))))
|
@ -1,10 +0,0 @@
|
||||
#lang ragg
|
||||
|
||||
<expr> : ">"
|
||||
| "<"
|
||||
| "+"
|
||||
| "-"
|
||||
| "."
|
||||
| ","
|
||||
| <loop>
|
||||
<loop> : "["<expr>*"]"
|
Loading…
Reference in New Issue