This project encompasses various phases of a compiler, each residing in its respective directory.
Presented by:
- Anton Ashraf
- Omar Ahmed
- Salma Ismail
- Marwan Hazem
A big thank you to these amazing contributors for their dedication and hard work! ๐โจ
Contains the implementation of the lexical analysis phase of the compiler.
- File:
lexical.cpp
- Reads the
input.c
file and generates tokens. - Tokens are written to
output.txt
. - Performs bracket matching using the
chck_brakects
function.
- Reads the
Houses the syntax tree generation phase of the compiler.
- Files:
SyntaxPhase.cpp
: ParsesWhile.c
and generates a syntax tree.SyntaxPhase.hpp
: Contains functions for parsing different code structures.
Encompasses the LR parsing phase of the compiler.
- File:
shiftreduce.cpp
- Reads
input.c
andrules.txt
. - Performs shift-reduce parsing and writes the output to
Output.txt
. - Utilizes a set of production rules defined in
rules.txt
.
- Reads
To execute specific phases of the compiler:
- Navigate to the relevant directory (e.g.,
01Lexical/
,02SyntaxTree/
, or03LRParser/
). - Compile and run the corresponding source file (e.g.,
lexical.cpp
,SyntaxPhase.cpp
, orshiftreduce.cpp
).
For example:
cd Compiler/01Lexical/
g++ lexical.cpp -o lexicalAnalyzer
./lexicalAnalyzer
- C++ compiler for compiling the source files.
- Input files such as
input.c
,While.c
, andrules.txt
as required by specific phases.
- The lexical analysis phase checks for balanced brackets using the
chck_brakects
function. - The LR parsing phase utilizes a set of production rules defined in
rules.txt
.
Feel free to explore each directory for detailed implementation and outputs. For any questions or issues, refer to the specific README within each directory.
Happy compiling!