logout syntex err line

fix parse err on complex list
This commit is contained in:
lyon 2023-02-25 16:17:59 +08:00
parent b4f563cfe3
commit 546daaabe0
5 changed files with 47 additions and 28 deletions

View File

@ -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}",

View File

@ -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;
}

View File

@ -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

View File

@ -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 */

View File

@ -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):