aboutsummaryrefslogtreecommitdiff
path: root/windows
diff options
context:
space:
mode:
authorDamien George2014-04-08 11:04:29 +0000
committerDamien George2014-04-08 11:04:29 +0000
commit97790455fe10c5fb22bc3edde2b43474ce0dbaad (patch)
treeb887205c456731d7f4d92837d6ab19be183bb16f /windows
parent72d70cb0455c61ee963d9063bd42a8b0f6c80789 (diff)
Improve REPL detecting when input needs to continue.
Full CPython compatibility with this requires actually parsing the input so far collected, and if it fails parsing due to lack of tokens, then continue collecting input. It's not worth doing it this way. Not having compatibility at this level does not hurt the goals of Micro Python.
Diffstat (limited to 'windows')
-rw-r--r--windows/main.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/windows/main.c b/windows/main.c
index 36d98f73d..5ba21eef3 100644
--- a/windows/main.c
+++ b/windows/main.c
@@ -126,17 +126,15 @@ static void do_repl(void) {
// EOF
return;
}
- if (mp_repl_is_compound_stmt(line)) {
- for (;;) {
- char *line2 = prompt("... ");
- if (line2 == NULL || strlen(line2) == 0) {
- break;
- }
- char *line3 = str_join(line, '\n', line2);
- free(line);
- free(line2);
- line = line3;
+ while (mp_repl_continue_with_input(line)) {
+ char *line2 = prompt("... ");
+ if (line2 == NULL) {
+ break;
}
+ char *line3 = str_join(line, '\n', line2);
+ free(line);
+ free(line2);
+ line = line3;
}
mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, line, strlen(line), false);