Updated run_prompt to handle multiline statements#50
Conversation
Previously multiline statements were not possible because the scanner automatically appends the EOF token
Originally I thought fixing this might involve complicate syntax checking like makin sure that all '(' are
closed etc.
I think this solution is the simplest to implement, that is every statement is ended with a empty input
(newline).
| while True: | ||
| line = input("$ : ") | ||
| statement = line | ||
| while line: |
There was a problem hiding this comment.
I think its fine for now just not a nice user experience to press enter 2 times... An alternative might be to allow a specific keybinding (shift+enter) to insert a newline to stdin and stdout. Otherwise we can also implement something along these lines
while line.endsWith('{'):
...This way it adds a newline when needed not everytime.
There was a problem hiding this comment.
yes but what about
1 ==
1
;
There is just to many edge cases
There was a problem hiding this comment.
but shift enter thing sounds nice
There was a problem hiding this comment.
Idk I feel like that should be an error lol, or maybe we make it so it waits until ;?
There was a problem hiding this comment.
I think its fine for now just not a nice user experience to press enter 2 times... An alternative might be to allow a specific keybinding (shift+enter) to insert a newline to
stdinandstdout. Otherwise we can also implement something along these lineswhile line.endsWith('{'): ...This way it adds a newline when needed not everytime.
It seems that detecting shift+enter is not the easiest because it's platform dependent, with there being difficulty covering major systems (I'm personally using Ubuntu WSL and the most commonly used library doesn't support it)
Previously multiline statements were not possible because the scanner automatically appends the EOF token
Originally I thought fixing this might involve complicate syntax checking like makin sure that all '(' are
closed etc.
I think this solution is the simplest to implement, that is that: every statement is ended with a empty input
(newline).