This project is actually a transpiler, I just stared it as a compiler study/practice. Here I attempt to translate from a simplified form of C++ to modern C++.
(I should think in a better name for my simplified C++ version)
This was a couple of months side project, feel free to learn from it, but please don't expect a stable tool. There's half done stuff and buggy features here and there.
Still, I managed to port some classes from my game engine math library to simplified C++, which was way more than expected when I started this. Compilers are intimidating, but once you get to have a basic one working, it feels very powerful.
- No pointers or references
- Define the memory space for each class (stack or heap) by using stack keyword before class definition:
stack class Line: public Shape
- Single file (no declaration/implementation separation)
- Modules!
- Automatic includes and circular dependency
- It relies on C++ linters and Language Servers for coloring/autocompletion
- Some errors may be spotted (related with includes etc)
- It relies on some silly macros (see
code/core/FakeMacros.hpp
) to fake some keywords
- Access to C++ std stuff
- Recursive Scope search must be improved
- Access to STL containers
- Reflection (it should come almost for free)
- Lambdas syntax
- RECOMENDED
- to build compiler +
ToCPP
tool:python3 -B scripts/build.py -xl
- it will generate:
binaries/tools_ToCPP
- NOTICE this IS the transpiler
- you can use it like this:
./binaries/tools_ToCPP file1.cxx file2.cxx ...
- I usually run the tool from VSCode with
launch.json
andtasks.json
configurations
- it will generate:
- build integration test suite:
python3 -B scripts/build.py -xil
- this will build the generated C++ files
test/integration/BasicTest
- this will build the generated C++ files
- to build compiler +
- First, download and install dependencies:
./scripts/dependencies.sh
- Build project:
python -B ./scripts/build.py -[ruixlch]
- -h Show help.
- -r Compile Release, Debug by default.
- -u Compile Unit Tests suite. (NEEDED BY
test.sh
) - -i Compile Integration Tests suite. (NEEDED BY
test.sh
) - -x Compile Tools.
- -l Enable Logs.
- -c Clean the project.
- Run unitary tests (optional):
./scripts/test.sh
Not available yet.
- code: Source and Headers.
- config: Engine and scenes config files.
- scripts: Contains scripts described above.
- compiledLibs: Contains the libcompiler.a. Generated by
scripts/build.py
. - binaries: Generated by
scripts/test.sh.
. Contains the test executable files (both unitary and integration). - test: Set of tests. Unitary and Integration.
- tools: Set of tools.
- dependencies: Generated by
scripts/dependencies.sh.
Contains third party libraries. - build: Generated by
scripts/build.py
.
Run unitary tests with ./scripts/test.sh
. Result are stored in binaries/output.
This command will print the results in terminal.
Run integration test by executing ./binaries/test_integration
. Result is stored in log.txt.