Last active
August 29, 2015 14:18
-
-
Save JRHeaton/355e142ffc94eb966ce9 to your computer and use it in GitHub Desktop.
Brainfuck parser + interpreter in Swift 1.2 made w/ @danzimm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Madness | |
import Prelude | |
struct Brainfuck { | |
class State { | |
var bytes = ContiguousArray<UInt8>(count: 30_000, repeatedValue: 0) | |
var pointer: UInt16 = 0 | |
var deref: UInt8 { | |
get { | |
return bytes[Int(pointer)] | |
} | |
set { | |
bytes[Int(pointer)] = newValue | |
} | |
} | |
} | |
enum Command: Printable { | |
case IncPtr | |
case DecPtr | |
case IncAtPtr | |
case DecAtPtr | |
case Putc | |
case Getc | |
case Loop([Command]) | |
static func fromCharacter(char: Character) -> Command? { | |
switch char { | |
case "<": return .DecPtr | |
case ">": return .IncPtr | |
case "+": return .IncAtPtr | |
case "-": return .DecAtPtr | |
case ".": return .Putc | |
case ",": return .Getc | |
default: return nil | |
} | |
} | |
var description: String { | |
switch self { | |
case .IncPtr: return ">" | |
case .DecPtr: return "<" | |
case .IncAtPtr: return "+" | |
case .DecAtPtr: return "-" | |
case .Putc: return "." | |
case .Getc: return "," | |
case .Loop(let commands): | |
return toString(commands) | |
} | |
} | |
func evaluate(state: State) { | |
switch self { | |
case .Loop(let commands): | |
if state.deref != 0 { | |
map(commands, ~Command.evaluate <| state) | |
evaluate(state) | |
} | |
case .IncPtr: | |
if state.pointer < UInt16.max { | |
state.pointer++ | |
} | |
case .DecPtr: | |
if state.pointer != 0 { | |
state.pointer-- | |
} | |
case .IncAtPtr: | |
if state.deref < UInt8.max { | |
state.deref++ | |
} | |
case .DecAtPtr: | |
if state.deref != 0 { | |
state.deref-- | |
} | |
case .Putc: | |
print(Character(UnicodeScalar(state.deref))) | |
default: () | |
} | |
} | |
} | |
} | |
func satisfy(test: String -> Bool) -> Parser<String, String>.Function { | |
return { input, index in | |
if index < input.endIndex { | |
let str = String(input[index]) | |
if test(str) { | |
return (str, index.successor()) | |
} else { | |
return nil | |
} | |
} else { | |
return nil | |
} | |
} | |
} | |
let parser = fix { (commands: Parser<String, Brainfuck.Command>.Function) in | |
// Command characters (separated due to swiftc expression complexity limitations) | |
let commandCharacters = [">", "<", "+", "-", ",", "."] | |
let cmds = reduce(commandCharacters, Prelude.const(nil)) { (acc: Parser<String, String>.Function, str: String) in | |
return acc | %(str) | |
} | |
// Delimiters: whitespace, newline | |
let delim = ignore((%" " | %"\n" | satisfy({ (c: String) in !contains(commandCharacters + ["[", "]"], c) }))*) | |
let singleCharCommand = cmds | |
--> first | |
->> ~flatMap <|% Brainfuck.Command.fromCharacter | |
->> unsafeUnwrap | |
let loop = (ignore("[") ++ commands ++ ignore("]")) | |
return (delim ++ (singleCharCommand | loop) ++ delim)* --> { Brainfuck.Command.Loop($0) } | |
} --> { (topCommand: Brainfuck.Command) -> [Brainfuck.Command] in | |
switch topCommand { | |
case .Loop(let program): | |
return program | |
default: return [] | |
} | |
} | |
let program: String = NSString(contentsOfFile: NSBundle.mainBundle().pathForResource("hw", ofType: "brainfuck")!, encoding: 4, error: nil) as! String | |
let p = parse(parser, program)! | |
// println(parser(program, program.startIndex)) | |
let state = Brainfuck.State() | |
map(p, { $0.evaluate(state) }) | |
/* | |
Input: | |
A mandelbrot set fractal viewer in brainf*** written by Erik Bosman | |
+++++++++++++[->++>>>+++++>++>+<<<<<<]>>>>>++++++>--->>>>>>>>>>+++++++++++++++[[ | |
>>>>>>>>>]+[<<<<<<<<<]>>>>>>>>>-]+[>>>>>>>>[-]>]<<<<<<<<<[<<<<<<<<<]>>>>>>>>[-]+ | |
<<<<<<<+++++[-[->>>>>>>>>+<<<<<<<<<]>>>>>>>>>]>>>>>>>+>>>>>>>>>>>>>>>>>>>>>>>>>> | |
>+<<<<<<<<<<<<<<<<<[<<<<<<<<<]>>>[-]+[>>>>>>[>>>>>>>[-]>>]<<<<<<<<<[<<<<<<<<<]>> | |
>>>>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