summaryrefslogtreecommitdiff
path: root/py/compile.h
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-06-24 17:02:58 +1000
committerDamien George <damien@micropython.org>2024-03-22 13:05:25 +1100
commit2b8e88c563e4bab53e3183d15f04795d645eea28 (patch)
tree5c3cc7fc56a799c6434c83f9e7429ccc7ef84302 /py/compile.h
parentacbdbcd95e6d953b08f0642a844c1808323e0b7c (diff)
py/compile: Add option to allow compiling top-level await.
Enabled by MICROPY_COMPILE_ALLOW_TOP_LEVEL_AWAIT. When enabled, this means that scope such as module-level functions and REPL statements can yield. The outer C code must then handle this yielded generator. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/compile.h')
-rw-r--r--py/compile.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/py/compile.h b/py/compile.h
index 5e0fd8b31..f9970a521 100644
--- a/py/compile.h
+++ b/py/compile.h
@@ -30,6 +30,11 @@
#include "py/parse.h"
#include "py/emitglue.h"
+#if MICROPY_COMP_ALLOW_TOP_LEVEL_AWAIT
+// set to `true` to allow top-level await expressions
+extern bool mp_compile_allow_top_level_await;
+#endif
+
// the compiler will raise an exception if an error occurred
// the compiler will clear the parse tree before it returns
// mp_globals_get() will be used for the context