Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/g-w1/ezc
compiler for ez (a language that I made)
https://github.com/g-w1/ezc
asm compiler rust ziglang
Last synced: 3 months ago
JSON representation
compiler for ez (a language that I made)
- Host: GitHub
- URL: https://github.com/g-w1/ezc
- Owner: g-w1
- License: gpl-3.0
- Created: 2020-09-05T23:39:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-10-08T20:55:59.000Z (over 1 year ago)
- Last Synced: 2024-10-01T03:23:06.030Z (3 months ago)
- Topics: asm, compiler, rust, ziglang
- Language: Rust
- Homepage:
- Size: 1.72 MB
- Stars: 18
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ezc
Compiler for `ez`.
## Documentation: https://jacobgw.com/ezc/
## Goals
- To learn a _lot_
- `ez` should resemble english
- Use only rust standard library
- Write a working compiler.
- Write a (minimal) standard library for `ez` in another language (zig, rust, c, asm, ..)## Instructions
To run just do `ezc file` use `-g` flag for debug info (it will generate a out.asm file). then you can open in gdb or lldb
To make use of the standard library, pass `-stdlib-path /path/to/stdlib` to the compiler. To compile the standard library, go into the lib directory in this compiler. Then run `zig build` in that directory and find the library in `zig-cache/lib/libstd.a`. You will probably need zig 0.7.1. You can find that here: https://ziglang.org/download/.
To test the code: `cargo test`
To test the generated code you can do `cd tests; ./test.sh`. Note: this requires `gcc`.## Dependencies:
- Zig (0.7.1). NOTE: If you want to build without zig run `HAS_NO_ZIG=1 cargo build`. This may be useful if you are on a system without zig or want to provide your own standard library.
- `nasm`
- `cargo`
- `gcc` (only for testing)## Resources
- http://www.eis.mdx.ac.uk/staffpages/r_bornat/books/compiling.pdf - book about compilers
- http://www.egr.unlv.edu/~ed/assembly64.pdf - book about x86-64 assembly
- https://ruslanspivak.com/lsbasi-part1/ - this blog series as a reference to the frontend of a compiler
- [godbolt.org](https://godbolt.org) - an interactive webpage to explore how compilers work on the backend
- http://tinf2.vub.ac.be/~dvermeir/courses/compilers/compilers.pdf - book about compilers.
- https://github.com/ziglang/zig - source code for another programming language
- http://www.cs.ecu.edu/karl/5220/spr16/Notes/Lexical/finitestate.html - explanation of a lexer as a state machine
- https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/index.html - another tutorial about compilers. it is by the leader in the industry compiler toolchain (llvm)
- http://www.cs.man.ac.uk/~pjj/cs2111/ho/node10.html - stack based code generation for expressions
- https://craftinginterpreters.com/ - book about interpreters. could be useful
- https://wiki.osdev.org/System_V_ABI talks about this systemv abi: used for calling conventions. this also does https://wiki.osdev.org/Calling_Conventions## Features
- [x] lexer
- [x] ast (structs for ast items)
- [x] parser
- [x] codegen
- [x] immutable assignments
- [x] mutable variables
- [x] semantic analysis.
- [x] expressions (the start of recursive parsing)
- [x] if statements
- [x] loops
- [x] fancy compile errors (with carets)
- [x] functions
- [x] modules
- [x] char literals
- [x] standard library
- [x] io
- [x] arrays and string literals
- [x] finish blog bost
- [x] finish documentation