Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cyberfined/harakiri-lib
library for parsing, type checking and compiling harakiri language
https://github.com/cyberfined/harakiri-lib
aarch64 compiler compilers harakiri haskell haskell-library imperative-programming-language programming-language register-allocation
Last synced: 3 days ago
JSON representation
library for parsing, type checking and compiling harakiri language
- Host: GitHub
- URL: https://github.com/cyberfined/harakiri-lib
- Owner: cyberfined
- License: wtfpl
- Created: 2021-02-19T09:36:37.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-02-19T09:50:49.000Z (over 3 years ago)
- Last Synced: 2023-08-28T05:50:15.754Z (about 1 year ago)
- Topics: aarch64, compiler, compilers, harakiri, haskell, haskell-library, imperative-programming-language, programming-language, register-allocation
- Language: Haskell
- Homepage:
- Size: 41 KB
- Stars: 2
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# harakiri lib
Library for parsing, type checking and compiling a simple programming language named harakiri. It's implemented without LLVM or GCC backend.
## Supported architectures
* Aarch64
## Syntax
All supported constructions are used in the code below:
```
def fib(n) {
if n <= 2 {
return 1
}
return fib(n-1) + fib(n-2)
}def print_interval(from, to) {
while from < to {
echo(from)
from = from + 1
}
}def main() {
echo("Enter mode: 0 - interval printer, 1 - fibonacci calculator")
a = -1
while 1 {
a = input()
if a != 0 && a != 1 {
echo("Mode must be equal to 0 or 1")
} else {
break
}
}
if a == 0 {
echo("enter start value")
a = input()
echo("enter end value")
b = input()
print_interval(a, b)
} else {
echo("enter n to get n-th fibonacci number")
a = input()
echo(a, "-th fibonacci number is: ", fib(a))
}
}
```## Supported operations
| operation | unary or binary | description |
|-----------|-----------------|--------------------------|
| - | unary | negate |
| + | binary | addition |
| - | binary | subtraction |
| * | binary | multiplication |
| / | binary | division |
| == | binary | equal to |
| != | binary | not equal to |
| < | binary | lower than |
| <= | binary | lower than or equal to |
| > | binary | greater than |
| >= | binary | greater than or equal to |
| && | binary | boolean and |
| \|\| | binary | boolean or |## Implemented parts
- [x] Parser
- [x] Type checker
- [x] IR generation
- [x] Assembly language code generation
- [ ] IR optimizations