fix NULL handle

This commit is contained in:
lyon1998 2022-04-03 14:12:14 +08:00
parent 1fa8970fc1
commit 5e41b7f4db

View File

@ -665,13 +665,14 @@ char* Parser_solveBranckets(Args* outBuffs,
Arg* right_arg = arg_setStr(NULL, "", ""); Arg* right_arg = arg_setStr(NULL, "", "");
uint8_t is_in_brancket = 0; uint8_t is_in_brancket = 0;
args_setStr(&buffs, "index", ""); args_setStr(&buffs, "index", "");
char* tokens = Lexer_getTokens(&buffs, content); char* tokens;
/* exit when NULL */ /* exit when NULL */
if (NULL == content) { if (NULL == content) {
arg_deinit(right_arg); arg_deinit(right_arg);
right_arg = arg_setStr(right_arg, "", stmt); right_arg = arg_setStr(right_arg, "", stmt);
goto exit; goto exit;
} }
tokens = Lexer_getTokens(&buffs, content);
/* exit when no '[' ']' */ /* exit when no '[' ']' */
if (!Parser_isContainToken(tokens, TOKEN_devider, "[")) { if (!Parser_isContainToken(tokens, TOKEN_devider, "[")) {
/* not contain '[', return origin */ /* not contain '[', return origin */
@ -1010,7 +1011,7 @@ char* Parser_removeAnnotation(char* line) {
} }
AST* AST_parseLine(char* line, Stack* block_stack) { AST* AST_parseLine(char* line, Stack* block_stack) {
/* match block start keywords */ /* match block start keywords */
const char control_keywords[][9] = {"break", "continue"}; const char control_keywords[][9] = {"break", "continue"};
/* normal keyward */ /* normal keyward */
@ -1264,7 +1265,7 @@ static char* Parser_parsePyLines(Args* outBuffs,
uint16_t lines_index = 0; uint16_t lines_index = 0;
uint8_t is_in_multi_comment = 0; uint8_t is_in_multi_comment = 0;
char* out_ASM = NULL; char* out_ASM = NULL;
char* single_ASM; char* single_ASM;
uint32_t line_size = 0; uint32_t line_size = 0;
/* parse each line */ /* parse each line */
while (1) { while (1) {
@ -1408,8 +1409,8 @@ char* ASM_addBlockDeepth(AST* ast,
char* AST_toPikaASM(AST* ast, Args* outBuffs) { char* AST_toPikaASM(AST* ast, Args* outBuffs) {
Args buffs = {0}; Args buffs = {0};
char* pikaAsm = strsCopy(&buffs, ""); char* pikaAsm = strsCopy(&buffs, "");
QueueObj* exitBlock; QueueObj* exitBlock;
uint8_t is_block_matched; uint8_t is_block_matched;
if (NULL == ast) { if (NULL == ast) {
pikaAsm = NULL; pikaAsm = NULL;
goto exit; goto exit;