blob: eaad6b5d72f94990e56cf2fbd835353398c37c53 [file] [log] [blame]
Damien George04b91472014-05-03 23:27:38 +01001/*
2 * This file is part of the Micro Python project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2013, 2014 Damien P. George
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
Dave Hylandsf14b92b2014-03-12 18:06:26 -070027#include <stdlib.h>
Dave Hylandsf14b92b2014-03-12 18:06:26 -070028#include <stdio.h>
Dave Hylands4f1b7fe2014-06-15 22:33:14 -070029#include <stdint.h>
Dave Hylandsf14b92b2014-03-12 18:06:26 -070030
Damien George2cf6dfa2015-01-01 21:06:20 +000031#include "py/nlr.h"
32#include "py/parsehelper.h"
33#include "py/compile.h"
34#include "py/runtime.h"
35#include "py/repl.h"
36#include "py/gc.h"
37#include "py/pfenv.h"
Paul Sokolovskybf195862014-12-20 20:45:01 +020038#ifdef MICROPY_HAL_H
Damien George7a37f642014-07-02 13:42:37 +010039#include MICROPY_HAL_H
Paul Sokolovskybf195862014-12-20 20:45:01 +020040#endif
Damien Georgec9fd6642014-03-29 14:20:05 +000041#include "readline.h"
Dave Hylandsf14b92b2014-03-12 18:06:26 -070042#include "pyexec.h"
Damien George951ed9d2014-07-20 13:57:43 +010043#include "pybstdio.h"
Damien Georged553be52014-04-17 18:03:27 +010044#include "genhdr/py-version.h"
Dave Hylandsf14b92b2014-03-12 18:06:26 -070045
Damien Georgef704e7f2014-03-24 12:23:37 +000046pyexec_mode_kind_t pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL;
47STATIC bool repl_display_debugging_info = 0;
Dave Hylandsf14b92b2014-03-12 18:06:26 -070048
Damien Georgebc1488a2014-10-26 15:39:22 +000049#define EXEC_FLAG_PRINT_EOF (1)
50#define EXEC_FLAG_ALLOW_DEBUGGING (2)
51#define EXEC_FLAG_IS_REPL (4)
52
Dave Hylandsf14b92b2014-03-12 18:06:26 -070053// parses, compiles and executes the code in the lexer
54// frees the lexer before returning
Damien Georgebc1488a2014-10-26 15:39:22 +000055// EXEC_FLAG_PRINT_EOF prints 2 EOF chars: 1 after normal output, 1 after exception output
56// EXEC_FLAG_ALLOW_DEBUGGING allows debugging info to be printed after executing the code
57// EXEC_FLAG_IS_REPL is used for REPL inputs (flag passed on to mp_compile)
58STATIC int parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t input_kind, int exec_flags) {
59 int ret = 0;
60
Dave Hylandsf14b92b2014-03-12 18:06:26 -070061 mp_parse_error_kind_t parse_error_kind;
62 mp_parse_node_t pn = mp_parse(lex, input_kind, &parse_error_kind);
Damien Georgea4c52c52014-12-05 19:35:18 +000063 qstr source_name = lex->source_name;
Dave Hylandsf14b92b2014-03-12 18:06:26 -070064
Damien Georgebc1488a2014-10-26 15:39:22 +000065 // check for parse error
Dave Hylandsf14b92b2014-03-12 18:06:26 -070066 if (pn == MP_PARSE_NODE_NULL) {
Damien Georgebc1488a2014-10-26 15:39:22 +000067 if (exec_flags & EXEC_FLAG_PRINT_EOF) {
68 stdout_tx_strn("\x04", 1);
69 }
Dave Hylandsf14b92b2014-03-12 18:06:26 -070070 mp_parse_show_exception(lex, parse_error_kind);
71 mp_lexer_free(lex);
Damien Georgebc1488a2014-10-26 15:39:22 +000072 goto finish;
Dave Hylandsf14b92b2014-03-12 18:06:26 -070073 }
74
75 mp_lexer_free(lex);
76
Damien Georgebc1488a2014-10-26 15:39:22 +000077 mp_obj_t module_fun = mp_compile(pn, source_name, MP_EMIT_OPT_NONE, exec_flags & EXEC_FLAG_IS_REPL);
Dave Hylandsf14b92b2014-03-12 18:06:26 -070078
Damien Georgebc1488a2014-10-26 15:39:22 +000079 // check for compile error
Damien Georgea91ac202014-10-05 19:01:34 +010080 if (mp_obj_is_exception_instance(module_fun)) {
Damien Georgebc1488a2014-10-26 15:39:22 +000081 if (exec_flags & EXEC_FLAG_PRINT_EOF) {
82 stdout_tx_strn("\x04", 1);
83 }
Paul Sokolovsky46c3ab22014-12-06 14:29:09 +020084 mp_obj_print_exception(printf_wrapper, NULL, module_fun);
Damien Georgebc1488a2014-10-26 15:39:22 +000085 goto finish;
Dave Hylandsf14b92b2014-03-12 18:06:26 -070086 }
87
Damien Georgebc1488a2014-10-26 15:39:22 +000088 // execute code
Dave Hylandsf14b92b2014-03-12 18:06:26 -070089 nlr_buf_t nlr;
Dave Hylandsf14b92b2014-03-12 18:06:26 -070090 uint32_t start = HAL_GetTick();
91 if (nlr_push(&nlr) == 0) {
Damien George5cbc9e02014-11-27 16:58:31 +000092 mp_hal_set_interrupt_char(CHAR_CTRL_C); // allow ctrl-C to interrupt us
Damien Georged17926d2014-03-30 13:35:08 +010093 mp_call_function_0(module_fun);
Damien George5cbc9e02014-11-27 16:58:31 +000094 mp_hal_set_interrupt_char(-1); // disable interrupt
Dave Hylandsf14b92b2014-03-12 18:06:26 -070095 nlr_pop();
Dave Hylands8d62bbd2014-10-21 23:04:38 -070096 ret = 1;
Damien Georgebc1488a2014-10-26 15:39:22 +000097 if (exec_flags & EXEC_FLAG_PRINT_EOF) {
98 stdout_tx_strn("\x04", 1);
99 }
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700100 } else {
101 // uncaught exception
102 // FIXME it could be that an interrupt happens just before we disable it here
Damien George5cbc9e02014-11-27 16:58:31 +0000103 mp_hal_set_interrupt_char(-1); // disable interrupt
Damien Georgebc1488a2014-10-26 15:39:22 +0000104 // print EOF after normal output
105 if (exec_flags & EXEC_FLAG_PRINT_EOF) {
106 stdout_tx_strn("\x04", 1);
107 }
Dave Hylands8d62bbd2014-10-21 23:04:38 -0700108 // check for SystemExit
Damien George3be69842014-10-22 19:13:28 +0100109 if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_SystemExit)) {
110 // at the moment, the value of SystemExit is unused
111 ret = PYEXEC_FORCED_EXIT;
112 } else {
Paul Sokolovsky46c3ab22014-12-06 14:29:09 +0200113 mp_obj_print_exception(printf_wrapper, NULL, (mp_obj_t)nlr.ret_val);
Damien George3be69842014-10-22 19:13:28 +0100114 ret = 0;
Dave Hylands8d62bbd2014-10-21 23:04:38 -0700115 }
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700116 }
117
118 // display debugging info if wanted
Damien Georgebc1488a2014-10-26 15:39:22 +0000119 if ((exec_flags & EXEC_FLAG_ALLOW_DEBUGGING) && repl_display_debugging_info) {
Damien George5cbc9e02014-11-27 16:58:31 +0000120 mp_uint_t ticks = HAL_GetTick() - start; // TODO implement a function that does this properly
121 printf("took " UINT_FMT " ms\n", ticks);
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700122 gc_collect();
123 // qstr info
124 {
Damien Georged03c6812014-10-05 21:51:54 +0100125 mp_uint_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700126 qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes);
Damien Georged03c6812014-10-05 21:51:54 +0100127 printf("qstr:\n n_pool=" UINT_FMT "\n n_qstr=" UINT_FMT "\n n_str_data_bytes=" UINT_FMT "\n n_total_bytes=" UINT_FMT "\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes);
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700128 }
129
130 // GC info
Paul Sokolovsky6aaccc42014-12-21 00:24:58 +0200131 gc_dump_info();
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700132 }
133
Damien Georgebc1488a2014-10-26 15:39:22 +0000134finish:
135 if (exec_flags & EXEC_FLAG_PRINT_EOF) {
136 stdout_tx_strn("\x04", 1);
137 }
138
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700139 return ret;
140}
141
Damien Georgef704e7f2014-03-24 12:23:37 +0000142int pyexec_raw_repl(void) {
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700143 vstr_t line;
144 vstr_init(&line, 32);
145
146raw_repl_reset:
Damien Georgef704e7f2014-03-24 12:23:37 +0000147 stdout_tx_str("raw REPL; CTRL-B to exit\r\n");
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700148
149 for (;;) {
150 vstr_reset(&line);
151 stdout_tx_str(">");
152 for (;;) {
153 char c = stdin_rx_chr();
Damien George5cbc9e02014-11-27 16:58:31 +0000154 if (c == CHAR_CTRL_A) {
Damien Georgef704e7f2014-03-24 12:23:37 +0000155 // reset raw REPL
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700156 goto raw_repl_reset;
Damien George5cbc9e02014-11-27 16:58:31 +0000157 } else if (c == CHAR_CTRL_B) {
Damien Georgef704e7f2014-03-24 12:23:37 +0000158 // change to friendly REPL
159 stdout_tx_str("\r\n");
160 vstr_clear(&line);
161 pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL;
162 return 0;
Damien George5cbc9e02014-11-27 16:58:31 +0000163 } else if (c == CHAR_CTRL_C) {
Damien Georgef704e7f2014-03-24 12:23:37 +0000164 // clear line
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700165 vstr_reset(&line);
Damien George5cbc9e02014-11-27 16:58:31 +0000166 } else if (c == CHAR_CTRL_D) {
Damien Georgef704e7f2014-03-24 12:23:37 +0000167 // input finished
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700168 break;
Damien Georged8b47d32014-04-03 22:11:43 +0100169 } else if (c <= 127) {
170 // let through any other ASCII character
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700171 vstr_add_char(&line, c);
172 }
173 }
174
Damien Georgef704e7f2014-03-24 12:23:37 +0000175 // indicate reception of command
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700176 stdout_tx_str("OK");
177
Damien Georgef704e7f2014-03-24 12:23:37 +0000178 if (line.len == 0) {
179 // exit for a soft reset
180 stdout_tx_str("\r\n");
181 vstr_clear(&line);
Dave Hylands8d62bbd2014-10-21 23:04:38 -0700182 return PYEXEC_FORCED_EXIT;
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700183 }
184
Damien Georgef704e7f2014-03-24 12:23:37 +0000185 mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, line.buf, line.len, 0);
Damien Georgeb0edec62014-05-10 17:48:46 +0100186 if (lex == NULL) {
Damien Georgebc1488a2014-10-26 15:39:22 +0000187 printf("\x04MemoryError\n\x04");
Damien Georgeb0edec62014-05-10 17:48:46 +0100188 } else {
Damien Georgebc1488a2014-10-26 15:39:22 +0000189 int ret = parse_compile_execute(lex, MP_PARSE_FILE_INPUT, EXEC_FLAG_PRINT_EOF);
Dave Hylands8d62bbd2014-10-21 23:04:38 -0700190 if (ret & PYEXEC_FORCED_EXIT) {
191 return ret;
192 }
Damien Georgeb0edec62014-05-10 17:48:46 +0100193 }
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700194 }
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700195}
196
Paul Sokolovsky87bc8e22015-01-15 10:46:27 +0200197#if MICROPY_REPL_EVENT_DRIVEN
198
199typedef struct _friendly_repl_t {
200 vstr_t line;
201 bool cont_line;
202} friendly_repl_t;
203
204friendly_repl_t repl;
205
206void pyexec_friendly_repl_init(void) {
207 vstr_init(&repl.line, 32);
208 repl.cont_line = false;
209 readline_init(&repl.line);
210 stdout_tx_str(">>> ");
211}
212
213void pyexec_friendly_repl_reset() {
214 repl.cont_line = false;
215 vstr_reset(&repl.line);
216 readline_init(&repl.line);
217}
218
219int pyexec_friendly_repl_process_char(int c) {
220 int ret = readline_process_char(c);
221
222 if (!repl.cont_line) {
223
224 if (ret == CHAR_CTRL_A) {
225 // change to raw REPL
226 pyexec_mode_kind = PYEXEC_MODE_RAW_REPL;
227 stdout_tx_str("\r\n");
228 vstr_clear(&repl.line);
229 return PYEXEC_SWITCH_MODE;
230 } else if (ret == CHAR_CTRL_B) {
231 // reset friendly REPL
232 stdout_tx_str("\r\n");
233 goto friendly_repl_reset;
234 } else if (ret == CHAR_CTRL_C) {
235 // break
236 stdout_tx_str("\r\n");
237 goto input_restart;
238 } else if (ret == CHAR_CTRL_D) {
239 // exit for a soft reset
240 stdout_tx_str("\r\n");
241 vstr_clear(&repl.line);
242 return PYEXEC_FORCED_EXIT;
243 } else if (vstr_len(&repl.line) == 0) {
244 //goto input_restart;
245 }
246
247 if (ret < 0) {
248 return 0;
249 }
250
Damien George827b0f72015-01-29 13:57:23 +0000251 if (!mp_repl_continue_with_input(vstr_null_terminated_str(&repl.line))) {
Paul Sokolovsky87bc8e22015-01-15 10:46:27 +0200252 goto exec;
253 }
254
Damien George0d3cb672015-01-28 23:43:01 +0000255 vstr_add_byte(&repl.line, '\n');
Paul Sokolovsky87bc8e22015-01-15 10:46:27 +0200256 repl.cont_line = true;
257 stdout_tx_str("... ");
258 readline_note_newline();
259 return 0;
260
261 } else {
262
263 if (ret == CHAR_CTRL_C) {
264 // cancel everything
265 stdout_tx_str("\r\n");
266 repl.cont_line = false;
267 goto input_restart;
268 } else if (ret == CHAR_CTRL_D) {
269 // stop entering compound statement
270 goto exec;
271 }
272
273 if (ret < 0) {
274 return 0;
275 }
276
Damien George827b0f72015-01-29 13:57:23 +0000277 if (mp_repl_continue_with_input(vstr_null_terminated_str(&repl.line))) {
Damien George0d3cb672015-01-28 23:43:01 +0000278 vstr_add_byte(&repl.line, '\n');
Paul Sokolovsky87bc8e22015-01-15 10:46:27 +0200279 stdout_tx_str("... ");
280 readline_note_newline();
281 return 0;
282 }
283
284exec: ;
285 mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, vstr_str(&repl.line), vstr_len(&repl.line), 0);
286 if (lex == NULL) {
287 printf("MemoryError\n");
288 } else {
289 int ret = parse_compile_execute(lex, MP_PARSE_SINGLE_INPUT, EXEC_FLAG_ALLOW_DEBUGGING | EXEC_FLAG_IS_REPL);
290 if (ret & PYEXEC_FORCED_EXIT) {
291 return ret;
292 }
293 }
294
295friendly_repl_reset: // TODO
296input_restart:
297 pyexec_friendly_repl_reset();
298 stdout_tx_str(">>> ");
299 return 0;
300 }
301}
302
303#else //MICROPY_REPL_EVENT_DRIVEN
304
Damien Georgef704e7f2014-03-24 12:23:37 +0000305int pyexec_friendly_repl(void) {
306 vstr_t line;
307 vstr_init(&line, 32);
308
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700309#if defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD
310 // in host mode, we enable the LCD for the repl
Damien Georged17926d2014-03-30 13:35:08 +0100311 mp_obj_t lcd_o = mp_call_function_0(mp_load_name(qstr_from_str("LCD")));
312 mp_call_function_1(mp_load_attr(lcd_o, qstr_from_str("light")), mp_const_true);
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700313#endif
314
Damien Georgef704e7f2014-03-24 12:23:37 +0000315friendly_repl_reset:
muxa75e3822014-06-27 00:35:53 +0200316 stdout_tx_str("Micro Python " MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE "; " MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME "\r\n");
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700317 stdout_tx_str("Type \"help()\" for more information.\r\n");
318
319 // to test ctrl-C
320 /*
321 {
322 uint32_t x[4] = {0x424242, 0xdeaddead, 0x242424, 0xdeadbeef};
323 for (;;) {
324 nlr_buf_t nlr;
325 printf("pyexec_repl: %p\n", x);
Damien George5cbc9e02014-11-27 16:58:31 +0000326 mp_hal_set_interrupt_char(CHAR_CTRL_C);
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700327 if (nlr_push(&nlr) == 0) {
328 for (;;) {
329 }
330 } else {
331 printf("break\n");
332 }
333 }
334 }
335 */
336
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700337 for (;;) {
Damien Georgebc1488a2014-10-26 15:39:22 +0000338 input_restart:
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700339 vstr_reset(&line);
340 int ret = readline(&line, ">>> ");
341
Damien George5cbc9e02014-11-27 16:58:31 +0000342 if (ret == CHAR_CTRL_A) {
Damien Georgef704e7f2014-03-24 12:23:37 +0000343 // change to raw REPL
344 stdout_tx_str("\r\n");
345 vstr_clear(&line);
346 pyexec_mode_kind = PYEXEC_MODE_RAW_REPL;
347 return 0;
Damien George5cbc9e02014-11-27 16:58:31 +0000348 } else if (ret == CHAR_CTRL_B) {
Damien Georgef704e7f2014-03-24 12:23:37 +0000349 // reset friendly REPL
350 stdout_tx_str("\r\n");
351 goto friendly_repl_reset;
Damien George5cbc9e02014-11-27 16:58:31 +0000352 } else if (ret == CHAR_CTRL_C) {
Damien Georgef704e7f2014-03-24 12:23:37 +0000353 // break
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700354 stdout_tx_str("\r\n");
355 continue;
Damien George5cbc9e02014-11-27 16:58:31 +0000356 } else if (ret == CHAR_CTRL_D) {
Damien Georgef704e7f2014-03-24 12:23:37 +0000357 // exit for a soft reset
358 stdout_tx_str("\r\n");
359 vstr_clear(&line);
Dave Hylands8d62bbd2014-10-21 23:04:38 -0700360 return PYEXEC_FORCED_EXIT;
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700361 } else if (vstr_len(&line) == 0) {
362 continue;
363 }
364
Damien George827b0f72015-01-29 13:57:23 +0000365 while (mp_repl_continue_with_input(vstr_null_terminated_str(&line))) {
Damien George0d3cb672015-01-28 23:43:01 +0000366 vstr_add_byte(&line, '\n');
Damien George50912e72015-01-20 11:55:10 +0000367 ret = readline(&line, "... ");
Damien George5cbc9e02014-11-27 16:58:31 +0000368 if (ret == CHAR_CTRL_C) {
Damien Georgebc1488a2014-10-26 15:39:22 +0000369 // cancel everything
370 stdout_tx_str("\r\n");
371 goto input_restart;
Damien George5cbc9e02014-11-27 16:58:31 +0000372 } else if (ret == CHAR_CTRL_D) {
Damien George97790452014-04-08 11:04:29 +0000373 // stop entering compound statement
374 break;
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700375 }
376 }
377
378 mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, vstr_str(&line), vstr_len(&line), 0);
Damien Georgeb0edec62014-05-10 17:48:46 +0100379 if (lex == NULL) {
380 printf("MemoryError\n");
381 } else {
Damien George50912e72015-01-20 11:55:10 +0000382 ret = parse_compile_execute(lex, MP_PARSE_SINGLE_INPUT, EXEC_FLAG_ALLOW_DEBUGGING | EXEC_FLAG_IS_REPL);
Dave Hylands8d62bbd2014-10-21 23:04:38 -0700383 if (ret & PYEXEC_FORCED_EXIT) {
384 return ret;
385 }
Damien Georgeb0edec62014-05-10 17:48:46 +0100386 }
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700387 }
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700388}
389
Paul Sokolovsky87bc8e22015-01-15 10:46:27 +0200390#endif //MICROPY_REPL_EVENT_DRIVEN
391
Damien George3be69842014-10-22 19:13:28 +0100392int pyexec_file(const char *filename) {
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700393 mp_lexer_t *lex = mp_lexer_new_from_file(filename);
394
395 if (lex == NULL) {
396 printf("could not open file '%s' for reading\n", filename);
397 return false;
398 }
399
Damien Georgebc1488a2014-10-26 15:39:22 +0000400 return parse_compile_execute(lex, MP_PARSE_FILE_INPUT, 0);
Dave Hylandsf14b92b2014-03-12 18:06:26 -0700401}
402
403mp_obj_t pyb_set_repl_info(mp_obj_t o_value) {
404 repl_display_debugging_info = mp_obj_get_int(o_value);
405 return mp_const_none;
406}
407
408MP_DEFINE_CONST_FUN_OBJ_1(pyb_set_repl_info_obj, pyb_set_repl_info);