mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
logout syntex err line
fix parse err on complex list
This commit is contained in:
parent
b4f563cfe3
commit
546daaabe0
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -11,7 +11,7 @@
|
|||||||
"program": "${workspaceFolder}/build/test/pikascript_test",
|
"program": "${workspaceFolder}/build/test/pikascript_test",
|
||||||
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
||||||
"args": [
|
"args": [
|
||||||
// "--gtest_filter=pikaMain.mem_now"
|
"--gtest_filter=parser.return_list"
|
||||||
],
|
],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
|
@ -370,7 +370,8 @@ uint8_t Parser_checkIsDirect(char* str) {
|
|||||||
Args buffs = {0};
|
Args buffs = {0};
|
||||||
uint8_t res = 0;
|
uint8_t res = 0;
|
||||||
pika_assert(NULL != str);
|
pika_assert(NULL != str);
|
||||||
if (Cursor_isContain(str, TOKEN_operator, "=")) {
|
char* left = Cursor_splitCollect(&buffs, str, "=", 1);
|
||||||
|
if (!strEqu(left, str)) {
|
||||||
res = 1;
|
res = 1;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@ -2607,7 +2608,7 @@ static char* _Parser_linesToBytesOrAsm(Args* outBuffs,
|
|||||||
parse_after:
|
parse_after:
|
||||||
if (NULL == single_ASM) {
|
if (NULL == single_ASM) {
|
||||||
out_ASM = NULL;
|
out_ASM = NULL;
|
||||||
pika_platform_printf(" -> %s\r\n", line);
|
pika_platform_printf("------\r\n%s\r\n------\r\n", line);
|
||||||
strsDeinit(&buffs);
|
strsDeinit(&buffs);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -5388,6 +5388,27 @@ TEST(parser, while_try_while) {
|
|||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(parser, return_list) {
|
||||||
|
pikaMemInfo.heapUsedMax = 0;
|
||||||
|
Args* buffs = New_strBuff();
|
||||||
|
char* lines =
|
||||||
|
"return [\n"
|
||||||
|
" ui.Text(\n"
|
||||||
|
" align=ui.ALIGN.CENTER\n"
|
||||||
|
" ),\n"
|
||||||
|
" ui.Button(\n"
|
||||||
|
" onclick=self.onclick_next\n"
|
||||||
|
" )\n"
|
||||||
|
"]\n";
|
||||||
|
printf("%s\r\n", lines);
|
||||||
|
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||||
|
printf("%s", pikaAsm);
|
||||||
|
// EXPECT_STREQ(pikaAsm,
|
||||||
|
// "B0\n");
|
||||||
|
args_deinit(buffs);
|
||||||
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TEST_END
|
TEST_END
|
@ -1103,7 +1103,6 @@ TEST(pikaMain, syntax_err_1) {
|
|||||||
obj_run(pikaMain, "print('testtest)\n");
|
obj_run(pikaMain, "print('testtest)\n");
|
||||||
/* assert */
|
/* assert */
|
||||||
EXPECT_STREQ(log_buff[0], "Error: Syntax error.\r\n");
|
EXPECT_STREQ(log_buff[0], "Error: Syntax error.\r\n");
|
||||||
EXPECT_STREQ(log_buff[1], "BEGIN\r\n");
|
|
||||||
/* deinit */
|
/* deinit */
|
||||||
obj_deinit(pikaMain);
|
obj_deinit(pikaMain);
|
||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
@ -1438,10 +1437,6 @@ TEST(pikaMain, not_4_space) {
|
|||||||
/* collect */
|
/* collect */
|
||||||
/* assert */
|
/* assert */
|
||||||
EXPECT_STREQ(log_buff[0], "Error: Syntax error.\r\n");
|
EXPECT_STREQ(log_buff[0], "Error: Syntax error.\r\n");
|
||||||
EXPECT_STREQ(
|
|
||||||
log_buff[1],
|
|
||||||
"IndentationError: unexpected indent, only support 4 spaces\r\n");
|
|
||||||
EXPECT_STREQ(log_buff[2], "BEGIN\r\n");
|
|
||||||
/* deinit */
|
/* deinit */
|
||||||
obj_deinit(pikaMain);
|
obj_deinit(pikaMain);
|
||||||
/* mem check */
|
/* mem check */
|
||||||
|
@ -9,30 +9,32 @@ class MainContainer(ui.Container):
|
|||||||
mem.now()
|
mem.now()
|
||||||
|
|
||||||
def build(self):
|
def build(self):
|
||||||
text = ui.Text(
|
return [
|
||||||
text='Hello Page1',
|
ui.Text(
|
||||||
align=ui.ALIGN.CENTER
|
text='Hello Page1',
|
||||||
)
|
align=ui.ALIGN.CENTER
|
||||||
btn = ui.Button(
|
),
|
||||||
text='Next',
|
ui.Button(
|
||||||
align=ui.ALIGN.CENTER,
|
text='Next',
|
||||||
pos=(0, 50),
|
align=ui.ALIGN.CENTER,
|
||||||
height=30,
|
pos=(0, 50),
|
||||||
width=80,
|
height=30,
|
||||||
onclick=self.onclick_next
|
width=80,
|
||||||
)
|
onclick=self.onclick_next
|
||||||
return [text, btn]
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class Page1(ui.Page):
|
class Page1(ui.Page):
|
||||||
def build(self):
|
def build(self):
|
||||||
mainCtn = MainContainer(
|
return [
|
||||||
width=300,
|
MainContainer(
|
||||||
height=200,
|
width=300,
|
||||||
pos=(0, 50)
|
height=200,
|
||||||
)
|
pos=(0, 50)
|
||||||
title = ui.Text("Title")
|
),
|
||||||
return [mainCtn, title]
|
ui.Text("Title")
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class Page2(ui.Page):
|
class Page2(ui.Page):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user