redraiment / brainfuck Goto Github PK
View Code? Open in Web Editor NEWBrainfuck Compiler and Interpreter with LLVM in C
License: GNU General Public License v3.0
Brainfuck Compiler and Interpreter with LLVM in C
License: GNU General Public License v3.0
Merge the serial same commands to reduce instructions and enhance performances.
+
and -
commands to one update instruction.>
and <
commands to one move instruction.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
Build AST.
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.
It because the execution engine (JIT compiler) cannot find putchar
and getchar
.
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. |
Enhance the C version compiler to support JIT interpreter mode.
#!/usr/bin/env brainfuck
++++++++++
[>+++++++>++++++++++>+++>+<<<<-]
>++.>+.+++++++..+++.>++.<<+++++++++++++++.
>.+++.------.--------.>+.>.
#
for single line comment.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.Emit LLVM representation (.ll)
ld
command to link the object files.It would be cashed when link to executable file.
Build a simple Brainfuck interpreter in pure ANSI C, without any third-party dependencies.
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!
Change the default behavior same with clang:
Disable extra command default, and let user to enable it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.