parse a = b[c] is ok

This commit is contained in:
lyon 2022-01-17 20:25:32 +08:00
parent 52cd909fdd
commit 827c70bb08
16 changed files with 19 additions and 10 deletions

0
port/linux/api-make-linux.sh Normal file → Executable file
View File

0
port/linux/api-make-win10.sh Normal file → Executable file
View File

0
port/linux/api-make.sh Normal file → Executable file
View File

0
port/linux/ci_benchmark.sh Normal file → Executable file
View File

0
port/linux/gtest.sh Normal file → Executable file
View File

0
port/linux/init.sh Normal file → Executable file
View File

0
port/linux/install_dependency.sh Normal file → Executable file
View File

0
port/linux/make.sh Normal file → Executable file
View File

0
port/linux/pkg-push.sh Normal file → Executable file
View File

0
port/linux/pull-core.sh Normal file → Executable file
View File

0
port/linux/push-core.sh Normal file → Executable file
View File

0
port/linux/run.sh Normal file → Executable file
View File

0
port/linux/test-banchmark.sh Normal file → Executable file
View File

View File

@ -1807,11 +1807,13 @@ TEST(parser, __get__) {
printf("%s", lines);
char* pikaAsm = Parser_multiLineToAsm(buffs, (char*)lines);
printf("%s", pikaAsm);
// EXPECT_STREQ(pikaAsm,
// "B0\n"
// "1 STR [Info]: in Python config...\n"
// "0 RUN print\n"
// );
EXPECT_STREQ(pikaAsm,
"B0\n"
"1 REF b\n"
"1 REF c\n"
"0 RUN __get__\n"
"0 OUT a\n"
);
args_deinit(buffs);
EXPECT_EQ(pikaMemNow(), 0);
}

0
port/linux/update-compiler.sh Normal file → Executable file
View File

View File

@ -623,11 +623,18 @@ char* Parser_solveRightBranckets(Args* outBuffs, char* right) {
pyload2 = Lexer_getTokenPyload(token2);
/* matched [] */
if ((TOKEN_devider == token_type1) && (strEqu(pyload1, "["))) {
} else if ((TOKEN_devider == token_type1) &&
(strEqu(pyload1, "]"))) {
if ((TOKEN_devider == token_type2) && (strEqu(pyload2, "["))) {
args_setStr(buffs, "obj", pyload1);
} else if ((TOKEN_devider == token_type2) &&
(strEqu(pyload2, "]"))) {
args_setStr(buffs, "index", pyload1);
right_arg = arg_strAppend(right_arg, "__get__(");
right_arg = arg_strAppend(right_arg, args_getStr(buffs, "obj"));
right_arg = arg_strAppend(right_arg, ",");
right_arg =
arg_strAppend(right_arg, args_getStr(buffs, "index"));
right_arg = arg_strAppend(right_arg, ")");
} else {
right_arg = arg_strAppend(right_arg, pyload1);
}
args_deinit(token_buffs);
}
@ -689,7 +696,7 @@ AST* AST_parseStmt(AST* ast, char* stmt) {
if (STMT_method == stmtType) {
method = strsGetFirstToken(buffs, right, '(');
obj_setStr(ast, (char*)"method", method);
char* subStmts = strsCut(buffs, stmt, '(', ')');
char* subStmts = strsCut(buffs, right, '(', ')');
while (1) {
char* subStmt =
strsPopTokenWithSkip(buffs, subStmts, ',', '(', ')');