diff --git a/main.rkt b/main.rkt new file mode 100644 index 0000000..414095f --- /dev/null +++ b/main.rkt @@ -0,0 +1,57 @@ +;; 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 +; Interpretation: a tape in brainf*ck's Turing machine. + +; A DataPointer (DP) is a NonNegInt +; Interpretation: an data pointer in the brainf*ck language in a tape. + +; 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))) + +; 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 "" 0) +; - - - - - - on-tick fetch, decode, execute +; - - - - - - on-key for "," +; - - - - - - (on-mouse for stepper) +; - - - - - - (draw-scene for output and tape) \ No newline at end of file