Giter Club home page Giter Club logo

bcc's Introduction

BCC (Brainfuck to JVM bytecode compiler)

This is a compiler from Brainfuck to JVM bytecode. Pull BFCompiler.jar and use the following command:

java -jar BFCompiler.jar [target source file] [name of class]

This command will generate a .class file with the name that you indicated in the above command. To run that file, use this:

java -noverify [name of class]

We need -noverify because the compiler does not push new stack frames for every jump instruction, a safety violation according to the JVM.

Example:

java -jar BFCompiler.jar helloworld.bf helloworld
java -noverify helloworld

The above commands generate a helloworld.class file, which is executed by the second command.

Also, the brainfuck runtime requires that you press [RETURN] whenever you key in a new character. This is a limitation of the compiler. If you key in more than one character before pressing [RETURN], the runtime will simply take the first letter encountered and discard there rest.

BFRuntime.java was written as a reference for the bytecode generation for the bf runtime. Run ASMifier to see the bytecode.

Build instructions

This is just an Eclipse project, so just use your favourite blend and go. To use my exact build configuration, you will need:

Plugin Version Where?
Bytecode Outline 2.4.3 (Eclipse Marketplace)
ANTLR 4 IDE 0.3.5 (Eclipse Marketplace)
XText 2.7.3 download "All-In-One Update Site" here

Manually installing the .zip
Using the Eclipse Marketplace

You can use the ASMifier provided by Bytecode Outline directly from Eclipse, and saving the grammar.g4 file in /grammar will automatically build the parser/lexer.

If the versions become superseded on the Marketplace, drop and issue or even better, update this file and pull request.

To build this, create a build configuration in Eclipse that builds BFCompiler. BFRuntime contains a main method for accuracy, and your Eclipse install may default to building that so be careful.

To get the .jar file, just export as runnable JAR and you're good to go.

Have fun!

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.