corrected the random max value.
some more error information handling improvement in parse.c
This commit is contained in:
parent
01464d1fb1
commit
ec5e61278c
@ -101,8 +101,8 @@ const hawk_ooch_t* hawk_dflerrstr (hawk_t* awk, hawk_errnum_t errnum)
|
||||
HAWK_T("global variable redefined"),
|
||||
HAWK_T("parameter redefined"),
|
||||
HAWK_T("variable redefined"),
|
||||
HAWK_T("duplicate parameter name '${0}'"),
|
||||
HAWK_T("duplicate global variable '${0}'"),
|
||||
HAWK_T("duplicate parameter name"),
|
||||
HAWK_T("duplicate global variable"),
|
||||
HAWK_T("duplicate local variable"),
|
||||
HAWK_T("'${0}' not a valid parameter name"),
|
||||
HAWK_T("'${0}' not a valid variable name"),
|
||||
|
@ -831,9 +831,9 @@ enum hawk_errnum_t
|
||||
HAWK_EGBLRED, /**< global variable redefined */
|
||||
HAWK_EPARRED, /**< parameter redefined */
|
||||
HAWK_EVARRED, /**< variable redefined */
|
||||
HAWK_EDUPPAR, /**< duplicate parameter name '${0}' */
|
||||
HAWK_EDUPGBL, /**< duplicate global variable name '${0}' */
|
||||
HAWK_EDUPLCL, /**< duplicate local variable name '${0}' */
|
||||
HAWK_EDUPPAR, /**< duplicate parameter name */
|
||||
HAWK_EDUPGBL, /**< duplicate global variable name */
|
||||
HAWK_EDUPLCL, /**< duplicate local variable name' */
|
||||
HAWK_EBADPAR, /**< '${0}' not a valid parameter name */
|
||||
HAWK_EBADVAR, /**< '${0}' not a valid variable name */
|
||||
HAWK_EVARMS, /**< variable name missing */
|
||||
|
@ -530,7 +530,8 @@ static int fnc_sqrt (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
|
||||
static int fnc_rand (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
{
|
||||
#define RANDV_MAX HAWK_TYPE_MAX(hawk_int_t)
|
||||
/*#define RANDV_MAX HAWK_TYPE_MAX(hawk_int_t)*/
|
||||
#define RANDV_MAX RAND_MAX
|
||||
hawk_val_t* r;
|
||||
hawk_int32_t randv;
|
||||
modctx_t* modctx;
|
||||
|
@ -1324,7 +1324,7 @@ static hawk_nde_t* parse_function (hawk_t* awk)
|
||||
hawk_comp_oochars(pa, pal, name.ptr, name.len, 0) == 0) ||
|
||||
hawk_arr_search(awk->parse.params, 0, pa, pal) != HAWK_ARR_NIL)
|
||||
{
|
||||
SETERR_ARG_LOC (awk, HAWK_EDUPPAR, pa, pal, &awk->tok.loc);
|
||||
hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPPAR, HAWK_T("duplicate parameter name '%.*js'"), pal, pa);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
@ -1856,7 +1856,7 @@ static int add_global (hawk_t* awk, const hawk_oocs_t* name, hawk_loc_t* xloc, i
|
||||
/* check if it conflicts with other global variable names */
|
||||
if (find_global(awk, name) != HAWK_ARR_NIL)
|
||||
{
|
||||
SETERR_ARG_LOC (awk, HAWK_EDUPGBL, name->ptr, name->len, xloc);
|
||||
hawk_seterrfmt (awk, xloc, HAWK_EDUPGBL, HAWK_T("duplicate global variable name '%.*js'"), name->len, name->ptr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2261,7 +2261,7 @@ static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop)
|
||||
n = hawk_arr_search(awk->parse.lcls, nlcls, lcl.ptr, lcl.len);
|
||||
if (n != HAWK_ARR_NIL)
|
||||
{
|
||||
hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, HAWK_T("duplicate local variable - %.*js"), lcl.len, lcl.ptr);
|
||||
hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, HAWK_T("duplicate local variable name - %.*js"), lcl.len, lcl.ptr);
|
||||
return HAWK_NULL;
|
||||
}
|
||||
|
||||
@ -2272,7 +2272,7 @@ static hawk_t* collect_locals (hawk_t* awk, hawk_oow_t nlcls, int istop)
|
||||
if (n < awk->tree.ngbls_base)
|
||||
{
|
||||
/* it is a conflict only if it is one of a static global variable */
|
||||
hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, HAWK_T("duplicate local variable - %.*js"), lcl.len, lcl.ptr);
|
||||
hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EDUPLCL, HAWK_T("duplicate local variable name - %.*js"), lcl.len, lcl.ptr);
|
||||
return HAWK_NULL;
|
||||
}
|
||||
}
|
||||
|
@ -83,8 +83,6 @@ struct pafv_t
|
||||
(idx) <= HAWK_TYPE_MAX(hawk_int_t) && \
|
||||
(idx) <= HAWK_TYPE_MAX(hawk_oow_t))
|
||||
|
||||
#define SETERR_ARGX_LOC(rtx,code,ea,loc) hawk_rtx_seterror ((rtx), (code), (ea), (loc))
|
||||
|
||||
#define CLRERR(rtx) hawk_rtx_seterrnum(rtx, HAWK_NULL, HAWK_ENOERR)
|
||||
#define ADJERR_LOC(rtx,l) do { (rtx)->_gem.errloc = *(l); } while (0)
|
||||
|
||||
|
@ -112,4 +112,19 @@ $ ~/xxx/bin/hawk 'function test(ax) { @local ax; }'
|
||||
HAWK_EPARRED -> ERROR: CODE 61 LINE 1 COLUMN 28 - parameter 'ax' redefined
|
||||
|
||||
|
||||
$ ~/xxx/bin/hawk 'function test(ax, bx, ax) { return ax * bx; }'
|
||||
HAWK_EDUPPAR -> ERROR: CODE 63 LINE 1 COLUMN 23 - duplicate parameter name 'ax'
|
||||
|
||||
|
||||
$ ~/xxx/bin/hawk '@global x, y, x; '
|
||||
HAWK_EDUPGBL -> ERROR: CODE 64 LINE 1 COLUMN 15 - duplicate global variable name 'x'
|
||||
|
||||
|
||||
|
||||
$ ~/xxx/bin/hawk 'function test(ax, bx) { @local x, y, x; }'
|
||||
HAWK_EDUPLCL -> ERROR: CODE 65 LINE 1 COLUMN 38 - duplicate local variable name - x
|
||||
|
||||
$ ~/xxx/bin/hawk 'function test(ax, bx) { @local ARGC; }'
|
||||
ERROR: CODE 65 LINE 1 COLUMN 32 - duplicate local variable name - ARGC
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user