diff --git a/port/linux/test/parse-test.cpp b/port/linux/test/parse-test.cpp index 18d65eb4c..633311e0b 100644 --- a/port/linux/test/parse-test.cpp +++ b/port/linux/test/parse-test.cpp @@ -1571,6 +1571,8 @@ TEST(parser, break_) { " if i = 1:\n" " break\n" " break \n" + " continue\n" + " continue \n" "\n"; printf("%s", lines); char* pikaAsm = Parser_multiLineToAsm(buffs, (char*)lines); @@ -1601,6 +1603,10 @@ TEST(parser, break_) { "0 BRK\n" "B2\n" "0 BRK\n" + "B2\n" + "0 CTN\n" + "B2\n" + "0 CTN\n" "B0\n" "0 JMP -1\n" "B0\n" diff --git a/src/PikaParser.c b/src/PikaParser.c index 4e7e4f313..23e99a845 100644 --- a/src/PikaParser.c +++ b/src/PikaParser.c @@ -803,6 +803,13 @@ AST* AST_parseLine(char* line, Stack* blockStack) { goto block_matched; } } + if (0 == strncmp(lineStart, (char*)"continue", 8)) { + if ((lineStart[8] == ' ') || (lineStart[8] == 0)) { + obj_setStr(ast, "continue", ""); + stmt = ""; + goto block_matched; + } + } if (strEqu(lineStart, (char*)"return")) { obj_setStr(ast, "return", ""); stmt = ""; @@ -1133,6 +1140,13 @@ char* AST_toPikaAsm(AST* ast, Args* buffs) { is_block_matched = 1; goto exit; } + if (obj_isArgExist(ast, "continue")) { + /* parse stmt ast */ + pikaAsm = AST_appandPikaAsm(ast, ast, runBuffs, pikaAsm); + pikaAsm = strsAppend(runBuffs, pikaAsm, "0 CTN\n"); + is_block_matched = 1; + goto exit; + } exit: if (!is_block_matched) { /* parse stmt ast */