Open Astramast opened 1 week ago
I think this can be done like this:
import whitespace.interpreter
whitespace.interpreter.eval(some_code)
Confirmed:
>>> import whitespace.interpreter
>>> s='S S S T\tS S T\tS S S L\nT\tL\nS S S S S T\tT\tS S T\tS T\tL\nT\tL\nS S S S S T\tT\tS T\tT\tS S L\nT\tL\nS S S S S T\tT\tS T\tT\tS S L\nT\tL\nS S S S S T\tT\tS T\tT\tT\tT\tL\nT\tL\nS S S S S T\tS T\tT\tS S L\nT\tL\nS S S S S T\tS S S S S L\nT\tL\nS S S S S T\tS T\tS T\tT\tT\tL\nT\tL\nS S S S S T\tT\tS T\tT\tT\tT\tL\nT\tL\nS S S S S T\tT\tT\tS S T\tS L\nT\tL\nS S S S S T\tT\tS T\tT\tS S L\nT\tL\nS S S S S T\tT\tS S T\tS S L\nT\tL\nS S S S S T\tS S S S T\tL\nT\tL\nS S L\nL\nL\n'
>>> whitespace.interpreter.eval(s)
Hello, World!>>>
This has been implemented in my fork of this repo called whitespace2:
>>> import whitespace
>>> s='S S S T\tS S T\tS S S L\nT\tL\nS S S S S T\tT\tS S T\tS T\tL\nT\tL\nS S S S S T\tT\tS T\tT\tS S L\nT\tL\nS S S S S T\tT\tS T\tT\tS S L\nT\tL\nS S S S S T\tT\tS T\tT\tT\tT\tL\nT\tL\nS S S S S T\tS T\tT\tS S L\nT\tL\nS S S S S T\tS S S S S L\nT\tL\nS S S S S T\tS T\tS T\tT\tT\tL\nT\tL\nS S S S S T\tT\tS T\tT\tT\tT\tL\nT\tL\nS S S S S T\tT\tT\tS S T\tS L\nT\tL\nS S S S S T\tT\tS T\tT\tS S L\nT\tL\nS S S S S T\tT\tS S T\tS S L\nT\tL\nS S S S S T\tS S S S T\tL\nT\tL\nS S L\nL\nL\n'
>>> whitespace.run(s)
Hello, World!>>>
This could be very interesting if we could call the interpreter within python's code, like
Right now we can do this with subprocess, but it's kind of externalizing the thing.
Thank you for the interpreter tho.