Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on How to initialize variable assignment in a non-OOP interpreter?
Post
How to initialize variable assignment in a non-OOP interpreter?
I'm still in the process of making MarkFuncs and having given up from copy-pasting open-source interpreters, them using OOP too, I decided to make one without OOP and with scratch alongside with the help of @Moshi in the Discord server.
test4
is where I'm currently at right now. interpreter.py
currently has an output syntax for strings, and 2 functions that solve a challenge each in Code Golf CD. Right now, I want to do some math, in other words, deal with integers. The first problem to encounter, however is variable assignment.
I still have no idea how to get a specific keyword stored into the program and its value, then be reused and/or outputted. Here's what I have in mind for the syntax to be like:
x=9;y=10;→x+y; # Full program
x=9 # Assign 9 in variable named x
; # Semicolon to terminate the assigning process
y=10 # Assign 10 in variable named y
; # Semicolon to terminate the assigning process
→x+y # Output the sum of x and y (uses the in-progress calculate() function)
; # Semicolon to terminate the outputting process
This will be put in the Input section of the TIO link.
Since I'm not using OOP--and I want to keep it that way--, it'll be tricky to even make variable assigning possible, and that's why I need help here.
Question: How to make variable assigning possible in my Python-written interpreter?
1 comment thread