Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/txus/calc
Simple arithmetic language interpreter with JIT compilation, using LLVM.
https://github.com/txus/calc
Last synced: 3 months ago
JSON representation
Simple arithmetic language interpreter with JIT compilation, using LLVM.
- Host: GitHub
- URL: https://github.com/txus/calc
- Owner: txus
- Created: 2013-06-23T18:55:23.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-23T15:56:49.000Z (over 11 years ago)
- Last Synced: 2024-08-03T18:14:08.833Z (6 months ago)
- Language: C
- Homepage: https://github.com/txus/calc
- Size: 141 KB
- Stars: 25
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- AwesomeInterpreter - calc
README
# calc
Calc is a proof of concept to implement a simple arithmetic language
interpreter with JIT compilation, using either LLVM or a more low-level JIT
based on GNU Lightning.A fun weekend project, if you ask me!
# Install
You need LLVM and GNU Lightning installed. On Mac OSX:
$ brew install llvm
Unfortunately the version of Lightning in Homebrew is broken. Download and
install lightning from its [mirror git repository][lightning].Now:
$ git clone git://github.com/txus/calc.git calc
$ cd calc
$ makeYou get the `calc` executable.
## Usage
Using the AST-walking interpreter:
$ ./calc "3 * (4 + 5)"
Using the LLVM JIT compiler:
$ ./calc --llvm "3 * (4 + 5)"
Using the lower-level, GNU-lightning based JIT compiler:
$ ./calc --jit "3 * (4 + 5)"
## Syntax
It's just integers, these operators: `+ - * /`, and parentheses for precedence.
## Who's this
This was made by [Josep M. Bach (Txus)](http://txustice.me) under the MIT
license. I'm [@txustice][twitter] on twitter (where you should probably follow
me!).[twitter]: https://twitter.com/txustice
[lightning]: https://github.com/bonzini/lightning