Question: How would I make import statements?
SpyGuy0215 opened this issue · 2 comments
First off, I just wanted to say that this tutorial is AMAZING!!!! I only have one "issue"/question, which is: how would I go about making an import statement in this language? All of the other stuff I wanted to do could be based off something, but import is kinda different. My apologies if this shouldn't be an issue, I didn't really know how to ask.
Well, you could use RUN(<filename>)
and define functions in said file, then call them from your code.
Define a keyword called 'import' and then implement said keyword in parser so that it checks for a string after the keyword. Define an ImportNode and give the value of the string as one of the properties. In the interpreter, you can copy the execute_run() function to visit_ImportNode and with some minor adjustment, you will have an import statement.