Tool | Description |
---|---|
Flex | Lexical Analyzer Generator |
Bison | Parser Generator |
React | Frontend framework used for GUI |
NodeJS | Backend framework |
Github Actions | CI to generate Binary and push it to backend directory |
int x;
int x = 5;
const int x = 5;
string x = "Hello";
string x = "c";
- Available types
- int
- float
- string
- bool
- Mathematical operator
- +, -, *, /, %,
- Logical operator
- ==, !=, >, <, >=, <=
- and , or , not , xor
x = 5;
x = "Hello";
x = 5.5;
x = true;
if (x == 5 and y == 10) {
x = 10;
} endif
if (x >= 5 or y <= 10) {
x = x +1 ;
} else {
x = x - 1;
}
if (x < 5 and y > 10) {
x = x + 1;
} else if (x > 5) {
x = x - 1;
} else {
x = 0;
}
while (x < 5) {
x = x + 1;
}
repeat {
x = x + 1;
} until (x == 5);
for (int i = 0; i < 5; i = i + 1) {
x = x + 1;
}
switch (x) {
case 1:
x = 1;
break;
case 2:
x = 2;
break;
default:
x = 0;
}
int func1(int x, int y) {
return x + y;
}
void func2(int x) {
x = x + 1;
}
int func3() {
return 5;
}
int x = func1(5, 10);
func2(5);
int y = func3();
{
int x = 5;
{
x = x + 1;
}
}
// This is a comment
print("Hello World");
print(x);
print(5);
print(5+6);
enum Color {
RED,
GREEN,
BLUE
}
enum Color c = RED;
-
There is a script named build.sh that generates the parser and lexer and takes test file from you as input argurmnt.
-
You can run the script by typing the following command in the terminal:
./build.sh if_test.c
-
Note: the test file should be in the test_cases folder.
-
Errors and warning will be printed to the terminal.
-
Symbol table will be generated in a txt file named symbol_table.txt.
-
The quadruples will be generated in a txt file named quads.txt.
Quadraple | Description |
---|---|
PUSH (value) | Pushing (value) to stack |
POP (ID) | Pop value from stack to the (ID) |
NOT | Getting complement of value |
ADD (arg1) (arg2) (result) | Adding (arg1) (arg2) and save value to (result) |
SUB (arg1) (arg2) (result) | Substracting (arg1) (arg2) and save value to (result) |
MUL | Multiply (arg1) (arg2) and save value to (result) |
DIV | Divide (arg1) (arg2) and save value to (result) |
MOD | Calculate the modules of (arg1) (arg2) and save value to (result) |
AND | Perform logical and between (arg1) (arg2) and save value to (result) |
OR | Perform logical or between (arg1) (arg2) and save value to (result) |
XOR | Perform logical xor between (arg1) (arg2) and save value to (result) |
EQ | Check the equality of the two operands and store the comparsion result in temp reg |
NE | Check the inequality of the two operands and store the comparsion result in temp reg |
LT | Check if the first operand is less than the second and store the comparison result in temp reg |
GT | Check if the first operand is greater than the second and store the comparison result in temp reg |
LE | Check if the first operand is less than or equal the second and store the comparison result in temp reg |
GE | Check if the first operand is greater than or equal the second and store the comparison result in temp reg |
JMP L(): | Unconditional Jump to label |
JUMPZERO L(): | Jump if the zero flag from previous command is zero |
JMPNONZERO L(): | Jump if the zero flag from previous command is non-zero |
Convi (var/value) | Convert float to integer |
Convf (var/value) | Convert integer to float |