-
This project based on BUPT SCS Compilation Principles and Techniques Course Design.
-
This is a simple project to generate Pascal-S code, and if you have a Pascal-S to C compiler, this are two Python scripts to compile and compare the result between the generated Pascal-S code and compiled C code.
-
If this project helps you, please give me a ⭐, which will be a great encouragement to me!
- Support assignment, baisc calculation, nested if-else, nested for, function call ( Only functions with depth 1 are supported, just like C ) and std-out statement.
- Try our best to avoid the division by zero fault, but it is still possible. This fault will make lines behind the fault line not executed and you will see nothing is printed. It will NOT effect the correctness of the generated code, it just make the code meaningless.
- Nested if-else, nested for and function call can be nested within each other, which increase the complexity of the generated code.
- The length of the generated code is about 1000 lines, but you can chanege macros in the
src/StructureGenerator.h
to customize the length of your generated code.
You need to install fpc, CMake and Python with following command.
sudo apt-get install fpc
sudo apt-get install cmake
sudo apt-get install python3
You can build the project with following command.
mkdir -p ./build
cd ./build
cmake .. -DCMAKE_BUILD_TYPE=Debug
cmake --build . --config Debug --target all -j 26
There is already a Pascal-S to C compiler in compiler/
. After build with CMake, you just need to run the python script.
python compile_compare.py
You can also check consistency of output of the generated Pascal-S code and compiled C code with following command.
python statistic.py