What happened
belive it or not, i made a working parser that works with all out keyword comands function, return,print, and let.
Function- sadly right now couts as a non ending function so it ondly recursivly calls parse fro rest of the file, but thats easy solvable issue.,
Parser now generates correct AST, witch after building Codegen can be correctly transpiled into C
heres a comparison code w/ AST
code:
SUFFER: two
;
FUNCTION main():
let x = 5
print(“hello world”)
return 0
AST:
[{‘type’: ‘function’, ‘name’: ‘main’, ‘body’: [{‘type’: ‘let’, ‘name’: ‘x’, ‘value’: 5}, {‘type’: ‘print’, ‘value’: ‘hello world’}, {‘type’: ‘return’, ‘value’: 0}]}]
as we can see theres a list (body) inside the whole list as a part od the main function. This is enough to generate correct C and run it !
since last time i also implemented errors.py witch is only a library of custom errors dataclas. the point of that is that with mopre complexity in our programming language the more feedback we need to guive to the coder to tell him “hey you did this wrong!” instead of “you fricked up” because that wouldnt be fun
in the picture we can see my terminal as a proof of the working error and parser.
someone told me theres no need for a wirtual enviroment, but its better to keep track of stuff even tho we wont be needing any more packages. BUT if we did then its good practice after compiling the compiler to have all the necesary packages already installed.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.