fixed a test case

This commit is contained in:
hyung-hwan 2020-11-09 16:32:34 +00:00
parent 097a6c92f2
commit 93aa76e104
2 changed files with 30 additions and 35 deletions

View File

@ -2967,7 +2967,7 @@ static hawk_nde_t* parse_next (hawk_t* hawk, const hawk_loc_t* xloc)
} }
nde = (hawk_nde_next_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); nde = (hawk_nde_next_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde));
if (nde == HAWK_NULL) if (HAWK_UNLIKELY(!nde))
{ {
ADJERR_LOC (hawk, xloc); ADJERR_LOC (hawk, xloc);
return HAWK_NULL; return HAWK_NULL;
@ -2978,8 +2978,7 @@ static hawk_nde_t* parse_next (hawk_t* hawk, const hawk_loc_t* xloc)
return (hawk_nde_t*)nde; return (hawk_nde_t*)nde;
} }
static hawk_nde_t* parse_nextfile ( static hawk_nde_t* parse_nextfile (hawk_t* hawk, const hawk_loc_t* xloc, int out)
hawk_t* hawk, const hawk_loc_t* xloc, int out)
{ {
hawk_nde_nextfile_t* nde; hawk_nde_nextfile_t* nde;
@ -2995,7 +2994,7 @@ static hawk_nde_t* parse_nextfile (
} }
nde = (hawk_nde_nextfile_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); nde = (hawk_nde_nextfile_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde));
if (nde == HAWK_NULL) if (HAWK_UNLIKELY(!nde))
{ {
ADJERR_LOC (hawk, xloc); ADJERR_LOC (hawk, xloc);
return HAWK_NULL; return HAWK_NULL;
@ -3036,7 +3035,7 @@ static hawk_nde_t* parse_delete (hawk_t* hawk, const hawk_loc_t* xloc)
dloc = hawk->tok.loc; dloc = hawk->tok.loc;
var = parse_primary_ident(hawk, &dloc); var = parse_primary_ident(hawk, &dloc);
if (var == HAWK_NULL) goto oops; if (HAWK_UNLIKELY(!var)) goto oops;
if ((type == HAWK_NDE_DELETE && !is_var(var)) || if ((type == HAWK_NDE_DELETE && !is_var(var)) ||
(type == HAWK_NDE_RESET && !is_plain_var(var))) (type == HAWK_NDE_RESET && !is_plain_var(var)))
@ -3057,7 +3056,7 @@ static hawk_nde_t* parse_delete (hawk_t* hawk, const hawk_loc_t* xloc)
} }
nde = (hawk_nde_delete_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); nde = (hawk_nde_delete_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde));
if (nde == HAWK_NULL) if (HAWK_UNLIKELY(!nde))
{ {
ADJERR_LOC (hawk, xloc); ADJERR_LOC (hawk, xloc);
goto oops; goto oops;
@ -3083,17 +3082,12 @@ static hawk_nde_t* parse_print (hawk_t* hawk, const hawk_loc_t* xloc)
hawk_nde_type_t type; hawk_nde_type_t type;
hawk_loc_t eloc; hawk_loc_t eloc;
HAWK_ASSERT (hawk->ptok.type == TOK_PRINT || HAWK_ASSERT (hawk->ptok.type == TOK_PRINT || hawk->ptok.type == TOK_PRINTF);
hawk->ptok.type == TOK_PRINTF);
type = (hawk->ptok.type == TOK_PRINT)? type = (hawk->ptok.type == TOK_PRINT)? HAWK_NDE_PRINT: HAWK_NDE_PRINTF;
HAWK_NDE_PRINT: HAWK_NDE_PRINTF;
if (!MATCH_TERMINATOR(hawk) && if (!MATCH_TERMINATOR(hawk) && !MATCH(hawk,TOK_GT) &&
!MATCH(hawk,TOK_GT) && !MATCH(hawk,TOK_RS) && !MATCH(hawk,TOK_BOR) && !MATCH(hawk,TOK_LOR))
!MATCH(hawk,TOK_RS) &&
!MATCH(hawk,TOK_BOR) &&
!MATCH(hawk,TOK_LOR))
{ {
hawk_nde_t* args_tail; hawk_nde_t* args_tail;
hawk_nde_t* tail_prev; hawk_nde_t* tail_prev;
@ -3398,14 +3392,14 @@ static hawk_nde_t* parse_statement_nb (
nde = parse_expr_withdc(hawk, xloc); nde = parse_expr_withdc(hawk, xloc);
} }
if (nde == HAWK_NULL) return HAWK_NULL; if (HAWK_UNLIKELY(!nde)) return HAWK_NULL;
if (MATCH_TERMINATOR_NORMAL(hawk)) if (MATCH_TERMINATOR_NORMAL(hawk))
{ {
/* check if a statement ends with a semicolon or <NL> */ /* check if a statement ends with a semicolon or <NL> */
if (get_token(hawk) <= -1) if (get_token(hawk) <= -1)
{ {
if (nde != HAWK_NULL) hawk_clrpt (hawk, nde); if (nde) hawk_clrpt (hawk, nde);
return HAWK_NULL; return HAWK_NULL;
} }
} }
@ -3416,7 +3410,7 @@ static hawk_nde_t* parse_statement_nb (
} }
else else
{ {
if (nde != HAWK_NULL) hawk_clrpt (hawk, nde); if (nde) hawk_clrpt (hawk, nde);
hawk_seterrnum (hawk, &hawk->ptok.loc, HAWK_ESTMEND); hawk_seterrnum (hawk, &hawk->ptok.loc, HAWK_ESTMEND);
return HAWK_NULL; return HAWK_NULL;
} }
@ -3438,7 +3432,7 @@ static hawk_nde_t* parse_statement (hawk_t* hawk, const hawk_loc_t* xloc)
{ {
/* null statement */ /* null statement */
nde = (hawk_nde_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde)); nde = (hawk_nde_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*nde));
if (!nde) if (HAWK_UNLIKELY(!nde))
{ {
ADJERR_LOC (hawk, xloc); ADJERR_LOC (hawk, xloc);
return HAWK_NULL; return HAWK_NULL;

View File

@ -244,6 +244,7 @@ function main()
{ {
@local bool, b, c; @local bool, b, c;
@reset(c);
bool = ((b = 1) in c); bool = ((b = 1) in c);
ensure (bool, 0, @SCRIPTNAME, @SCRIPTLINE); ensure (bool, 0, @SCRIPTNAME, @SCRIPTLINE);
ensure (b, 1, @SCRIPTNAME, @SCRIPTLINE); ensure (b, 1, @SCRIPTNAME, @SCRIPTLINE);