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/boot/demo06-pikamain/pikascript_demo06-pikamain",
|
||||
"args": [
|
||||
// "--gtest_filter=pikaMain.mem_now"
|
||||
"--gtest_filter=parser.return_list"
|
||||
],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${workspaceFolder}",
|
||||
|
@ -370,7 +370,8 @@ uint8_t Parser_checkIsDirect(char* str) {
|
||||
Args buffs = {0};
|
||||
uint8_t res = 0;
|
||||
pika_assert(NULL != str);
|
||||
if (Cursor_isContain(str, TOKEN_operator, "=")) {
|
||||
char* left = Cursor_splitCollect(&buffs, str, "=", 1);
|
||||
if (!strEqu(left, str)) {
|
||||
res = 1;
|
||||
goto exit;
|
||||
}
|
||||
@ -2607,7 +2608,7 @@ static char* _Parser_linesToBytesOrAsm(Args* outBuffs,
|
||||
parse_after:
|
||||
if (NULL == single_ASM) {
|
||||
out_ASM = NULL;
|
||||
pika_platform_printf(" -> %s\r\n", line);
|
||||
pika_platform_printf("------\r\n%s\r\n------\r\n", line);
|
||||
strsDeinit(&buffs);
|
||||
goto exit;
|
||||
}
|
||||
|
@ -5388,6 +5388,27 @@ TEST(parser, while_try_while) {
|
||||
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
|
||||
|
||||
TEST_END
|
@ -1103,7 +1103,6 @@ TEST(pikaMain, syntax_err_1) {
|
||||
obj_run(pikaMain, "print('testtest)\n");
|
||||
/* assert */
|
||||
EXPECT_STREQ(log_buff[0], "Error: Syntax error.\r\n");
|
||||
EXPECT_STREQ(log_buff[1], "BEGIN\r\n");
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
@ -1438,10 +1437,6 @@ TEST(pikaMain, not_4_space) {
|
||||
/* collect */
|
||||
/* assert */
|
||||
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 */
|
||||
obj_deinit(pikaMain);
|
||||
/* mem check */
|
||||
|
@ -9,30 +9,32 @@ class MainContainer(ui.Container):
|
||||
mem.now()
|
||||
|
||||
def build(self):
|
||||
text = ui.Text(
|
||||
text='Hello Page1',
|
||||
align=ui.ALIGN.CENTER
|
||||
)
|
||||
btn = ui.Button(
|
||||
text='Next',
|
||||
align=ui.ALIGN.CENTER,
|
||||
pos=(0, 50),
|
||||
height=30,
|
||||
width=80,
|
||||
onclick=self.onclick_next
|
||||
)
|
||||
return [text, btn]
|
||||
return [
|
||||
ui.Text(
|
||||
text='Hello Page1',
|
||||
align=ui.ALIGN.CENTER
|
||||
),
|
||||
ui.Button(
|
||||
text='Next',
|
||||
align=ui.ALIGN.CENTER,
|
||||
pos=(0, 50),
|
||||
height=30,
|
||||
width=80,
|
||||
onclick=self.onclick_next
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class Page1(ui.Page):
|
||||
def build(self):
|
||||
mainCtn = MainContainer(
|
||||
width=300,
|
||||
height=200,
|
||||
pos=(0, 50)
|
||||
)
|
||||
title = ui.Text("Title")
|
||||
return [mainCtn, title]
|
||||
return [
|
||||
MainContainer(
|
||||
width=300,
|
||||
height=200,
|
||||
pos=(0, 50)
|
||||
),
|
||||
ui.Text("Title")
|
||||
]
|
||||
|
||||
|
||||
class Page2(ui.Page):
|
||||
|
Loading…
x
Reference in New Issue
Block a user