This is a simple PL0 compiler implemented in C. PL0 is a simple programming language used for educational purposes. The compiler consists of a lexical analyzer that tokenizes input code and prints out the tokens.
To build the compiler, make sure you have make installed on your system. Then, follow these steps:
-
Clone the repository:
git clone https://github.com/MatheusVBellini/lexical-analyser
-
Navigate to the project directory:
cd lexical-analyser -
Build the compiler:
make
Once the compiler is built, you can use it to tokenize PL0 code files. Here are the available commands:
-
make run: Runs the compiler on a PL0 code file. You need to provide the path to the input file.make run
-
make test: Runs a test suite to ensure the compiler is working correctly. The test suite includes various PL0 code files with expected token outputs.make test
Suppose you have a PL0 code file named example.pl0 with the following content:
VAR x;
BEGIN
x := 5;
END.
You can tokenize this file using the compiler:
make run example.pl0This will output the tokens:
VAR, VAR
x, ident
;, simbolo_ponto_virgula
BEGIN, BEGIN
x, ident
:=, simbolo_atribuicao
5, numero
;, simbolo_ponto_virgula
END, END
., simbolo_ponto
This project is licensed under the MIT License. See the LICENSE file for details.