minimal x86_64 compiler that converts cslop to assembly it is written entirely from scratch without any dependencies except the java runtime environment and nasm assembler currently all the code is modular in assembly ,meaning its really unoptimized and it still manages to beat python at speed
npm install real-compiler
npx compiler yourfile.tl
- ':' -> equal to
- '|' -> or
- '&' -> and
the rest are standard
int a = {NumExp} \\ all integers and booleans are 64 bit
boolean a = {BoolExp}
if(cond a){
{Program}
}
elif(cond b){
{Program}
}
else
{
{Program}
};
while(cond a){
{Prog}
};
exit({NumExp});
a program is a list of statements
int i = 1;
int n = 2147483647;
int f = 0;
int rem = 0;
while(i<n){
rem = n%i;
if(rem:0){
f = f+1;
};
i = i+1;
};
if(f:1){
exit(1);
};
exit(0);
- 1. lexer
- 2. parser
- 3. ast
- 4. code gen
- 5. stack management
- 7. arithmetic expressions
- 8. boolean expressions
- 9. while loops
- 10. variable scopes
- 11. error handling
- 12. functions
- 13. peephole optimization
- 14. arrays and strings
- 15. input and output