diff --git a/HISTORY b/HISTORY index bff505c..81ec61f 100755 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,7 @@ +May. 14 2017 +Added a clear_parser parameter to the mb_run function +Added an extra end of running checking after stepped + May. 13 2017 Added an MB_ENABLE_FULL_ERROR macro diff --git a/MY-BASIC Quick Reference.pdf b/MY-BASIC Quick Reference.pdf index 921c173..37b9d67 100644 Binary files a/MY-BASIC Quick Reference.pdf and b/MY-BASIC Quick Reference.pdf differ diff --git a/core/my_basic.c b/core/my_basic.c index e45461d..df6f99f 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -10180,6 +10180,7 @@ static int _execute_statement(mb_interpreter_t* s, _ls_node_t** l, bool_t force_ _running_context_t* running = 0; _ls_node_t* sub_stack = 0; bool_t skip_to_eoi = true; + bool_t end_of_ast = false; mb_assert(s && l); @@ -10359,10 +10360,18 @@ _exit: *l = ast; + if(!ast) { + ast = _ls_back(s->ast); + end_of_ast = true; + } + do { int ret = _stepped(s, ast); if(result == MB_FUNC_OK) result = ret; + + if(end_of_ast && ast && ast->next) /* May be changed when stepping */ + *l = ast->next; } while(0); return result; @@ -13221,7 +13230,7 @@ _exit: } /* Run the current AST */ -int mb_run(struct mb_interpreter_t* s) { +int mb_run(struct mb_interpreter_t* s, bool_t clear_parser) { int result = MB_FUNC_OK; _ls_node_t* ast = 0; @@ -13248,7 +13257,8 @@ int mb_run(struct mb_interpreter_t* s) { #endif /* MB_ENABLE_CLASS */ } - _destroy_parsing_context(&s->parsing_context); + if(clear_parser) + _destroy_parsing_context(&s->parsing_context); s->handled_error = false; diff --git a/core/my_basic.h b/core/my_basic.h index 96ecff3..a924785 100755 --- a/core/my_basic.h +++ b/core/my_basic.h @@ -648,7 +648,7 @@ MBAPI int mb_eval_routine(struct mb_interpreter_t* s, void** l, mb_value_t val, MBAPI int mb_load_string(struct mb_interpreter_t* s, const char* l, bool_t reset/* = true*/); MBAPI int mb_load_file(struct mb_interpreter_t* s, const char* f); -MBAPI int mb_run(struct mb_interpreter_t* s); +MBAPI int mb_run(struct mb_interpreter_t* s, bool_t clear_parser/* = true*/); MBAPI int mb_suspend(struct mb_interpreter_t* s, void** l); MBAPI int mb_schedule_suspend(struct mb_interpreter_t* s, int t);