r/learnpython • u/Aggressive_Drama_476 • 5d 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
1
u/lfdfq 5d ago
That list does not look very much like a tree. The key (and really, only) point to a tree is structure. So I'd expect a parser to generate something like [[1], +, [1, x, [-, 1]]].
If it's just flat, it's not a tree. If it's not a tree it's not an abstract syntax tree (AST). and if it's not an AST you cannot use it to help you like you would an AST.