From 1b0f29781c78f13fe584fe9680d3a4c687cce6df Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 14 Nov 2022 17:25:05 +0800 Subject: [PATCH] up --- src/compiler.h | 5 +++-- tests/4.py | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 tests/4.py diff --git a/src/compiler.h b/src/compiler.h index 0a5a26d3..1f060558 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -757,12 +757,13 @@ __LISTCOMP: consumeEndStatement(); } else if(match(TK("label"))){ if(mode() != EXEC_MODE) syntaxError("'label' is only available in EXEC_MODE"); - consume(TK("@id")); + consume(TK(".")); consume(TK("@id")); getCode()->addLabel(parser->previous.str()); consumeEndStatement(); } else if(match(TK("goto"))){ + // https://entrian.com/goto/ if(mode() != EXEC_MODE) syntaxError("'goto' is only available in EXEC_MODE"); - consume(TK("@id")); + consume(TK(".")); consume(TK("@id")); emitCode(OP_LOAD_CONST, getCode()->addConst(vm->PyStr(parser->previous.str()))); emitCode(OP_GOTO); consumeEndStatement(); diff --git a/tests/4.py b/tests/4.py new file mode 100644 index 00000000..7067b3c6 --- /dev/null +++ b/tests/4.py @@ -0,0 +1,7 @@ +for i in range(100): + for j in range(100): + print(i, j) + goto .end + +label .end +print("END") \ No newline at end of file