8000 GitHub - annikulin/brainfuck-compiler: Brainfuck to JavaScript compiler
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

annikulin/brainfuck-compiler

Folders and files

< 8000 thead class="DirectoryContent-module__OverviewHeaderRow--W8yGl Table-module__Box_1--JrPYF">
NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brainfuck to JavaScript compiler

Actions Status

Overview

Brainfuck compiler that executes Brainfuck code in Java and transpiles it to JavaScript.

The following phases of the compiler are supported:

  1. Lexical Analysis (Tokenization). The text of the program is broken up into Tokens and kept inside of a computer’s memory;
  2. Parsing. A sequence of Tokens is being analyzed, and a parse model consisting of Statements and Expressions is constructed showing syntactic relation between commands;
  3. Code Optimization. Subsequent increment, decrement, and shift commands are replaced by a single aggregate operation;
  4. Code Generation or Execution:
    • Code Generation. Brainfuck program is transpiled into JavaScript code;
    • Code Execution. Brainfuck program is being interpreted in Java.

Quickstart

Use BrainfuckCompiler command-line utility to try out how the transpiler works.

To execute a classic "Hello World!", create a file with Brainfuck code:

echo "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++." > /tmp/HelloWorld.b

Then, run the compiler with ./gradlew run passing arguments for input Brainfuck and output JS files.

./gradlew run --args="-i /tmp/HelloWorld.b -o /tmp/HelloWorld.js"

First, BrainfuckCompiler executes Brainfuck code in Java, then transpiles it to JavaScript, and evaluates generated script inside the Nashorn JS engine.
Hello World in Brainfuck

About

Brainfuck to JavaScript compiler

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0