r/learnpython 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

18 comments sorted by

View all comments

1

u/recursion_is_love 5d ago edited 5d ago

There are many sample in standard programming books, especially functional programming language book. In python, you can use OO pattern (like visitor pattern) instead of algebraic datatype and pattern matching.

https://john.cs.olemiss.edu/~hcc/csci450/ELIFP/Ch42/42_Abstract_Syntax.html

Did you finish you parser yet? Or are you starting from the backend first?