This is under construction and not ready for use.
This repository provides a C implementation of grug, including the frontend, interpreter backend, and bindings.
The library is packaged as a single grug.c + grug.h pair, and the recommended way to install grug into your project is to copy those source files into your own project. For now they are written as-is, but shortly into the future that file will be generated by a program as an amalgamated build. After that point, grug should also function in the non-amalgam form.
Here are your options as someone compiling grug:
- GRUG_MALLOC_HEADER: optional, a header file to include in grug.c to replace allocation functions
- GRUG_MALLOC: optional, a malloc() function to use with the same arguments as libc malloc
- GRUG_FREE: optional, a free() function to use. Has the signature "void free(void* ptr, size_t len)", so your allocator doesn't need to necessarily store the size for each allocation.
- keep the tests up to date
- rethink the API
- pass grug IR to backend as well as AST
- split grug_arena to its own library, eg. BeardArena
- tokenizer
- parser
- this includes parsing the json AST, writing out the json AST, and writing the AST back out into a grug file
- This is when some tests may begin to pass. Get as many tests to pass as possible with only the tokenizer+parser
- IR generation
- stoopid ass IR walker interpreter
- a temporary solution until all of the tests pass
- amalgamated build
- take
grug_main.hand globs it intogrug.h, taking care to resolve the right includes - take all the C files and other headers in src and globs them into
grug.c, taking care to resolve includes accordingly.
- take
- improve build system
- add windows support
- add macos support?
- make asan and ubsan optional
- add support for providing additional compiler options
- make sure cmake works correctly when importing grug as a cmake package
- Improve CI
- protect main branch so CI must pass before anything can be committed/merged into it
- aarch64
- windows
- create release of the amalgamated sources
- make sure the amalgamated source can be compiled and linked into the example with a single command
- actually run the test suite (only require specially marked tests to pass until they eventually all pass)
- don't forget asan and ubsan
- add a C auto formatter & fail CI if the formatting isn't correct
- I got this idea from Cubyz which has its own formatter and will not pass CI if the formatting isn't correct.
- I don't like any of the existing options I found, I will likely make my own, eg. BeardCFormat
- add clang-tidy to CI
- add tests for grug-for-c working when included in C++ mode
- the C code will not be compiled in C++ mode, however the header may be included from a C++ translation unit
- get 100% coverage
- will most likely require additional tests that aren't in grug-tests
- add support for more build systems
- zig build system, so grug-for-c can be directly imported as a zig package
- bytecode interpreter backend
- Take a look at how the grug-rs bytecode interpreter backend works
- rewrite the README
- create grug-for-c specific examples in a separate repos
- how to import into cmake
- how to import into makefile
- how to import into zig