CLOWN is a simple programming language that is designed to be easy to learn and use. It is a high-level language and a mixture of C, Python, and JavaScript. It is statically typed, and supports functions, loops, and many other features.
- This is a project for the course "CMP4060 Compilers and Languages" at the University of Cairo, Faculty of Engineering, Computer Engineering Department.
- The compiler doesn't execute the code, it only checks for syntax errors and prints the intermediate assembly code (Quadruples).
- Not all the features have quadruples generation (Functions, Enums, Break, Continue, and Return).
- The compiler is not fully tested, so it may contain bugs.
- Remove
extern int yydebug;
insrc/clown.y
if any - Remove
yydebug = 1;
in main function insrc/clown.y
if any
make all
make run INPUT_FILE=inputs/code.clown
- Add
extern int yydebug;
tosrc/clown.y
- Add
yydebug = 1;
to main function insrc/clown.y
make all
make run INPUT_FILE=inputs/code.clown
"int", "float", "string", "bool", "print", "if", "else", "elif", "while", "for", "do", "break", "continue", "return", "=", "==", "!=", ">", ">=", "<", "<=", "+", "-", "*", "/", "^", "%", "||", "&&", "!", "(", ")", "{", "}", ";", "function", "const", "switch", "case", "default", "enum", "NULL", ":", ","
print("Hello World");
print(a);
print(a + b);
print(1 + 2 + 3);
if (a == 1) {
print("a is 1");
} elif (a == 2) {
print("a is 2");
} else {
print("a is not 1 or 2");
}
int a = 0;
while (a < 10) {
print(a);
a = a + 1;
}
for (int i = 0; i < 10; i = i + 1) {
print(i);
}
int a = 0;
do {
print(a);
a = a + 1;
} while (a < 10);
int a = 0;
while (a < 10) {
print(a);
a = a + 1;
if (a == 5) {
break;
}
}
int a = 0;
while (a < 10) {
a = a + 1;
if (a == 5) {
continue;
}
print(a);
}
function add(a, b) {
return a + b;
}