- A transpiler that converts an imaginary language 'lambda' into executable C source code.
- The current build works perfectly without conflicts/shift reduce warnings. (except for 1, look at commit message)
- The comp structure is not implemented.
- Final Grade: 9/10
-
Download all necessary files:
mylexer.l
myanalyzer.y
cgen.c
cgen.h
lambdalib.h
build.sh
-
Build the Compiler:
- Open a terminal.
- Navigate to the directory containing the downloaded files.
- Run the build script with the following command:
chmod +x build.sh
./build.sh
- This script will automatically create the compiler named
mycomp
.
To test the compiler with an input file, follow these steps:
-
Prepare your input file:
- Ensure you have a valid input file with the extension
.la
(e.g.,input.la
).
- Ensure you have a valid input file with the extension
-
Run the Compiler:
- Use the following command to compile your input file:
./mycomp <input.la> ex.c
- This command will take
input.la
as the input and generate a C source file namedex.c
.
- Use the following command to compile your input file:
-
Compile the Generated C Source Code:
- Use a C compiler (e.g.,
gcc
) to compile the generated C source file:gcc ex.c -o output
- Replace
output
with the desired name for your executable.
- Use a C compiler (e.g.,
- Make sure you have the necessary build tools installed (e.g.,
flex
,bison
,gcc
). - This transpiler only checks for correct syntax. It doesn't check for further code clarity and will transfer mistakes to the output C code.