mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
debug += for parser
This commit is contained in:
parent
5bf39388c0
commit
31e45abe64
@ -1064,4 +1064,39 @@ TEST(parser, pop_by_str) {
|
||||
EXPECT_STREQ((char*)"3(>=)2", token1);
|
||||
EXPECT_STREQ((char*)"29", token2);
|
||||
args_deinit(buffs);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(parser, mm) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"a = a ** -1\n";
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_multiLineToAsm(buffs, (char*)lines);
|
||||
printf("%s", pikaAsm);
|
||||
EXPECT_STREQ(pikaAsm,(char *)
|
||||
"B0\n"
|
||||
"1 REF a\n"
|
||||
"1 NUM -1\n"
|
||||
"0 OPT **\n"
|
||||
"0 OUT a\n"
|
||||
);
|
||||
args_deinit(buffs);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(parser, self_inc) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = (char*)"a += -1\n";
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_multiLineToAsm(buffs, (char*)lines);
|
||||
printf("%s", pikaAsm);
|
||||
EXPECT_STREQ(pikaAsm,(char *)
|
||||
"B0\n"
|
||||
"1 REF a\n"
|
||||
"1 NUM -1\n"
|
||||
"0 OPT +=\n"
|
||||
);
|
||||
args_deinit(buffs);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
@ -188,7 +188,9 @@ uint8_t Parser_checkIsDirect(char* str) {
|
||||
/* include '0' */
|
||||
uint32_t size = strGetSize(str) + 1;
|
||||
for (int i = 1; i + 1 < size; i++) {
|
||||
if ((str[i - 1] != '=') && (str[i] == '=') && (str[i + 1] != '=')) {
|
||||
if ((str[i - 1] != '=') && (str[i - 1] != '+') && (str[i - 1] != '-') &&
|
||||
(str[i - 1] != '*') && (str[i - 1] != '/') && (str[i + 1] != '=') &&
|
||||
(str[i] == '=')) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -510,8 +512,8 @@ char* Lexer_getOperator(Args* outBuffs, char* stmt) {
|
||||
"<=", ">", ">=", "!=", "==", "%=", "/=",
|
||||
"//=", "-=", "+=", "*=", "**="};
|
||||
for (int i = 0; i < sizeof(operators) / 4; i++) {
|
||||
if (Lexer_isContain(tokens, operators[i])) {
|
||||
operator= strsCopy(buffs, operators[i]);
|
||||
if (Lexer_isContain(tokens, (char*)operators[i])) {
|
||||
operator= strsCopy(buffs, (char*)operators[i]);
|
||||
}
|
||||
}
|
||||
/* out put */
|
||||
|
Loading…
x
Reference in New Issue
Block a user