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.
This commit is contained in:
Damien George
2014-04-08 11:04:29 +00:00
parent 72d70cb045
commit 97790455fe
7 changed files with 78 additions and 68 deletions

View File

@@ -146,17 +146,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 = strjoin(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 = strjoin(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);