DrBrainf-ck/main.rkt

62 lines
1.9 KiB
Racket
Raw Normal View History

2018-11-21 14:27:15 +00:00
;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-intermediate-lambda-reader.ss" "lang")((modname main) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
; 2018-11-21 - Made by Claudio Maggioni - Tommaso Rodolfo Masera
; easybf
; A Byte is an Int between 0 and 255
; Interpretation: a byte in decimal notation.
; A Tape is a NEList<Byte>
; Interpretation: a tape in brainf*ck's Turing machine.
; A DataPointer (DP) is a NonNegInt
; Interpretation: a data pointer in the brainf*ck language in a tape.
2018-11-21 14:27:15 +00:00
; A Program is a String of:
; - ">"
; - "<"
; - "+"
; - "-"
; - "."
; - ","
; - "["
; - "]"
; Interpretation: the brainf*ck program.
; A InstructionPointer (IP) is a NonNegInt
; Interpretation: a pointer to the instruction to execute.
; A World is a (make-world tape dp output program ip) where:
; - tape: Tape
; - dp: DataPointer
; - output: String
; - program: Program
; - ip: InstructionPointer
; Interpretation: the current state of execution of a brainf*ck program.
(define-struct world [tape dp output program ip])
; Template function for World
(define (fn-for-world w)
(... (world-tape w)
(world-dp w)
(world-output w)
(world-program w)
(world-ip w)))
; read-file: FileName -> String
; Given a filename, parses it and returns the content as a string.
(define (read-file fl)
...)
2018-11-21 14:27:15 +00:00
; TODO:
; - read-file: FileName -> String
; - string->program: String -> Program (filter of valid instructions)
; - program->world: Program -> World (compute initial world state)
; - big-bang:
; - - - - - - inital state (make-world (list 0) 0 "" <program> 0)
; - - - - - - on-tick fetch, decode, execute
; - - - - - - on-key for ","
; - - - - - - (on-mouse for stepper)
; - - - - - - (draw-scene for output and tape)