This project is an implementation of a Lexical and a Syntax Analyzer for the P-- programming language.
This is an educational programming language designed to help the study of how compilers work. The syntax rules of this language can be found in the pdf: Linguagem P--.pdf
- Che Fan Pan (@Che-Fan)
- Eduardo Cavalari Valença (@EduardoCavValenca)
- Marcos Vinicius Firmino Pietrucci (@Marcos-Pietrucci)
- Murilo Mussatto (@mmussatto)
To compile this project, just use the following command
$ make
To run the program, you must use the following command
$ make run
After that, you will be asked for the name of the text file containing the P-- code.
The project was built in two parts. The first one was the development of a Lexical Analyzer to break the source code in a series of tokens. This was achieved by using state machines that read each character of the source code and create a token corresponding to what was read.
After running the program, the output of the lexical analysis, with all the tokens created, can be found in the tokens.txt file.
The second part of the project was to perform a syntax analysis in the source code, following the syntax rules of the P-- language. In order to do this, numerous functions were created to simulate a derivation tree.
After running the program, the output of the syntax analysis can be found in the errors.txt file.