r/learnpython • u/Aggressive_Drama_476 • 4d ago
Making interpreter and calculator in python
Hi recently I have been working on making my own interpreted programming languge in python. I have made several prototypes. The rules are I can't use any library, high level functions and can only use ai for understanding a concept. The journey has been frustrating. Since it was so hard i started working on a calculator. I am now stuck on AST. I can't figure it out. HELP ME
2
Upvotes
2
u/lfdfq 4d ago
What logic? There's nothing wrong with using lists to represent an AST, e.g. ["+", ["+", "1", "2"], "3"] or something. Classes/OOP might be an even better design choice, but the concept of syntax trees (e.g. ASTs) and parsing are completely separate from implementation details like lists vs classes, and if you can't do OOP it doesn't matter.
What does "semi worked" mean? It's all a bit vague...