Git Product home page Git Product logo

brainfuck's Introduction

Hi ๐Ÿ‘‹, I'm Zhang, Zepeng (redraiment)

redraiment


๐Ÿ‘จโ€๐Ÿ’ป Bio

{:name {:first "Zepeng"
        :last "Zhang"}
 :email "[email protected]"
 :bio "A Full Stack Engineer Passionate about Cutting-Edge Technologies."
 :favorites [:AI :Compiler :Database :DataAnalysis :WebApplication
             :Clojure :Kotlin :Python :C :JavaScript
             :Linux :FreeBSD :PostgreSQL :Emacs]}

๐Ÿ”ญ Looking forward to connecting with you and creating something amazing together!

๐Ÿ“‹ My Funny Projects

Quote by Richard P. Feynman: "What I cannot create, I do not understand."

Hence, I reinvented many wheels.

๐Ÿงฌ Play with Interpreters & Compilers

  • brainfuck: A learning project focused on practicing compiler and interpreter construction using LLVM C API, flex, bison, and more.
  • basic: A BASIC Programming Language Interpreter implemented in ANSI C.
  • SmallC: my undergraduate graduation project, featuring a programming language with built-in concurrency support.
  • Linsp: A minimal Lisp interpreter in Lisp, inspired by The Roots of Lisp.
  • clop: A programming language currently under design.
  • jssp: A templating system embedding JVM scripting language into text documents, similar to JSP, PHP, ASP, and other server-side scripting languages.

๐Ÿ–ผ๏ธ Frameworks

FrontEnd Framework on React
  • pure-frame: A data-driven, functional, and reactive JavaScript framework for modern web apps, utilizing React and inspired by re-frame.
BackEnd Framework on Clojure
  • zeta: An open-source software development toolkit in Clojure.
BackEnd Framework on Java
BackEnd Framework on PHP 5
  • PinkRaiment: A PHP MVC framework inspired by RoR.
  • phpActiveRecord: ActiveRecord implementation in PHP, similar to jActiveRecord.

๐Ÿ‚ Play with Emacs Lisp

  • edbc: Emacs-Lisp-based data access technology inspired by JDBC.
  • emacs-cgi: Using Emacs Lisp for CGI scripting.
  • eml: Emacs-lisp Markup Language - converting S-expressions to XML.
  • wechat.el: A framework for developing WeChat games in Emacs Lisp.

๐Ÿ’ฝ Play with Databases

  • SciKit Learn for PolarDB: A PostgreSQL extension wrapping SciKit-Learn.
  • pgaut: A PostgreSQL extension implementing MySQL's on update current_timestamp.
  • pgsql-proxy-middleware: A one-liner Node.js proxy middleware for PostgreSQL.
  • sqlet: A framework for developing web services in pure SQL.

๐Ÿฌ Play with Docker

My workstations: Development environments based on Docker containers.

  • docker-workstations: A collection of Docker images for development, including:
    • archlinux: A Archlinux Docker based image with useful utilities.
    • clojure: A Clojure development environment based on archlinux with Leiningen.
    • python: a Python development environment based on archlinux with IPython and Jupyter.

๐Ÿ’ก Play with Knowledges

๐Ÿงฐ Play with Utilities

  • jco: An API for parsing command-line options in Java programs.
  • jfn: An example of functional-style programming in pure Java (1.5+).
  • listfile: An enhanced ls capable of matching file paths with regular expressions.

brainfuck's People

Contributors

redraiment avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

brainfuck's Issues

Reduce the serial same commands

Merge the serial same commands to reduce instructions and enhance performances.

  • Reduce the serial + and - commands to one update instruction.
  • Reduce the serial > and < commands to one move instruction.

Build a Brainfuck compile with LLVM C API

Almost of LLVM tutorials are using C++, however, I'd like to use C language to build the lightweight compiler.
Fortunately, the LLVM provides the C interface as well!

Support shebang mode

Function Requirement

  • Support shebang mode like below:
#!/usr/bin/env brainfuck

++++++++++
[>+++++++>++++++++++>+++>+<<<<-]
>++.>+.+++++++..+++.>++.<<+++++++++++++++.
>.+++.------.--------.>+.>.

Tech Requirement

  • Add new command # for single line comment.

Provide command line options to switch between compile mode and scripting mode

Function Description

Usage: brainfuck [Options] <source-file>

Options:

  • -c/--compile: Enable compile mode. Emit native object (.o).
  • -p/--preprocess: Enable preprocess mode. Emit LLVM representation (.ll).
  • -s/--script: [DEFAULT] Enable scripting mode. Parse and execute in memory.
  • -o/--output <output-file>: Write output to file.
  • -h/--help: Show this help and exit.

Tech requirement

  • Parsing command line options with GNU getopt library.

Learn brainfuck specification

Resources

Key Information

  • Memory size: 30,000 bytes, and initialized to zero.
  • Data pointer initialized to point to the leftmost byte of the array.
  • Two streams of bytes for input and output.
  • Eight commands:
Character Meaning
> Increment the data pointer (to point to the next cell to the right).
< Decrement the data pointer (to point to the next cell to the left).
+ Increment (increase by one) the byte at the data pointer.
- Decrement (decrease by one) the byte at the data pointer.
. Output the byte at the data pointer.
, Accept one byte of input, storing its value in the byte at the data pointer.
[ If the byte at the data pointer is zero, then instead of moving the instruction pointer forward to the next command, jump it forward to the command after the matching ] command.
] If the byte at the data pointer is nonzero, then instead of moving the instruction pointer forward to the next command, jump it back to the command after the matching [ command.

Embed Brainfuck as DSL in Clojure with macro

Macro in Lisp is an amazing feature! It can be used for defining language syntax extensions, which is known as Domain Specific Languages (DSLs).

Try create a Clojure macro to embedded Brainfuck into Clojure.

make error

Hello author:
when I use make command,it will be error.

user@user-Latitude-5430:~/brainfuck$ make
clang -c -I/usr/local/include  -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -o options.o options.c
clang -c -I/usr/local/include  -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -o engine.o engine.c
clang -c -I/usr/local/include  -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -o ast.o ast.c
/usr/bin/bison -d -o parser.c parser.y
/usr/bin/flex --header-file=scanner.h -o scanner.c scanner.l
clang -c -I/usr/local/include  -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -o parser.o parser.c
In file included from parser.y:3:
parser.y:12:3: error: unknown type name 'yytoken_kind_t'
  yytoken_kind_t token;
  ^
1 error generated.
make: *** [Makefile:35: parser.o] Error 1

Set link mode as default

Change the default behavior same with clang:

  • Default to generate executable file.
  • Remove the link mod option.

Support link mode

Function Requirement

  • Generate the executable file by link mode.

Tech Requirement

  • Use system() function to invoke ld command to link the object files.

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.