summaryrefslogtreecommitdiffstatshomepage
path: root/py/repl.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-07 13:01:30 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-07 13:01:30 +0100
commita28507ab2bbf872ec2e0193997d81e20f7ae404c (patch)
treeecb5e18320ef44bb2cd136bea919490a70633693 /py/repl.c
parent34ba06b076b42e698a159526b16f283aa87f58ab (diff)
downloadmicropython-a28507ab2bbf872ec2e0193997d81e20f7ae404c.tar.gz
micropython-a28507ab2bbf872ec2e0193997d81e20f7ae404c.zip
py: Detect unmatched tripple quote in repl helper.
Diffstat (limited to 'py/repl.c')
-rw-r--r--py/repl.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/py/repl.c b/py/repl.c
index 412ab20081..bca1be584e 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -29,10 +29,11 @@ bool mp_repl_is_compound_stmt(const char *line) {
return true;
}
- // also "compound" if unmatched open bracket
+ // also "compound" if unmatched open bracket or triple quote
int n_paren = 0;
int n_brack = 0;
int n_brace = 0;
+ int in_triple_quote = 0;
for (const char *l = line; *l; l++) {
switch (*l) {
case '(': n_paren += 1; break;
@@ -41,9 +42,15 @@ bool mp_repl_is_compound_stmt(const char *line) {
case ']': n_brack -= 1; break;
case '{': n_brace += 1; break;
case '}': n_brace -= 1; break;
+ case '"':
+ if (l[1] == '"' && l[2] == '"') {
+ l += 2;
+ in_triple_quote = 1 - in_triple_quote;
+ }
+ break;
}
}
- return n_paren > 0 || n_brack > 0 || n_brace > 0;
+ return n_paren > 0 || n_brack > 0 || n_brace > 0 || in_triple_quote != 0;
}
#endif // MICROPY_ENABLE_REPL_HELPERS