GithubHelp home page GithubHelp logo

brainfuck.go's Introduction

brainfuck.go

Description

BrainFuck interpreter written in golang.

Table of Contents

Installation

Pull this module

go get -u github.com/ronnathaniel/brainfuck.go

Build executable from source

cd ~/go/src/github.com/ronnathaniel/brainfuck.go
go build .
mv brainfuck.go /usr/local/bin/brainfuck

Usage

This compiler can be used both in-line code and in the command line. Simple integrations allow for Used-From-Anywhere.

CLI

On the command line side, this interpreter can be stored as a quasi-executable, like gcc.

Run brainfuck, pass in BF source files as args. Source files should end with extensions .b or .bf

brainfuck hello.bf

interprets and optimizes hello.bf before computing the logic. Input is retrieved from stdin and Output pushed to stdout.

Optionally pass in a string from the command line.

brainfuck -c "++[>+<-]"

Inline

Compiling within code is easy. The Exec function will parse, optimize, compile, and run any string of BrainFuck logic.

The function has a signature of

func Exec(inputRaw string) 

allowing it to be called from anywhere.

import "github.com/ronnathaniel/brainfuck.go/brainfuck"

brainfuck.Exec(">++++[+>+++>>+<<<-]")

Open source files with a supplied OpenFile function. Pass it a relative string path.

fuckRaw := brainfuck.OpenFile("<PATH/TO/SRC>.bf")
brainfuck.Exec(fuckRaw)

Configurations

Enable debugging logs by setting the DEBUG flag.

brainfuck.DEBUG = true

The default tap size is set to 500. Override it with the TAPE_SIZE_DEFAULT flag.

brainfuck.TAPE_SIZE_DEFAULT = <NEW-SIZE: uint32>

Structure

.
├── LICENSE
├── README.md
├── brainfuck/   - importable package
├── cmd.go       - handles command line
└── examples/    - example bf src

Contributions Welcomed :)

Report Issues, create Pull Requests, or email [email protected]

License

This project is provided by the MIT license. All rights reserved.

Copyright

samo c 20

S4M0

brainfuck.go's People

Contributors

ronnathaniel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.