A compiler for the MiniSoft language developed with Flex and Bison. This project was created as part of the Compilation course at the University of Science and Technology Houari Boumediene (USTHB).
The MiniSoft compiler implements a complete compilation process for a simple educational programming language. It features:
The compiler can detect various errors including:
MiniSoft is a simple programming language with the following features:
MainPrgm L3_software;
Var
<!- Variable declarations ->
let x, y, z: Int;
let a, b: Float;
let arr: [Int; 10];
@define Const PI: Float = 3.14;
@define Const MAX: Int = 100;
BeginPg
{
{-- Main program body --}
x := 10;
y := 20;
z := x + y;
a := 1.5;
b := a * PI;
arr[0] := 5;
if (z > MAX) then {
output("z exceeds maximum");
} else {
output("z is within limits: ", z);
}
for i from 0 to 9 step 1 {
arr[i] := i * 2;
}
do {
x := x - 1;
} while (x > 0);
input(y);
output("You entered: ", y);
}
EndPg;
To build and run the MiniSoft compiler, you need:
On Ubuntu/Debian, you can install these with:
sudo apt-get install build-essential flex bison
Clone this repository:
git clone https://github.com/your-username/minisoft-compiler.git
cd minisoft-compiler
Build the compiler:
make
Clean build files (optional):
make clean
To compile a MiniSoft program:
./compiler test.txt
This will analyze the input file and report any errors found during the compilation process. If compilation is successful, it will output "Program successfully parsed" and display the symbol table.
lexer.l
: Flex specification for lexical analysisparser.y
: Bison specification for syntactic and semantic analysissymtab.h/c
: Symbol table implementationMakefile
: Build configurationtest.txt
: Example MiniSoft programThe compiler is implemented in three main phases:
Special attention was given to:
a := 1 / (7 - 7)
This project is licensed under the MIT License - see the LICENSE file for details.