Open oleobal opened 6 years ago
We could store operators and keywords such as Shout
, Put
+into
in a different file, in the same way we did with rkop.py
, and do the same with extensions in a separate file.
And have an optional argument to enable language extensions on our main file.
Actually, unless we make an generic language extension tool, where you'd have to somehow provide functionality (the way it behaves) of your new keyword/operator, which is a rather complex problem, we need to write the extension behavior directly in the interpreter, and enable it with a enable extensions
command line optional argument.
Still, I think it could be interesting to 'anonymize' our operators, as in not write their raw content in the interpreter, but rather in another file, in the same way we did with arithmetic and conditional operators. This could allow us to change the keywords (to implement another language such as French, for example) but provided of course they operate in the same way (for instance, the assignment operator will always be of the form {Put} <expression {into} <variable>
).
rockstar_keywords.py :
class ASSIGNMENT:
PUT = "Put"
INTO = "Into"
class OPERATOR:
class CONDITIONAL:
EQ = 'is'
NEQ = ['aint', 'is not', 'werent', 'wasnt']
...
class ARITHMETIC:
ADD = ['plus', 'with']
...
French cannot be implemented because it is not a formal language. Ask Wittgenstein.
Regardless, good idea for the future. I think it might be possible to have files with each a set of tokens and instructions for execution in Python.
Also if you don't want to disable this instruction for the time being, open a new section in the readme and document it, at least.
1ac5d548708474fcc5afc3faa950ae7504982132 added a
stutter
instruction, but it is not part of spec.I suggest we either think up and implement a mechanism for extension(s ?), putting it in there, or disable it for the time being, to get closer to spec. Else it means a program written using our interpreter would not necessarily work on others.
Thoughts ?