mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
syantex check for 'class' 'def'
This commit is contained in:
parent
1e2529ae9b
commit
874f3ff7ed
@ -2523,6 +2523,55 @@ TEST(pikaMain, syantex_issue123lkjxi) {
|
||||
obj_run(pikaMain, lines);
|
||||
/* collect */
|
||||
/* assert */
|
||||
EXPECT_STREQ(log_buff[0], "[error]: Syntax error.\r\n");
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(pikaMain, syantex_issue_fae13) {
|
||||
char* lines = "for i < 3\n";
|
||||
/* init */
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
obj_run(pikaMain, lines);
|
||||
/* collect */
|
||||
/* assert */
|
||||
EXPECT_STREQ(log_buff[0], "[error]: Syntax error.\r\n");
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(pikaMain, syantex_issue_1289341) {
|
||||
char* lines = "class lkj\n";
|
||||
/* init */
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
obj_run(pikaMain, lines);
|
||||
/* collect */
|
||||
/* assert */
|
||||
EXPECT_STREQ(log_buff[0], "[error]: Syntax error.\r\n");
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(pikaMain, syantex_issue_183571) {
|
||||
char* lines = "def test\n";
|
||||
/* init */
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
obj_run(pikaMain, lines);
|
||||
/* collect */
|
||||
/* assert */
|
||||
EXPECT_STREQ(log_buff[0], "[error]: Syntax error.\r\n");
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
|
@ -1737,6 +1737,12 @@ AST* AST_parseLine(char* line, Stack* block_stack) {
|
||||
if (strIsStartWith(line_start, "for ")) {
|
||||
Args* list_buffs = New_strBuff();
|
||||
char* line_buff = strsCopy(list_buffs, line_start + 4);
|
||||
if (strCountSign(line_buff, ':') < 1) {
|
||||
args_deinit(list_buffs);
|
||||
obj_deinit(ast);
|
||||
ast = NULL;
|
||||
goto exit;
|
||||
}
|
||||
char* arg_in = strsPopToken(list_buffs, line_buff, ' ');
|
||||
AST_setThisNode(ast, "arg_in", arg_in);
|
||||
strsPopToken(list_buffs, line_buff, ' ');
|
||||
@ -1840,6 +1846,11 @@ AST* AST_parseLine(char* line, Stack* block_stack) {
|
||||
if (strIsStartWith(line_start, (char*)"def ")) {
|
||||
stmt = "";
|
||||
char* declear = strsCut(&buffs, line_start, ' ', ':');
|
||||
if (NULL == declear) {
|
||||
obj_deinit(ast);
|
||||
ast = NULL;
|
||||
goto exit;
|
||||
}
|
||||
declear = strsGetCleanCmd(&buffs, declear);
|
||||
AST_setThisNode(ast, "block", "def");
|
||||
AST_setThisNode(ast, "declear", declear);
|
||||
@ -1851,6 +1862,11 @@ AST* AST_parseLine(char* line, Stack* block_stack) {
|
||||
if (strIsStartWith(line_start, (char*)"class ")) {
|
||||
stmt = "";
|
||||
char* declear = strsCut(&buffs, line_start, ' ', ':');
|
||||
if (NULL == declear) {
|
||||
obj_deinit(ast);
|
||||
ast = NULL;
|
||||
goto exit;
|
||||
}
|
||||
declear = strsGetCleanCmd(&buffs, declear);
|
||||
AST_setThisNode(ast, "block", "class");
|
||||
AST_setThisNode(ast, "declear", declear);
|
||||
|
Loading…
x
Reference in New Issue
Block a user