hbf-0.1.0.0: An optimizing Brainfuck compiler and evaluator

Copyright(c) Sebastian Galkin 2018
LicenseGPL-3
Safe HaskellNone
LanguageHaskell2010

HBF.Eval

Description

Functions to evaluate a compiled Brainfuck program.

Synopsis

Documentation

type MachineType = Machine (Vector Int8) Source #

An alias for a Machine in which memory is an unboxed vector of bytes.

eval :: (PrimMonad m, MachineIO m) => Program Optimized -> m MachineType Source #

Evaluate the given program returning the end state of the Machine. The evaluation can happen in any PrimMonad for which we can do I/O. The reason to use PrimState is that we will use mutable vectors for the evaluation.

evalWith :: (PrimMonad m, MachineIO m) => VMOptions -> Program Optimized -> m MachineType Source #

Evaluate the given program returning the end state of the Machine. The evaluation can happen in any PrimMonad for which we can do I/O. The reason to use PrimState is that we will use mutable vectors for the evaluation. VMOptions are used to tune the details of the VM, like available memory, verbosity, etc.

evalWithIO :: VMOptions -> Program Optimized -> IO MachineType Source #

Evaluate the given program returning the end state of the Machine. The evaluation happens in IO, so Input/Output is done to the console.

evalWithMachine :: forall m. (PrimMonad m, MachineIO m) => VMOptions -> MachineType -> Program Optimized -> m MachineType Source #

Evaluate the given program returning the end state of the Machine. The evaluation can happen in any PrimMonad for which we can do I/O. The reason to use PrimState is that we will use mutable vectors for the evaluation. VMOptions are used to tune the details of the VM, like memory available, verbosity, etc. The evaluation starts with the specified MachineType, so the memory and initial pointer can be configured before running.

emptyMachine :: MachineType Source #

A VM Machine with the default memory available.

mkMachine :: Word -> MachineType Source #

Create a new machine with the given memory

data VMOptions Source #

Command line arguments for the VM evaluator.

Constructors

VMOptions 

Fields

defaultVMOptions :: VMOptions Source #

Default configuration for the VM.

unsafeParse :: [String] -> IO VMOptions Source #

Parse a list of command line arguments printing errors to the stderr

parse :: IO VMOptions Source #

Parse command line arguments printing errors to the stderr

parsePure :: [String] -> ParserResult VMOptions Source #

Parse a list of command line arguments