Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/williamfedele/tinycompiler
Compiler written in Zig for fun
https://github.com/williamfedele/tinycompiler
compiler compiler-design zig ziglang
Last synced: 21 days ago
JSON representation
Compiler written in Zig for fun
- Host: GitHub
- URL: https://github.com/williamfedele/tinycompiler
- Owner: williamfedele
- License: mit
- Created: 2024-09-25T03:38:27.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2024-10-17T19:27:18.000Z (21 days ago)
- Last Synced: 2024-10-17T19:42:27.377Z (21 days ago)
- Topics: compiler, compiler-design, zig, ziglang
- Language: Zig
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
⚡ TinyCompiler
A compiler written for fun to learn about Zig.
**Disclaimer**: The grammar, found in `grammar.ebnf`, has not been validated to reject erroneous code. There is also no semantic error handling at the moment so variables are not checked for existence for example. I need to generate a symbol table over the AST before the code generation phase.
## Syntax
The syntax is intentionally simple to make this a Zig learning experience rather than one of compiler design. I may extend it to include other features that are relatively simple like functions.
**Datatypes**: Only integers are valid at the moment.
**Keywords**: _if, while, end, print_.
### Example Usage
Source file:
```
x = 10/2
y = 5*2+1if (x <= y) print x+2 end
while (y >= x)
print y
if (y == 7)
x = x - 1
end
y = y - 1
end
```Translated output (python for now):
```py
x = 10 / 2
y = 5 * 2 + 1
if x <= y:
print(x + 2)
while y >= x:
print(y)
if y == 7:
x = x - 1
y = y - 1
```## License
[MIT](https://github.com/williamfedele/tinycompiler/blob/main/LICENSE)