changed the way to handle @words.
switched global, local, reset, abort to @global, @local, @reset, @abort to avoid collision with existing awk programs
This commit is contained in:
parent
1157af0b8a
commit
c2668bbe26
@ -378,8 +378,7 @@ struct opttab_t
|
||||
} opttab[] =
|
||||
{
|
||||
{ QSE_T("implicit"), QSE_AWK_IMPLICIT, QSE_T("allow undeclared variables") },
|
||||
{ QSE_T("explicit"), QSE_AWK_EXPLICIT, QSE_T("enable local,global for variable declaration") },
|
||||
{ QSE_T("extrakws"), QSE_AWK_EXTRAKWS, QSE_T("enable abort,reset,nextofile,OFILENAME,@include") },
|
||||
{ QSE_T("extrakws"), QSE_AWK_EXTRAKWS, QSE_T("enable abort,reset,nextofile,OFILENAME,@include,@global,@local") },
|
||||
{ QSE_T("rio"), QSE_AWK_RIO, QSE_T("enable builtin I/O including getline & print") },
|
||||
{ QSE_T("rwpipe"), QSE_AWK_RWPIPE, QSE_T("allow a dual-directional pipe") },
|
||||
{ QSE_T("newline"), QSE_AWK_NEWLINE, QSE_T("enable a newline to terminate a statement") },
|
||||
@ -522,7 +521,6 @@ static int comparg (int argc, qse_char_t* argv[], struct arg_t* arg)
|
||||
{
|
||||
|
||||
{ QSE_T(":implicit"), QSE_T('\0') },
|
||||
{ QSE_T(":explicit"), QSE_T('\0') },
|
||||
{ QSE_T(":extrakws"), QSE_T('\0') },
|
||||
{ QSE_T(":rio"), QSE_T('\0') },
|
||||
{ QSE_T(":rwpipe"), QSE_T('\0') },
|
||||
|
@ -980,12 +980,6 @@ enum qse_awk_trait_t
|
||||
**/
|
||||
QSE_AWK_IMPLICIT = (1 << 0),
|
||||
|
||||
/**
|
||||
* allows explicit variable declaration, the concatenation
|
||||
* operator, a period, and performs the parse-time function check.
|
||||
*/
|
||||
QSE_AWK_EXPLICIT = (1 << 1),
|
||||
|
||||
/**
|
||||
* enable abort,reset,nextofile,OFILENAME,@include.
|
||||
*/
|
||||
@ -1178,7 +1172,8 @@ enum qse_awk_errnum_t
|
||||
QSE_AWK_EINCDECOPR,/**< illegal operand for incr/decr operator */
|
||||
QSE_AWK_EINCLSTR, /**< 'include' not followed by a string */
|
||||
QSE_AWK_EINCLTD, /**< include level too deep */
|
||||
QSE_AWK_EDIRECNR, /**< directive '${0}' not recognized */
|
||||
QSE_AWK_EXKWNR, /**< @word '${0}' not recognized */
|
||||
QSE_AWK_EXKWEM, /**< @ not followed by a valid word */
|
||||
|
||||
/* run time error */
|
||||
QSE_AWK_EDIVBY0, /**< divide by zero */
|
||||
|
@ -101,7 +101,8 @@ const qse_char_t* qse_awk_dflerrstr (const qse_awk_t* awk, qse_awk_errnum_t errn
|
||||
QSE_T("illegal operand for increment/decrement operator"),
|
||||
QSE_T("'include' not followed by a string"),
|
||||
QSE_T("include level too deep"),
|
||||
QSE_T("directive '${0}' not recognized"),
|
||||
QSE_T("@word '${0}' not recognized"),
|
||||
QSE_T("@ not followed by a valid word"),
|
||||
|
||||
QSE_T("divide by zero"),
|
||||
QSE_T("invalid operand"),
|
||||
|
@ -94,8 +94,9 @@ enum tok_t
|
||||
TOK_END,
|
||||
TOK_FUNCTION,
|
||||
|
||||
TOK_LOCAL,
|
||||
TOK_GLOBAL,
|
||||
TOK_XLOCAL,
|
||||
TOK_XGLOBAL,
|
||||
TOK_XINCLUDE,
|
||||
|
||||
TOK_IF,
|
||||
TOK_ELSE,
|
||||
@ -106,12 +107,12 @@ enum tok_t
|
||||
TOK_CONTINUE,
|
||||
TOK_RETURN,
|
||||
TOK_EXIT,
|
||||
TOK_ABORT,
|
||||
TOK_XABORT,
|
||||
TOK_NEXT,
|
||||
TOK_NEXTFILE,
|
||||
TOK_NEXTOFILE,
|
||||
TOK_DELETE,
|
||||
TOK_RESET,
|
||||
TOK_XRESET,
|
||||
TOK_PRINT,
|
||||
TOK_PRINTF,
|
||||
|
||||
@ -254,9 +255,13 @@ static kwent_t kwtab[] =
|
||||
{
|
||||
/* keep this table in sync with the kw_t enums in <parse.h>.
|
||||
* also keep it sorted by the first field for binary search */
|
||||
{ { QSE_T("@abort"), 6 }, TOK_XABORT, QSE_AWK_EXTRAKWS },
|
||||
{ { QSE_T("@global"), 7 }, TOK_XGLOBAL, QSE_AWK_EXTRAKWS },
|
||||
{ { QSE_T("@include"), 8 }, TOK_XINCLUDE, QSE_AWK_EXTRAKWS },
|
||||
{ { QSE_T("@local"), 6 }, TOK_XLOCAL, QSE_AWK_EXTRAKWS },
|
||||
{ { QSE_T("@reset"), 6 }, TOK_XRESET, QSE_AWK_EXTRAKWS },
|
||||
{ { QSE_T("BEGIN"), 5 }, TOK_BEGIN, QSE_AWK_PABLOCK },
|
||||
{ { QSE_T("END"), 3 }, TOK_END, QSE_AWK_PABLOCK },
|
||||
{ { QSE_T("abort"), 5 }, TOK_ABORT, QSE_AWK_EXTRAKWS },
|
||||
{ { QSE_T("break"), 5 }, TOK_BREAK, 0 },
|
||||
{ { QSE_T("continue"), 8 }, TOK_CONTINUE, 0 },
|
||||
{ { QSE_T("delete"), 6 }, TOK_DELETE, 0 },
|
||||
@ -266,16 +271,13 @@ static kwent_t kwtab[] =
|
||||
{ { QSE_T("for"), 3 }, TOK_FOR, 0 },
|
||||
{ { QSE_T("function"), 8 }, TOK_FUNCTION, 0 },
|
||||
{ { QSE_T("getline"), 7 }, TOK_GETLINE, QSE_AWK_RIO },
|
||||
{ { QSE_T("global"), 6 }, TOK_GLOBAL, QSE_AWK_EXPLICIT },
|
||||
{ { QSE_T("if"), 2 }, TOK_IF, 0 },
|
||||
{ { QSE_T("in"), 2 }, TOK_IN, 0 },
|
||||
{ { QSE_T("local"), 5 }, TOK_LOCAL, QSE_AWK_EXPLICIT },
|
||||
{ { QSE_T("next"), 4 }, TOK_NEXT, QSE_AWK_PABLOCK },
|
||||
{ { QSE_T("nextfile"), 8 }, TOK_NEXTFILE, QSE_AWK_PABLOCK },
|
||||
{ { QSE_T("nextofile"), 9 }, TOK_NEXTOFILE, QSE_AWK_PABLOCK | QSE_AWK_EXTRAKWS },
|
||||
{ { QSE_T("print"), 5 }, TOK_PRINT, QSE_AWK_RIO },
|
||||
{ { QSE_T("printf"), 6 }, TOK_PRINTF, QSE_AWK_RIO },
|
||||
{ { QSE_T("reset"), 5 }, TOK_RESET, QSE_AWK_EXTRAKWS },
|
||||
{ { QSE_T("return"), 6 }, TOK_RETURN, 0 },
|
||||
{ { QSE_T("while"), 5 }, TOK_WHILE, 0 }
|
||||
};
|
||||
@ -540,8 +542,7 @@ static int parse (qse_awk_t* awk)
|
||||
if (parse_progunit (awk) <= -1) goto oops;
|
||||
}
|
||||
|
||||
if ((awk->opt.trait & QSE_AWK_EXPLICIT) &&
|
||||
!(awk->opt.trait & QSE_AWK_IMPLICIT))
|
||||
if (!(awk->opt.trait & QSE_AWK_IMPLICIT))
|
||||
{
|
||||
/* ensure that all functions called are defined
|
||||
* in the EXPLICIT-only mode */
|
||||
@ -798,7 +799,7 @@ static int parse_progunit (qse_awk_t* awk)
|
||||
{
|
||||
/*
|
||||
@include "xxxx"
|
||||
global xxx, xxxx;
|
||||
@global xxx, xxxx;
|
||||
BEGIN { action }
|
||||
END { action }
|
||||
pattern { action }
|
||||
@ -807,7 +808,7 @@ static int parse_progunit (qse_awk_t* awk)
|
||||
|
||||
QSE_ASSERT (awk->parse.depth.loop == 0);
|
||||
|
||||
if ((awk->opt.trait & QSE_AWK_EXPLICIT) && MATCH(awk,TOK_GLOBAL))
|
||||
if (MATCH(awk,TOK_XGLOBAL))
|
||||
{
|
||||
qse_size_t ngbls;
|
||||
|
||||
@ -826,41 +827,30 @@ static int parse_progunit (qse_awk_t* awk)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (MATCH(awk,TOK_ATSIGN))
|
||||
else if (MATCH(awk,TOK_XINCLUDE))
|
||||
{
|
||||
if (get_token(awk) <= -1) return -1;
|
||||
|
||||
if (MATCH(awk,TOK_IDENT) &&
|
||||
qse_strcmp (QSE_STR_PTR(awk->tok.name), QSE_T("include")) == 0)
|
||||
if (awk->opt.depth.s.incl > 0 &&
|
||||
awk->parse.depth.incl >= awk->opt.depth.s.incl)
|
||||
{
|
||||
if (awk->opt.depth.s.incl > 0 &&
|
||||
awk->parse.depth.incl >= awk->opt.depth.s.incl)
|
||||
{
|
||||
SETERR_LOC (awk, QSE_AWK_EINCLTD, &awk->ptok.loc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (get_token(awk) <= -1) return -1;
|
||||
|
||||
if (!MATCH(awk,TOK_STR))
|
||||
{
|
||||
SETERR_LOC (
|
||||
awk, QSE_AWK_EINCLSTR, &awk->ptok.loc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (begin_include (awk) <= -1) return -1;
|
||||
|
||||
/* i just return without doing anything special
|
||||
* after having setting up the environment for file
|
||||
* inclusion. the loop in parse() proceeds to call
|
||||
* parse_progunit() */
|
||||
}
|
||||
else
|
||||
{
|
||||
SETERR_TOK (awk, QSE_AWK_EDIRECNR);
|
||||
SETERR_LOC (awk, QSE_AWK_EINCLTD, &awk->ptok.loc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (get_token(awk) <= -1) return -1;
|
||||
|
||||
if (!MATCH(awk,TOK_STR))
|
||||
{
|
||||
SETERR_LOC (
|
||||
awk, QSE_AWK_EINCLSTR, &awk->ptok.loc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (begin_include (awk) <= -1) return -1;
|
||||
|
||||
/* i just return without doing anything special
|
||||
* after having setting up the environment for file
|
||||
* inclusion. the loop in parse() proceeds to call
|
||||
* parse_progunit() */
|
||||
}
|
||||
else if (MATCH(awk,TOK_FUNCTION))
|
||||
{
|
||||
@ -1433,33 +1423,30 @@ static qse_awk_nde_t* parse_block (
|
||||
nlcls_max = awk->parse.nlcls_max;
|
||||
|
||||
/* local variable declarations */
|
||||
if (awk->opt.trait & QSE_AWK_EXPLICIT)
|
||||
while (1)
|
||||
{
|
||||
while (1)
|
||||
/* skip new lines before local declaration in a block*/
|
||||
while (MATCH(awk,TOK_NEWLINE))
|
||||
{
|
||||
/* skip new lines before local declaration in a block*/
|
||||
while (MATCH(awk,TOK_NEWLINE))
|
||||
{
|
||||
if (get_token(awk) <= -1) return QSE_NULL;
|
||||
}
|
||||
if (get_token(awk) <= -1) return QSE_NULL;
|
||||
}
|
||||
|
||||
if (!MATCH(awk,TOK_LOCAL)) break;
|
||||
if (!MATCH(awk,TOK_XLOCAL)) break;
|
||||
|
||||
if (get_token(awk) <= -1)
|
||||
{
|
||||
qse_lda_delete (
|
||||
awk->parse.lcls, nlcls,
|
||||
QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
|
||||
return QSE_NULL;
|
||||
}
|
||||
if (get_token(awk) <= -1)
|
||||
{
|
||||
qse_lda_delete (
|
||||
awk->parse.lcls, nlcls,
|
||||
QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
if (collect_locals (awk, nlcls, istop) == QSE_NULL)
|
||||
{
|
||||
qse_lda_delete (
|
||||
awk->parse.lcls, nlcls,
|
||||
QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
|
||||
return QSE_NULL;
|
||||
}
|
||||
if (collect_locals (awk, nlcls, istop) == QSE_NULL)
|
||||
{
|
||||
qse_lda_delete (
|
||||
awk->parse.lcls, nlcls,
|
||||
QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
|
||||
return QSE_NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2468,7 +2455,7 @@ static qse_awk_nde_t* parse_exit (qse_awk_t* awk, const qse_awk_loc_t* xloc)
|
||||
qse_awk_nde_exit_t* nde;
|
||||
qse_awk_nde_t* val;
|
||||
|
||||
QSE_ASSERT (awk->ptok.type == TOK_EXIT || awk->ptok.type == TOK_ABORT);
|
||||
QSE_ASSERT (awk->ptok.type == TOK_EXIT || awk->ptok.type == TOK_XABORT);
|
||||
|
||||
nde = (qse_awk_nde_exit_t*) qse_awk_callocmem (awk, QSE_SIZEOF(*nde));
|
||||
if (nde == QSE_NULL)
|
||||
@ -2479,7 +2466,7 @@ static qse_awk_nde_t* parse_exit (qse_awk_t* awk, const qse_awk_loc_t* xloc)
|
||||
|
||||
nde->type = QSE_AWK_NDE_EXIT;
|
||||
nde->loc = *xloc;
|
||||
nde->abort = (awk->ptok.type == TOK_ABORT);
|
||||
nde->abort = (awk->ptok.type == TOK_XABORT);
|
||||
|
||||
if (MATCH_TERMINATOR(awk))
|
||||
{
|
||||
@ -2569,7 +2556,7 @@ static qse_awk_nde_t* parse_delete (qse_awk_t* awk, const qse_awk_loc_t* xloc)
|
||||
int inparen = 0;
|
||||
|
||||
QSE_ASSERT (awk->ptok.type == TOK_DELETE ||
|
||||
awk->ptok.type == TOK_RESET);
|
||||
awk->ptok.type == TOK_XRESET);
|
||||
|
||||
type = (awk->ptok.type == TOK_DELETE)?
|
||||
QSE_AWK_NDE_DELETE: QSE_AWK_NDE_RESET;
|
||||
@ -2855,7 +2842,7 @@ static qse_awk_nde_t* parse_statement_nb (
|
||||
if (get_token(awk) <= -1) return QSE_NULL;
|
||||
nde = parse_return (awk, xloc);
|
||||
}
|
||||
else if (MATCH(awk,TOK_EXIT) || MATCH(awk,TOK_ABORT))
|
||||
else if (MATCH(awk,TOK_EXIT) || MATCH(awk,TOK_XABORT))
|
||||
{
|
||||
if (get_token(awk) <= -1) return QSE_NULL;
|
||||
nde = parse_exit (awk, xloc);
|
||||
@ -2875,7 +2862,7 @@ static qse_awk_nde_t* parse_statement_nb (
|
||||
if (get_token(awk) <= -1) return QSE_NULL;
|
||||
nde = parse_nextfile (awk, xloc, 1);
|
||||
}
|
||||
else if (MATCH(awk,TOK_DELETE) || MATCH(awk,TOK_RESET))
|
||||
else if (MATCH(awk,TOK_DELETE) || MATCH(awk,TOK_XRESET))
|
||||
{
|
||||
if (get_token(awk) <= -1) return QSE_NULL;
|
||||
nde = parse_delete (awk, xloc);
|
||||
@ -5924,6 +5911,39 @@ retry:
|
||||
goto try_get_symbols;
|
||||
}
|
||||
}
|
||||
else if (c == QSE_T('@'))
|
||||
{
|
||||
int type;
|
||||
|
||||
ADD_TOKEN_CHAR (awk, tok, c);
|
||||
GET_CHAR_TO (awk, c);
|
||||
|
||||
if (c != QSE_T('_') && !QSE_AWK_ISALPHA (awk, c))
|
||||
{
|
||||
/* this extended keyword is empty,
|
||||
* not followed by a valid word */
|
||||
SETERR_LOC (awk, QSE_AWK_EXKWEM, &(awk)->tok.loc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* expect normal identifier starting with an alphabet */
|
||||
do
|
||||
{
|
||||
ADD_TOKEN_CHAR (awk, tok, c);
|
||||
GET_CHAR_TO (awk, c);
|
||||
}
|
||||
while (c == QSE_T('_') ||
|
||||
QSE_AWK_ISALPHA (awk, c) ||
|
||||
QSE_AWK_ISDIGIT (awk, c));
|
||||
|
||||
type = classify_ident (awk, QSE_STR_CSTR(tok->name));
|
||||
if (type == TOK_IDENT)
|
||||
{
|
||||
SETERR_TOK (awk, QSE_AWK_EXKWNR);
|
||||
return -1;
|
||||
}
|
||||
SET_TOKEN_TYPE (awk, tok, type);
|
||||
}
|
||||
else if (c == QSE_T('_') || QSE_AWK_ISALPHA (awk, c))
|
||||
{
|
||||
int type;
|
||||
@ -6113,20 +6133,16 @@ static int deparse (qse_awk_t* awk)
|
||||
|
||||
QSE_ASSERT (awk->tree.ngbls > 0);
|
||||
|
||||
qse_awk_getkwname (awk, QSE_AWK_KWID_GLOBAL, &kw);
|
||||
if (qse_awk_putsrcstrn(awk,kw.ptr,kw.len) <= -1)
|
||||
{
|
||||
EXIT_DEPARSE ();
|
||||
}
|
||||
if (qse_awk_putsrcstr (awk, QSE_T(" ")) <= -1)
|
||||
qse_awk_getkwname (awk, QSE_AWK_KWID_XGLOBAL, &kw);
|
||||
if (qse_awk_putsrcstrn(awk,kw.ptr,kw.len) <= -1 ||
|
||||
qse_awk_putsrcstr (awk, QSE_T(" ")) <= -1)
|
||||
{
|
||||
EXIT_DEPARSE ();
|
||||
}
|
||||
|
||||
for (i = awk->tree.ngbls_base; i < awk->tree.ngbls - 1; i++)
|
||||
{
|
||||
if ((awk->opt.trait & QSE_AWK_EXPLICIT) &&
|
||||
!(awk->opt.trait & QSE_AWK_IMPLICIT))
|
||||
if (!(awk->opt.trait & QSE_AWK_IMPLICIT))
|
||||
{
|
||||
/* use the actual name if no named variable
|
||||
* is allowed */
|
||||
@ -6153,8 +6169,7 @@ static int deparse (qse_awk_t* awk)
|
||||
EXIT_DEPARSE ();
|
||||
}
|
||||
|
||||
if ((awk->opt.trait & QSE_AWK_EXPLICIT) &&
|
||||
!(awk->opt.trait & QSE_AWK_IMPLICIT))
|
||||
if (!(awk->opt.trait & QSE_AWK_IMPLICIT))
|
||||
{
|
||||
if (qse_awk_putsrcstrn (awk,
|
||||
QSE_LDA_DPTR(awk->parse.gbls,i),
|
||||
|
@ -24,9 +24,13 @@
|
||||
/* these enums should match kwtab in parse.c */
|
||||
enum qse_awk_kwid_t
|
||||
{
|
||||
QSE_AWK_KWID_XABORT,
|
||||
QSE_AWK_KWID_XGLOBAL,
|
||||
QSE_AWK_KWID_XINCLUDE,
|
||||
QSE_AWK_KWID_XLOCAL,
|
||||
QSE_AWK_KWID_XRESET,
|
||||
QSE_AWK_KWID_BEGIN,
|
||||
QSE_AWK_KWID_END,
|
||||
QSE_AWK_KWID_ABORT,
|
||||
QSE_AWK_KWID_BREAK,
|
||||
QSE_AWK_KWID_CONTINUE,
|
||||
QSE_AWK_KWID_DELETE,
|
||||
@ -36,16 +40,13 @@ enum qse_awk_kwid_t
|
||||
QSE_AWK_KWID_FOR,
|
||||
QSE_AWK_KWID_FUNCTION,
|
||||
QSE_AWK_KWID_GETLINE,
|
||||
QSE_AWK_KWID_GLOBAL,
|
||||
QSE_AWK_KWID_IF,
|
||||
QSE_AWK_KWID_IN,
|
||||
QSE_AWK_KWID_LOCAL,
|
||||
QSE_AWK_KWID_NEXT,
|
||||
QSE_AWK_KWID_NEXTFILE,
|
||||
QSE_AWK_KWID_NEXTOFILE,
|
||||
QSE_AWK_KWID_PRINT,
|
||||
QSE_AWK_KWID_PRINTF,
|
||||
QSE_AWK_KWID_RESET,
|
||||
QSE_AWK_KWID_RETURN,
|
||||
QSE_AWK_KWID_WHILE
|
||||
};
|
||||
|
@ -482,8 +482,7 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde)
|
||||
if (px->id.idxa != (qse_size_t)-1)
|
||||
{
|
||||
|
||||
if ((awk->opt.trait & QSE_AWK_EXPLICIT) &&
|
||||
!(awk->opt.trait & QSE_AWK_IMPLICIT))
|
||||
if (!(awk->opt.trait & QSE_AWK_IMPLICIT))
|
||||
{
|
||||
/* no implicit(named) variable is allowed.
|
||||
* use the actual name */
|
||||
@ -524,8 +523,7 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde)
|
||||
|
||||
if (px->id.idxa != (qse_size_t)-1)
|
||||
{
|
||||
if ((awk->opt.trait & QSE_AWK_EXPLICIT) &&
|
||||
!(awk->opt.trait & QSE_AWK_IMPLICIT))
|
||||
if (!(awk->opt.trait & QSE_AWK_IMPLICIT))
|
||||
{
|
||||
/* no implicit(named) variable is allowed.
|
||||
* use the actual name */
|
||||
@ -744,7 +742,8 @@ static int print_stmt (qse_awk_t* awk, qse_awk_nde_t* p, int depth)
|
||||
if (px->nlcls > 0)
|
||||
{
|
||||
PRINT_TABS (awk, depth + 1);
|
||||
qse_awk_getkwname (awk, QSE_AWK_KWID_LOCAL, &kw);
|
||||
|
||||
qse_awk_getkwname (awk, QSE_AWK_KWID_XLOCAL, &kw);
|
||||
PUT_SRCSTRN (awk, kw.ptr, kw.len);
|
||||
PUT_SRCSTR (awk, QSE_T(" "));
|
||||
|
||||
@ -973,14 +972,14 @@ static int print_stmt (qse_awk_t* awk, qse_awk_nde_t* p, int depth)
|
||||
|
||||
if (px->val == QSE_NULL)
|
||||
{
|
||||
qse_awk_getkwname (awk, (px->abort? QSE_AWK_KWID_ABORT: QSE_AWK_KWID_EXIT), &kw);
|
||||
qse_awk_getkwname (awk, (px->abort? QSE_AWK_KWID_XABORT: QSE_AWK_KWID_EXIT), &kw);
|
||||
PUT_SRCSTRN (awk, kw.ptr, kw.len);
|
||||
PUT_SRCSTR (awk, QSE_T(";"));
|
||||
PUT_NL (awk);
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_awk_getkwname (awk, (px->abort? QSE_AWK_KWID_ABORT: QSE_AWK_KWID_EXIT), &kw);
|
||||
qse_awk_getkwname (awk, (px->abort? QSE_AWK_KWID_XABORT: QSE_AWK_KWID_EXIT), &kw);
|
||||
PUT_SRCSTRN (awk, kw.ptr, kw.len);
|
||||
PUT_SRCSTR (awk, QSE_T(" "));
|
||||
QSE_ASSERT (px->val->next == QSE_NULL);
|
||||
@ -1032,7 +1031,7 @@ static int print_stmt (qse_awk_t* awk, qse_awk_nde_t* p, int depth)
|
||||
case QSE_AWK_NDE_RESET:
|
||||
{
|
||||
PRINT_TABS (awk, depth);
|
||||
qse_awk_getkwname (awk, QSE_AWK_KWID_RESET, &kw);
|
||||
qse_awk_getkwname (awk, QSE_AWK_KWID_XRESET, &kw);
|
||||
PUT_SRCSTRN (awk, kw.ptr, kw.len);
|
||||
PUT_SRCSTR (awk, QSE_T(" "));
|
||||
qse_awk_prnpt (awk, ((qse_awk_nde_reset_t*)p)->var);
|
||||
|
@ -449,7 +449,7 @@ static int server_open (qse_httpd_t* httpd, qse_httpd_server_t* server)
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = socket (SOCKADDR_FAMILY(&addr), SOCK_STREAM, IPPROTO_TCP);
|
||||
fd = socket (qse_skadfamily(&addr), SOCK_STREAM, IPPROTO_TCP);
|
||||
if (fd <= -1) goto oops;
|
||||
|
||||
#if defined(FD_CLOEXEC)
|
||||
@ -518,7 +518,7 @@ IP_TRANSPRENT is needed for:
|
||||
if (bind (fd, (struct sockaddr*)&addr, addrsize) <= -1)
|
||||
{
|
||||
#if defined(IPV6_V6ONLY)
|
||||
if (errno == EADDRINUSE && SOCKADDR_FAMILY(&addr) == AF_INET6)
|
||||
if (errno == EADDRINUSE && qse_skadfamily(&addr) == AF_INET6)
|
||||
{
|
||||
int on = 1;
|
||||
setsockopt (fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
|
||||
@ -682,7 +682,7 @@ static int peer_open (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd = socket (SOCKADDR_FAMILY(&connaddr), SOCK_STREAM, IPPROTO_TCP);
|
||||
fd = socket (qse_skadfamily(&connaddr), SOCK_STREAM, IPPROTO_TCP);
|
||||
if (fd <= -1) goto oops;
|
||||
|
||||
#if defined(IP_TRANSPARENT)
|
||||
|
@ -7,10 +7,10 @@ function a (x) { print x; }
|
||||
BEGIN {
|
||||
|
||||
{
|
||||
local a;
|
||||
@local a;
|
||||
a = 50;
|
||||
{
|
||||
local a;
|
||||
@local a;
|
||||
a = 30;
|
||||
print a;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# a global variable can not have the same name as a function name
|
||||
#
|
||||
global a;
|
||||
@global a;
|
||||
function a () { }
|
||||
|
@ -9,7 +9,7 @@ function fn ()
|
||||
return a;
|
||||
}
|
||||
|
||||
global a;
|
||||
@global a;
|
||||
|
||||
BEGIN {
|
||||
a = 30
|
||||
|
@ -2,15 +2,15 @@
|
||||
# a local variable can shade a global variable
|
||||
#
|
||||
|
||||
global x;
|
||||
@global x;
|
||||
|
||||
BEGIN {
|
||||
x = 1;
|
||||
{
|
||||
local x;
|
||||
@local x;
|
||||
x = 2;
|
||||
{
|
||||
local x;
|
||||
@local x;
|
||||
x = 3;
|
||||
print x;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ function a (a) {
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
local a;
|
||||
@local a;
|
||||
a = 20;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
global ARGV;
|
||||
@global ARGV;
|
||||
|
||||
BEGIN {
|
||||
print ARGC;
|
||||
|
@ -1,2 +1,2 @@
|
||||
global + ;
|
||||
@global + ;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
BEGIN {
|
||||
|
||||
local +;
|
||||
@local +;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
BEGIN {
|
||||
local a;
|
||||
@local a;
|
||||
|
||||
a = 21;
|
||||
print a > 20? 1 2;
|
||||
|
@ -1,5 +1,5 @@
|
||||
BEGIN {
|
||||
local a;
|
||||
@local a;
|
||||
|
||||
a = 21;
|
||||
print a > 20? 1 : 2;
|
||||
|
@ -2,11 +2,11 @@
|
||||
function abc ()
|
||||
{
|
||||
|
||||
local x;
|
||||
@local x;
|
||||
print x = 20;
|
||||
|
||||
{
|
||||
local abc;
|
||||
@local abc;
|
||||
|
||||
abc = 30;
|
||||
print abc;
|
||||
|
@ -130,11 +130,11 @@ PROGS="
|
||||
lang-002.awk!!!--newline=on -d-
|
||||
lang-003.awk!!!--newline=on -d-
|
||||
lang-004.awk!!!--newline=on -d-
|
||||
lang-005.awk!!!--implicit=off --explicit=on --newline=on -d-
|
||||
lang-006.awk!!!--implicit=off --explicit=on --newline=on -d-
|
||||
lang-007.awk!!!--implicit=on --explicit=on --newline=on -d-
|
||||
lang-008.awk!!!--implicit=off --explicit=on --newline=on -d-
|
||||
lang-009.awk!lang-009.awk!!--implicit=off --explicit=on --newline=on --strictnaming=off -d-
|
||||
lang-005.awk!!!--implicit=off --newline=on -d-
|
||||
lang-006.awk!!!--implicit=off --newline=on -d-
|
||||
lang-007.awk!!!--implicit=on --newline=on -d-
|
||||
lang-008.awk!!!--implicit=off --newline=on -d-
|
||||
lang-009.awk!lang-009.awk!!--implicit=off --newline=on --strictnaming=off -d-
|
||||
lang-010.awk!this is just a test!!--newline=on -d-
|
||||
lang-011.awk!!!--newline=on -d-
|
||||
lang-012.awk!!!--newline=on -d-
|
||||
@ -144,18 +144,18 @@ PROGS="
|
||||
lang-016.awk!!!--newline=on -d-
|
||||
lang-017.awk!!!--newline=on -d-
|
||||
lang-017.awk!!!--call main --newline=on -d-
|
||||
lang-018.awk!!!--explicit=on --newline=on -d-
|
||||
lang-019.awk!!!--explicit=on --newline=on -d-
|
||||
lang-020.awk!!!--explicit=on --newline=on -d-
|
||||
lang-021.awk!!!--explicit=on --newline=on -d-
|
||||
lang-018.awk!!!--newline=on -d-
|
||||
lang-019.awk!!!--newline=on -d-
|
||||
lang-020.awk!!!--newline=on -d-
|
||||
lang-021.awk!!!--newline=on -d-
|
||||
lang-022.awk!!!--newline=on -d-
|
||||
lang-023.awk!!!--explicit=on --newline=on -d-
|
||||
lang-024.awk!!!--explicit=on --newline=on -d-
|
||||
lang-023.awk!!!--newline=on -d-
|
||||
lang-024.awk!!!--newline=on -d-
|
||||
lang-025.awk!!!--newline=on -d-
|
||||
lang-026.awk!!!--newline=on -d-
|
||||
lang-027.awk!!!--newline=on -d-
|
||||
lang-028.awk!!!--newline=on -d-
|
||||
lang-029.awk!!!--explicit=on --newline=on -d-
|
||||
lang-029.awk!!!--newline=on -d-
|
||||
lang-030.awk!!!--newline=on -d-
|
||||
lang-031.awk!!!--newline=on -d-
|
||||
lang-032.awk!!!--newline=on -d-
|
||||
|
Loading…
x
Reference in New Issue
Block a user