mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
combine 'break, continue'
This commit is contained in:
parent
7f9acba5dd
commit
18996e0fc5
@ -911,6 +911,21 @@ AST* AST_parseLine(char* line, Stack* block_stack) {
|
||||
}
|
||||
}
|
||||
|
||||
/* contral keyward */
|
||||
const char control_keywords[][9] = {"break", "continue"};
|
||||
for (int i = 0; i < sizeof(control_keywords) / 8; i++) {
|
||||
char* keyward = control_keywords[i];
|
||||
uint8_t keyward_size = strGetSize(keyward);
|
||||
if (strIsStartWith(line_start, keyward)) {
|
||||
if ((line_start[keyward_size] == ' ') ||
|
||||
(line_start[keyward_size] == 0)) {
|
||||
obj_setStr(ast, keyward, "");
|
||||
stmt = "";
|
||||
goto block_matched;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (strIsStartWith(line_start, "for ")) {
|
||||
Args* list_buffs = New_strBuff();
|
||||
char* line_buff = strsCopy(list_buffs, line_start + 4);
|
||||
@ -944,20 +959,6 @@ AST* AST_parseLine(char* line, Stack* block_stack) {
|
||||
}
|
||||
goto block_matched;
|
||||
}
|
||||
if (strIsStartWith(line_start, "break")) {
|
||||
if ((line_start[5] == ' ') || (line_start[5] == 0)) {
|
||||
obj_setStr(ast, "break", "");
|
||||
stmt = "";
|
||||
goto block_matched;
|
||||
}
|
||||
}
|
||||
if (strIsStartWith(line_start, "continue")) {
|
||||
if ((line_start[8] == ' ') || (line_start[8] == 0)) {
|
||||
obj_setStr(ast, "continue", "");
|
||||
stmt = "";
|
||||
goto block_matched;
|
||||
}
|
||||
}
|
||||
if (strEqu(line_start, "return")) {
|
||||
obj_setStr(ast, "return", "");
|
||||
stmt = "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user