fixed a bug in printing a tree node of the HAWK_NDE_POS type
This commit is contained in:
parent
db77a97119
commit
84c0b37e94
@ -164,7 +164,7 @@ For this reason, there is no way to get the type name of a regular expressin lit
|
||||
A pragma item of the file scope can be placed in any source files.
|
||||
A pragma item of the global scope can appear only once thoughout the all source files.
|
||||
|
||||
| | Scope | Values | Description |
|
||||
| Name | Scope | Values | Description |
|
||||
|---------------|--------|---------------|--------------------------------------------------------|
|
||||
| implicit | file | on, off | allow undeclared variables |
|
||||
| multilinestr | file | on, off | allow a multiline string literal without continuation |
|
||||
@ -201,7 +201,7 @@ Alternatively, you may form an array before passing it to a function.
|
||||
|
||||
There are subtle differences when you put an expression for a position variable. In Hawk, most of the ambiguity issues are resolved if you enclose the expression inside parentheses.
|
||||
|
||||
| | HAWK | AWK |
|
||||
| Expression | HAWK | AWK |
|
||||
|--------------|---------------|-----------------|
|
||||
| $++$++i | syntax error | OK |
|
||||
| $(++$(++i)) | OK | syntax error |
|
||||
|
@ -4872,8 +4872,8 @@ static hawk_nde_t* parse_primary_positional (hawk_t* awk, const hawk_loc_t* xloc
|
||||
hawk_nde_pos_t* nde;
|
||||
hawk_loc_t ploc;
|
||||
|
||||
nde = (hawk_nde_pos_t*) hawk_callocmem (awk, HAWK_SIZEOF(*nde));
|
||||
if (nde == HAWK_NULL)
|
||||
nde = (hawk_nde_pos_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde));
|
||||
if (HAWK_UNLIKELY(!nde))
|
||||
{
|
||||
ADJERR_LOC (awk, xloc);
|
||||
goto oops;
|
||||
@ -4886,7 +4886,7 @@ static hawk_nde_t* parse_primary_positional (hawk_t* awk, const hawk_loc_t* xloc
|
||||
|
||||
ploc = awk->tok.loc;
|
||||
nde->val = parse_primary(awk, &ploc);
|
||||
if (!nde->val) goto oops;
|
||||
if (HAWK_UNLIKELY(!nde->val)) goto oops;
|
||||
|
||||
return (hawk_nde_t*)nde;
|
||||
|
||||
@ -4914,7 +4914,7 @@ static hawk_nde_t* parse_primary_lparen (hawk_t* awk, const hawk_loc_t* xloc)
|
||||
/* parse the sub-expression inside the parentheses */
|
||||
eloc = awk->tok.loc;
|
||||
nde = parse_expr_withdc(awk, &eloc);
|
||||
if (!nde) return HAWK_NULL;
|
||||
if (HAWK_UNLIKELY(!nde)) return HAWK_NULL;
|
||||
|
||||
/* parse subsequent expressions separated by a comma, if any */
|
||||
last = nde;
|
||||
@ -4932,7 +4932,7 @@ static hawk_nde_t* parse_primary_lparen (hawk_t* awk, const hawk_loc_t* xloc)
|
||||
|
||||
eloc = awk->tok.loc;
|
||||
tmp = parse_expr_withdc(awk, &eloc);
|
||||
if (!tmp) goto oops;
|
||||
if (HAWK_UNLIKELY(!tmp)) goto oops;
|
||||
|
||||
HAWK_ASSERT (tmp->next == HAWK_NULL);
|
||||
last->next = tmp;
|
||||
@ -4971,7 +4971,7 @@ static hawk_nde_t* parse_primary_lparen (hawk_t* awk, const hawk_loc_t* xloc)
|
||||
}
|
||||
|
||||
tmp = (hawk_nde_grp_t*)hawk_callocmem(awk, HAWK_SIZEOF(hawk_nde_grp_t));
|
||||
if (!tmp)
|
||||
if (HAWK_UNLIKELY(!tmp))
|
||||
{
|
||||
ADJERR_LOC (awk, xloc);
|
||||
goto oops;
|
||||
@ -5003,7 +5003,7 @@ static hawk_nde_t* parse_primary_getline (hawk_t* awk, const hawk_loc_t* xloc, i
|
||||
hawk_loc_t ploc;
|
||||
|
||||
nde = (hawk_nde_getline_t*)hawk_callocmem(awk, HAWK_SIZEOF(*nde));
|
||||
if (nde == HAWK_NULL) goto oops;
|
||||
if (HAWK_UNLIKELY(!nde)) goto oops;
|
||||
|
||||
nde->type = HAWK_NDE_GETLINE;
|
||||
nde->mbs = mbs;
|
||||
@ -5040,8 +5040,8 @@ static hawk_nde_t* parse_primary_getline (hawk_t* awk, const hawk_loc_t* xloc, i
|
||||
}
|
||||
|
||||
ploc = awk->tok.loc;
|
||||
nde->var = parse_primary (awk, &ploc);
|
||||
if (nde->var == HAWK_NULL) goto oops;
|
||||
nde->var = parse_primary(awk, &ploc);
|
||||
if (HAWK_UNLIKELY(!nde->var)) goto oops;
|
||||
|
||||
if (!is_var(nde->var) && nde->var->type != HAWK_NDE_POS)
|
||||
{
|
||||
@ -5063,8 +5063,8 @@ novar:
|
||||
ploc = awk->tok.loc;
|
||||
/* TODO: is this correct? */
|
||||
/*nde->in = parse_expr_withdc (awk, &ploc);*/
|
||||
nde->in = parse_primary (awk, &ploc);
|
||||
if (nde->in == HAWK_NULL) goto oops;
|
||||
nde->in = parse_primary(awk, &ploc);
|
||||
if (HAWK_UNLIKELY(!nde->in)) goto oops;
|
||||
|
||||
nde->in_type = HAWK_IN_FILE;
|
||||
}
|
||||
|
@ -678,8 +678,9 @@ static int print_expr (hawk_t* awk, hawk_nde_t* nde)
|
||||
|
||||
case HAWK_NDE_POS:
|
||||
{
|
||||
PUT_SRCSTR (awk, HAWK_T("$"));
|
||||
PUT_SRCSTR (awk, HAWK_T("$("));
|
||||
PRINT_EXPR (awk, ((hawk_nde_pos_t*)nde)->val);
|
||||
PUT_SRCSTR (awk, HAWK_T(")"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user