diff --git a/qse/cmd/awk/awk.c b/qse/cmd/awk/awk.c index 9bdecdba..7c9eca16 100644 --- a/qse/cmd/awk/awk.c +++ b/qse/cmd/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c 238 2009-07-17 12:42:02Z hyunghwan.chung $ + * $Id: awk.c 239 2009-07-18 12:02:24Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -339,6 +339,7 @@ struct opttab_t { QSE_T("rexbound"), QSE_AWK_REXBOUND, QSE_T("enable {n,m} in a regular expression") }, { QSE_T("ncmponstr"), QSE_AWK_NCMPONSTR, QSE_T("perform numeric comparsion on numeric strings") }, { QSE_T("strictnaming"), QSE_AWK_STRICTNAMING, QSE_T("enable the strict naming rule") }, + { QSE_T("include"), QSE_AWK_INCLUDE, QSE_T("enable 'include'") }, { QSE_NULL, 0 } }; @@ -384,6 +385,7 @@ static int comparg (int argc, qse_char_t* argv[], struct arg_t* arg) { QSE_T(":rexbound"), QSE_T('\0') }, { QSE_T(":ncmponstr"), QSE_T('\0') }, { QSE_T(":strictnaming"), QSE_T('\0') }, + { QSE_T(":include"), QSE_T('\0') }, { QSE_T(":call"), QSE_T('c') }, { QSE_T(":file"), QSE_T('f') }, diff --git a/qse/include/qse/awk/Awk.hpp b/qse/include/qse/awk/Awk.hpp index cc2602cd..58995ba1 100644 --- a/qse/include/qse/awk/Awk.hpp +++ b/qse/include/qse/awk/Awk.hpp @@ -1,5 +1,5 @@ /* - * $Id: Awk.hpp 238 2009-07-17 12:42:02Z hyunghwan.chung $ + * $Id: Awk.hpp 239 2009-07-18 12:02:24Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -873,7 +873,10 @@ public: * - 9 is greater if #QSE_AWK_NCMPONSTR is off; * - "10.9" is greater if #QSE_AWK_NCMPONSTR is on */ - OPT_NCMPONSTR = QSE_AWK_NCMPONSTR + OPT_NCMPONSTR = QSE_AWK_NCMPONSTR, + + /** Enables 'include' */ + OPT_INCLUDE = QSE_AWK_INCLUDE }; /** Gets the option */ int getOption () const; @@ -991,28 +994,20 @@ public: */ /*@{*/ int getWord ( - const char_t* ow, qse_size_t owl, - const char_t** nw, qse_size_t* nwl + const cstr_t* ow, + cstr_t* nw ); int setWord ( - const char_t* ow, const char_t* nw - ); - - int setWord ( - const char_t* ow, qse_size_t owl, - const char_t* nw, qse_size_t nwl + const cstr_t* ow, + const cstr_t* nw ); int unsetWord ( - const char_t* ow + const cstr_t* ow ); - int unsetWord ( - const char_t* ow, qse_size_t owl - ); - - int unsetAllWords (); + void unsetAllWords (); /*@}*/ protected: diff --git a/qse/include/qse/awk/awk.h b/qse/include/qse/awk/awk.h index e22c2201..ee88e1a1 100644 --- a/qse/include/qse/awk/awk.h +++ b/qse/include/qse/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h 238 2009-07-17 12:42:02Z hyunghwan.chung $ + * $Id: awk.h 239 2009-07-18 12:02:24Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -574,6 +574,11 @@ enum qse_awk_option_t */ QSE_AWK_STRICTNAMING = (1 << 15), + /** + * supports file inclusion by enabling a keyword 'include' + */ + QSE_AWK_INCLUDE = (1 << 16), + /** * makes #qse_awk_t to behave as compatibly as classical AWK * implementations @@ -1059,17 +1064,14 @@ void qse_awk_setmaxdepth ( ); int qse_awk_getword ( - qse_awk_t* awk, - const qse_char_t* okw, - qse_size_t olen, - const qse_char_t** nkw, - qse_size_t* nlen + qse_awk_t* awk, + const qse_cstr_t* okw, + qse_cstr_t* nkw ); int qse_awk_unsetword ( qse_awk_t* awk, - const qse_char_t* kw, - qse_size_t len + const qse_cstr_t* kw ); void qse_awk_unsetallwords ( @@ -1089,16 +1091,9 @@ void qse_awk_unsetallwords ( * @return 0 on success, -1 on failure */ int qse_awk_setword ( - /* the pointer to a qse_awk_t instance */ - qse_awk_t* awk, - /* the pointer to an old keyword */ - const qse_char_t* okw, - /* the length of the old keyword */ - qse_size_t olen, - /* the pointer to an new keyword */ - const qse_char_t* nkw, - /* the length of the new keyword */ - qse_size_t nlen + qse_awk_t* awk, /**< awk object */ + const qse_cstr_t* okw, /**< old keyword */ + const qse_cstr_t* nkw /**< new keyword */ ); /** diff --git a/qse/include/qse/awk/std.h b/qse/include/qse/awk/std.h index e678249e..2365966c 100644 --- a/qse/include/qse/awk/std.h +++ b/qse/include/qse/awk/std.h @@ -1,5 +1,5 @@ /* - * $Id: std.h 232 2009-07-14 08:06:14Z hyunghwan.chung $ + * $Id: std.h 239 2009-07-18 12:02:24Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -34,6 +34,7 @@ * - add code to treat a function as a value * - add RQ and LQ for more powerful record splitting * - improve performance in qse_awk_rtx_readio() if RS is logner than 2 chars. + * - implement 'include' */ /** diff --git a/qse/lib/awk/Awk.cpp b/qse/lib/awk/Awk.cpp index 2294e5e2..8e30961a 100644 --- a/qse/lib/awk/Awk.cpp +++ b/qse/lib/awk/Awk.cpp @@ -1,5 +1,5 @@ /* - * $Id: Awk.cpp 236 2009-07-16 08:27:53Z hyunghwan.chung $ + * $Id: Awk.cpp 239 2009-07-18 12:02:24Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -1579,42 +1579,28 @@ int Awk::deleteFunction (const char_t* name) return n; } -int Awk::getWord ( - const char_t* ow, qse_size_t owl, - const char_t** nw, qse_size_t* nwl) +int Awk::getWord (const cstr_t* ow, cstr_t* nw) { QSE_ASSERT (awk != QSE_NULL); - return qse_awk_getword (awk, ow, owl, nw, nwl); + return qse_awk_getword (awk, ow, nw); } -int Awk::setWord (const char_t* ow, const char_t* nw) -{ - return setWord (ow, qse_strlen(ow), nw, qse_strlen(nw)); -} - -int Awk::setWord ( - const char_t* ow, qse_size_t owl, - const char_t* nw, qse_size_t nwl) +int Awk::setWord (const cstr_t* ow, const cstr_t* nw) { QSE_ASSERT (awk != QSE_NULL); - return qse_awk_setword (awk, ow, owl, nw, nwl); + return qse_awk_setword (awk, ow, nw); } -int Awk::unsetWord (const char_t* ow) -{ - return unsetWord (ow, qse_strlen(ow)); -} - -int Awk::unsetWord (const char_t* ow, qse_size_t owl) +int Awk::unsetWord (const cstr_t* w) { QSE_ASSERT (awk != QSE_NULL); - return qse_awk_setword (awk, ow, owl, QSE_NULL, 0); + return qse_awk_unsetword (awk, w); } -int Awk::unsetAllWords () +void Awk::unsetAllWords () { QSE_ASSERT (awk != QSE_NULL); - return qse_awk_setword (awk, QSE_NULL, 0, QSE_NULL, 0); + qse_awk_unsetallwords (awk); } Awk::ssize_t Awk::readSource ( diff --git a/qse/lib/awk/awk.c b/qse/lib/awk/awk.c index 7bf79585..8ed547dd 100644 --- a/qse/lib/awk/awk.c +++ b/qse/lib/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c 232 2009-07-14 08:06:14Z hyunghwan.chung $ + * $Id: awk.c 239 2009-07-18 12:02:24Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -27,14 +27,6 @@ QSE_IMPLEMENT_COMMON_FUNCTIONS (awk) #define SETERR(awk,code) qse_awk_seterrnum(awk,code) -#define SETERRARG(awk,code,line,arg,leng) \ - do { \ - qse_cstr_t errarg; \ - errarg.len = (leng); \ - errarg.ptr = (arg); \ - qse_awk_seterror ((awk), (code), (line), &errarg); \ - } while (0) - static void free_fun (qse_map_t* map, void* vptr, qse_size_t vlen) { qse_awk_t* awk = *(qse_awk_t**)QSE_XTN(map); @@ -360,34 +352,34 @@ void qse_awk_stopall (qse_awk_t* awk) awk->stopall = QSE_TRUE; } -int qse_awk_getword (qse_awk_t* awk, - const qse_char_t* okw, qse_size_t olen, - const qse_char_t** nkw, qse_size_t* nlen) +int qse_awk_getword (qse_awk_t* awk, const qse_cstr_t* okw, qse_cstr_t* nkw) { qse_map_pair_t* p; - p = qse_map_search (awk->wtab, okw, olen); + p = qse_map_search (awk->wtab, okw->ptr, okw->len); if (p == QSE_NULL) return -1; - *nkw = ((qse_cstr_t*)p->vptr)->ptr; - *nlen = ((qse_cstr_t*)p->vptr)->len; + nkw->ptr = ((qse_cstr_t*)p->vptr)->ptr; + nkw->len = ((qse_cstr_t*)p->vptr)->len; return 0; } -int qse_awk_unsetword (qse_awk_t* awk, const qse_char_t* kw, qse_size_t len) +int qse_awk_unsetword (qse_awk_t* awk, const qse_cstr_t* kw) { qse_map_pair_t* p; - p = qse_map_search (awk->wtab, kw, len); + QSE_ASSERT (kw->ptr != QSE_NULL); + + p = qse_map_search (awk->wtab, kw->ptr, kw->len); if (p == QSE_NULL) { - SETERRARG (awk, QSE_AWK_ENOENT, 0, kw, len); + qse_awk_seterror (awk, QSE_AWK_ENOENT, 0, kw); return -1; } qse_map_delete (awk->rwtab, QSE_MAP_VPTR(p), QSE_MAP_VLEN(p)); - qse_map_delete (awk->wtab, kw, len); + qse_map_delete (awk->wtab, kw->ptr, kw->len); return 0; } @@ -397,39 +389,45 @@ void qse_awk_unsetallwords (qse_awk_t* awk) qse_map_clear (awk->rwtab); } -int qse_awk_setword (qse_awk_t* awk, - const qse_char_t* okw, qse_size_t olen, - const qse_char_t* nkw, qse_size_t nlen) +int qse_awk_setword ( + qse_awk_t* awk, const qse_cstr_t* okw, const qse_cstr_t* nkw) { - if (nkw == QSE_NULL || nlen == 0) + if (nkw == QSE_NULL) { - if (okw == QSE_NULL || olen == 0) + if (okw == QSE_NULL) { /* clear the entire table */ qse_awk_unsetallwords (awk); return 0; } - return qse_awk_unsetword (awk, okw, olen); + return qse_awk_unsetword (awk, okw); } - else if (okw == QSE_NULL || olen == 0) + else if (okw == QSE_NULL) { SETERR (awk, QSE_AWK_EINVAL); return -1; } + QSE_ASSERT (okw->ptr != QSE_NULL); + QSE_ASSERT (nkw->ptr != QSE_NULL); + /* set the word */ - if (qse_map_upsert (awk->wtab, - (qse_char_t*)okw, olen, (qse_char_t*)nkw, nlen) == QSE_NULL) + if (qse_map_upsert ( + awk->wtab, + (qse_char_t*)okw->ptr, okw->len, + (qse_char_t*)nkw->ptr, nkw->len) == QSE_NULL) { SETERR (awk, QSE_AWK_ENOMEM); return -1; } - if (qse_map_upsert (awk->rwtab, - (qse_char_t*)nkw, nlen, (qse_char_t*)okw, olen) == QSE_NULL) + if (qse_map_upsert ( + awk->rwtab, + (qse_char_t*)nkw->ptr, nkw->len, + (qse_char_t*)okw->ptr, okw->len) == QSE_NULL) { - qse_map_delete (awk->wtab, okw, olen); + qse_map_delete (awk->wtab, okw->ptr, okw->len); SETERR (awk, QSE_AWK_ENOMEM); return -1; } diff --git a/qse/lib/awk/parse.c b/qse/lib/awk/parse.c index 99d3219b..dcb7e079 100644 --- a/qse/lib/awk/parse.c +++ b/qse/lib/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c 238 2009-07-17 12:42:02Z hyunghwan.chung $ + * $Id: parse.c 239 2009-07-18 12:02:24Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -23,6 +23,9 @@ enum token_t TOKEN_EOF, TOKEN_NEWLINE, + /* special token to direct the parser to include a file specified */ + TOKEN_INCLUDE, + /* TOKEN_XXX_ASSIGNs should in sync * with assop in assign_to_opcode */ TOKEN_ASSIGN, @@ -214,15 +217,7 @@ static qse_awk_nde_t* parse_print (qse_awk_t* awk, qse_size_t line, int type); static int get_token (qse_awk_t* awk); static int preget_token (qse_awk_t* awk); - -static int get_number (qse_awk_t* awk, qse_awk_token_t* token); -static int get_charstr (qse_awk_t* awk, qse_awk_token_t* token); static int get_rexstr (qse_awk_t* awk, qse_awk_token_t* token); -static int get_string ( - qse_awk_t* awk, qse_char_t end_char, - qse_char_t esc_char, qse_bool_t keep_esc_char, int preescaped, - qse_awk_token_t* token -); static int get_char (qse_awk_t* awk); static int unget_char (qse_awk_t* awk, qse_cint_t c); @@ -230,7 +225,6 @@ static int skip_spaces (qse_awk_t* awk); static int skip_comment (qse_awk_t* awk); static int classify_ident ( qse_awk_t* awk, const qse_char_t* name, qse_size_t len); -static int assign_to_opcode (qse_awk_t* awk); static int is_plain_var (qse_awk_nde_t* nde); static int is_var (qse_awk_nde_t* nde); @@ -267,6 +261,7 @@ static kwent_t kwtab[] = { QSE_T("global"), 6, TOKEN_GLOBAL, QSE_AWK_EXPLICIT }, { QSE_T("if"), 2, TOKEN_IF, 0 }, { QSE_T("in"), 2, TOKEN_IN, 0 }, + { QSE_T("include"), 7, TOKEN_INCLUDE, QSE_AWK_INCLUDE }, { QSE_T("local"), 5, TOKEN_LOCAL, QSE_AWK_EXPLICIT }, { QSE_T("next"), 4, TOKEN_NEXT, QSE_AWK_PABLOCK }, { QSE_T("nextfile"), 8, TOKEN_NEXTFILE, QSE_AWK_PABLOCK }, @@ -787,7 +782,7 @@ static qse_awk_t* parse_progunit (qse_awk_t* awk) if ((awk->option & QSE_AWK_RIO) != QSE_AWK_RIO) { - /* blockless pattern requires QSE_AWK_EIO + /* blockless pattern requires QSE_AWK_RIO * to be ON because the implicit block is * "print $0" */ SETERRLIN (awk, QSE_AWK_ENOSUP, tline); @@ -1948,7 +1943,13 @@ static qse_awk_nde_t* parse_statement_nb (qse_awk_t* awk, qse_size_t line) } /* keywords that require a terminating semicolon */ - if (MATCH(awk,TOKEN_DO)) + if (MATCH(awk,TOKEN_INCLUDE)) + { +/* TODO: implement include */ + SETERRLIN (awk, QSE_AWK_ENOSUP, line); + return QSE_NULL; + } + else if (MATCH(awk,TOKEN_DO)) { if (get_token(awk) <= -1) return QSE_NULL; @@ -2062,6 +2063,36 @@ static qse_awk_nde_t* parse_expression (qse_awk_t* awk, qse_size_t line) return nde; } +static int assign_to_opcode (qse_awk_t* awk) +{ + /* synchronize it with qse_awk_assop_type_t in run.h */ + static int assop[] = + { + QSE_AWK_ASSOP_NONE, + QSE_AWK_ASSOP_PLUS, + QSE_AWK_ASSOP_MINUS, + QSE_AWK_ASSOP_MUL, + QSE_AWK_ASSOP_DIV, + QSE_AWK_ASSOP_IDIV, + QSE_AWK_ASSOP_MOD, + QSE_AWK_ASSOP_EXP, + QSE_AWK_ASSOP_RS, + QSE_AWK_ASSOP_LS, + QSE_AWK_ASSOP_BAND, + QSE_AWK_ASSOP_BXOR, + QSE_AWK_ASSOP_BOR + }; + + if (awk->token.type >= TOKEN_ASSIGN && + awk->token.type <= TOKEN_BOR_ASSIGN) + { + return assop[awk->token.type - TOKEN_ASSIGN]; + } + + return -1; +} + + static qse_awk_nde_t* parse_expression0 (qse_awk_t* awk, qse_size_t line) { qse_awk_nde_t* x, * y; @@ -4591,513 +4622,6 @@ static qse_awk_nde_t* parse_print (qse_awk_t* awk, qse_size_t line, int type) return (qse_awk_nde_t*)nde; } -static int get_token_into (qse_awk_t* awk, qse_awk_token_t* token) -{ - qse_cint_t c; - int n; - - do - { - if (skip_spaces(awk) <= -1) return -1; - if ((n = skip_comment(awk)) <= -1) return -1; - } - while (n >= 1); - - qse_str_clear (token->name); - token->line = awk->src.lex.line; - token->column = awk->src.lex.column; - - c = awk->src.lex.curc; - - if (c == QSE_CHAR_EOF) - { - ADD_TOKEN_STR (awk, token, QSE_T(""), 5); - SET_TOKEN_TYPE (awk, token, TOKEN_EOF); - } - else if (c == QSE_T('\n')) - { - /*ADD_TOKEN_CHAR (awk, token, QSE_T('\n'));*/ - ADD_TOKEN_STR (awk, token, QSE_T(""), 4); - SET_TOKEN_TYPE (awk, token, TOKEN_NEWLINE); - GET_CHAR (awk); - } - else if (QSE_AWK_ISDIGIT (awk, c)/*|| c == QSE_T('.')*/) - { - if (get_number (awk, token) <= -1) return -1; - } - else if (c == QSE_T('.')) - { - GET_CHAR_TO (awk, c); - - if ((awk->option & QSE_AWK_EXPLICIT) == 0 && - QSE_AWK_ISDIGIT (awk, c)) - { - awk->src.lex.curc = QSE_T('.'); - UNGET_CHAR (awk, c); - if (get_number (awk, token) <= -1) return -1; - - } - else /*if (QSE_AWK_ISSPACE (awk, c) || c == QSE_CHAR_EOF)*/ - { - SET_TOKEN_TYPE (awk, token, TOKEN_PERIOD); - ADD_TOKEN_CHAR (awk, token, QSE_T('.')); - } - /* - else - { - qse_awk_seterror ( - awk, QSE_AWK_ELXCHR, token->line, - QSE_T("floating point not followed by any valid digits")); - return -1; - } - */ - } - else if (c == QSE_T('_') || QSE_AWK_ISALPHA (awk, c)) - { - int type; - - /* identifier */ - do - { - ADD_TOKEN_CHAR (awk, token, 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_PTR(token->name), - QSE_STR_LEN(token->name)); - SET_TOKEN_TYPE (awk, token, type); - } - else if (c == QSE_T('\"')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_STR); - if (get_charstr(awk, token) <= -1) return -1; - } - -/* -// TODO: compacct the code with this table -{ QSE_T("=="), TOKEN_EQ, 0 }, -{ QSE_T("="), TOKEN_ASSIGN, 0 }, -{ QSE_T("!=") TOKEN_NE, 0 }, -{ QSE_T("!~") TOKEN_NM, 0 }, -{ QSE_T("!") TOKEN_LNOT, 0 }, -{ QSE_T(">>=") TOKEN_RS_ASSIGN, QSE_AWK_EXTRAOPS }, -{ QSE_T(">>") TOKEN_RS, 0 }, -{ QSE_T(">=") TOKEN_GE, 0 }, -{ QSE_T(">") TOKEN_GT, 0 }, -{ QSE_T(">>=") TOKEN_LS_ASSIGN, QSE_AWK_EXTRAOPS }, -{ QSE_T(">>") TOKEN_LS, 0 }, -{ QSE_T(">=") TOKEN_LE, 0 }, -{ QSE_T(">") TOKEN_LT, 0 }, -{ QSE_T("||") TOKEN_LOR, 0 }, -{ QSE_T("|=") TOKEN_BOR_ASSIGN, 0 }, -{ QSE_T("|") TOKEN_BOR, 0 }, -{ QSE_T("&&") TOKEN_LAND, 0 }, -{ QSE_T("&=") TOKEN_BAND_ASSIGN, 0 }, -{ QSE_T("&") TOKEN_BAND, 0 }, -{ QSE_T("^^=") TOKEN_BXOR_ASSIGN, QSE_AWK_EXTRAOPS }, -{ QSE_T("^^") TOKEN_BXOR, QSE_AWK_EXTRAOPS }, -{ QSE_T("^=") TOKEN_EXP_ASSIGN, 0 }, -{ QSE_T("^") TOKEN_EXP, 0 }, -{ QSE_T("++") TOKEN_PLUSPLUS, 0 }, -{ QSE_T("+=") TOKEN_PLUS_ASSIGN, 0 }, -{ QSE_T("+") TOKEN_PLUS, 0 }, -{ QSE_T("--") TOKEN_MINUSMINUS, 0 }, -{ QSE_T("-=") TOKEN_MINUS_ASSIGN, 0 }, -{ QSE_T("-") TOKEN_MINUS, 0 }, -{ QSE_T("**=") TOKEN_EXP_ASSIGN, QSE_AWK_EXTRAOPS }, -{ QSE_T("**") TOKEN_EXP, QSE_AWK_EXTRAOPS }, -{ QSE_T("*=") TOKEN_MUL_ASSIGN, 0 }, -{ QSE_T("*") TOKEN_MUL, 0 }, -{ QSE_T("//=") TOKEN_IDIV_ASSIGN, 0 }, -{ QSE_T("//") TOKEN_IDIV, QSE_AWK_EXTRAOPS }, -{ QSE_T("/=") TOKEN_DIV_ASSIGN, QSE_AWK_EXTRAOPS }, -{ QSE_T("/") TOKEN_DIV, 0 }, -{ QSE_T("%=") TOKEN_MOD_ASSIGN, 0 }, -{ QSE_T("%") TOKEN_MOD, 0 }, -{ QSE_T("~"), TOKEN_TILDE, 0 }, -{ QSE_T("("), TOKEN_LPAREN, 0 }, -{ QSE_T(")"), TOKEN_RPAREN, 0 }, -{ QSE_T("{"), TOKEN_LBRACE, 0 }, -{ QSE_T("}"), TOKEN_RBRACE, 0 }, -{ QSE_T("["), TOKEN_LBRACK, 0 }, -{ QSE_T("]"), TOKEN_RBRACK, 0 }, -{ QSE_T("$"), TOKEN_DOLLAR, 0 }, -{ QSE_T(","), TOKEN_COMMA, 0 }, -{ QSE_T(";"), TOKEN_SEMICOLON, 0 }, -{ QSE_T(":"), TOKEN_COLON, 0 }, -{ QSE_T("?"), TOKEN_QUEST, 0 }, - */ - else if (c == QSE_T('=')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_EQ); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_ASSIGN); - } - } - else if (c == QSE_T('!')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_NE); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else if (c == QSE_T('~')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_NM); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_LNOT); - } - } - else if (c == QSE_T('>')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if (c == QSE_T('>')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if ((awk->option & QSE_AWK_EXTRAOPS) && c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_RS_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_RS); - } - } - else if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_GE); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_GT); - } - } - else if (c == QSE_T('<')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - - if ((awk->option & QSE_AWK_EXTRAOPS) && c == QSE_T('<')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_LS_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_LS); - } - } - else if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_LE); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_LT); - } - } - else if (c == QSE_T('|')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if (c == QSE_T('|')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_LOR); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_BOR_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_BOR); - } - } - else if (c == QSE_T('&')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if (c == QSE_T('&')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_LAND); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_BAND_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_BAND); - } - } - else if (c == QSE_T('^')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - - if ((awk->option & QSE_AWK_EXTRAOPS) && c == QSE_T('^')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_BXOR_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_BXOR); - } - } - else if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_EXP_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_EXP); - } - } - else if (c == QSE_T('+')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if (c == QSE_T('+')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_PLUSPLUS); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_PLUS_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_PLUS); - } - } - else if (c == QSE_T('-')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if (c == QSE_T('-')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_MINUSMINUS); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_MINUS_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_MINUS); - } - } - else if (c == QSE_T('*')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - - if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_MUL_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else if (c == QSE_T('*')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_EXP_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_EXP); - } - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_MUL); - } - } - else if (c == QSE_T('/')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - - if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_DIV_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else if ((awk->option & QSE_AWK_EXTRAOPS) && c == QSE_T('/')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_IDIV_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_IDIV); - } - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_DIV); - } - } - else if (c == QSE_T('%')) - { - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR_TO (awk, c); - - if (c == QSE_T('=')) - { - SET_TOKEN_TYPE (awk, token, TOKEN_MOD_ASSIGN); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - } - else - { - SET_TOKEN_TYPE (awk, token, TOKEN_MOD); - } - } - else - { - int i; - static struct - { - qse_char_t c; - int t; - } tab[] = - { - { QSE_T('~'), TOKEN_TILDE }, - { QSE_T('('), TOKEN_LPAREN }, - { QSE_T(')'), TOKEN_RPAREN }, - { QSE_T('{'), TOKEN_LBRACE }, - { QSE_T('}'), TOKEN_RBRACE }, - { QSE_T('['), TOKEN_LBRACK }, - { QSE_T(']'), TOKEN_RBRACK }, - { QSE_T('$'), TOKEN_DOLLAR }, - { QSE_T(','), TOKEN_COMMA }, - { QSE_T(';'), TOKEN_SEMICOLON }, - { QSE_T(':'), TOKEN_COLON }, - { QSE_T('?'), TOKEN_QUEST }, - { QSE_CHAR_EOF, TOKEN_EOF } - }; - - for (i = 0; tab[i].c != QSE_CHAR_EOF; i++) - { - if (c == tab[i].c) - { - SET_TOKEN_TYPE (awk, token, tab[i].t); - ADD_TOKEN_CHAR (awk, token, c); - GET_CHAR (awk); - goto get_token_ok; - } - } - - if (c == QSE_T('\0')) - { - SETERRARG (awk, QSE_AWK_ELXCHR, token->line, QSE_T(""), 5); - } - else - { - qse_char_t cc = (qse_char_t)c; - SETERRARG (awk, QSE_AWK_ELXCHR, token->line, &cc, 1); - } - return -1; - } - -get_token_ok: - return 0; -} - -static int get_token (qse_awk_t* awk) -{ - awk->ptoken.type = awk->token.type; - awk->ptoken.line = awk->token.line; - awk->ptoken.column = awk->token.column; - - if (QSE_STR_LEN(awk->atoken.name) > 0) - { - awk->token.type = awk->atoken.type; - awk->token.line = awk->atoken.line; - awk->token.column = awk->token.column; - - qse_str_swap (awk->token.name, awk->atoken.name); - qse_str_clear (awk->atoken.name); - - return 0; - } - - return get_token_into (awk, &awk->token); -} - -static int preget_token (qse_awk_t* awk) -{ - return get_token_into (awk, &awk->atoken); -} - static int get_number (qse_awk_t* awk, qse_awk_token_t* token) { qse_cint_t c; @@ -5200,53 +4724,6 @@ static int get_number (qse_awk_t* awk, qse_awk_token_t* token) return 0; } -static int get_charstr (qse_awk_t* awk, qse_awk_token_t* token) -{ - if (awk->src.lex.curc != QSE_T('\"')) - { - /* the starting quote has been consumed before this function - * has been called */ - ADD_TOKEN_CHAR (awk, token, awk->src.lex.curc); - } - return get_string (awk, QSE_T('\"'), QSE_T('\\'), QSE_FALSE, 0, token); -} - -static int get_rexstr (qse_awk_t* awk, qse_awk_token_t* token) -{ - if (awk->src.lex.curc == QSE_T('/')) - { - /* this part of the function is different from get_charstr - * because of the way this function is called. - * this condition is met when the input is //. - * the first / has been tokenized to TOKEN_DIV already. - * if TOKEN_DIV is seen as a primary, this function is called. - * as the token buffer has been cleared by the caller and - * the token type is set to TOKEN_REX, this function can - * just return after reading the next character */ - GET_CHAR (awk); - return 0; - } - else - { - int escaped = 0; - if (awk->src.lex.curc == QSE_T('\\')) - { - /* for input like /\//, this condition is met. - * the initial escape character is added when the - * second charater is handled in get_string() */ - escaped = 1; - } - else - { - /* add other initial characters here as get_string() - * begins with reading the next character */ - ADD_TOKEN_CHAR (awk, token, awk->src.lex.curc); - } - return get_string ( - awk, QSE_T('/'), QSE_T('\\'), QSE_TRUE, escaped, token); - } -} - static int get_string ( qse_awk_t* awk, qse_char_t end_char, qse_char_t esc_char, qse_bool_t keep_esc_char, @@ -5403,6 +4880,53 @@ static int get_string ( return 0; } +static int get_charstr (qse_awk_t* awk, qse_awk_token_t* token) +{ + if (awk->src.lex.curc != QSE_T('\"')) + { + /* the starting quote has been consumed before this function + * has been called */ + ADD_TOKEN_CHAR (awk, token, awk->src.lex.curc); + } + return get_string (awk, QSE_T('\"'), QSE_T('\\'), QSE_FALSE, 0, token); +} + +static int get_rexstr (qse_awk_t* awk, qse_awk_token_t* token) +{ + if (awk->src.lex.curc == QSE_T('/')) + { + /* this part of the function is different from get_charstr + * because of the way this function is called. + * this condition is met when the input is //. + * the first / has been tokenized to TOKEN_DIV already. + * if TOKEN_DIV is seen as a primary, this function is called. + * as the token buffer has been cleared by the caller and + * the token type is set to TOKEN_REX, this function can + * just return after reading the next character */ + GET_CHAR (awk); + return 0; + } + else + { + int escaped = 0; + if (awk->src.lex.curc == QSE_T('\\')) + { + /* for input like /\//, this condition is met. + * the initial escape character is added when the + * second charater is handled in get_string() */ + escaped = 1; + } + else + { + /* add other initial characters here as get_string() + * begins with reading the next character */ + ADD_TOKEN_CHAR (awk, token, awk->src.lex.curc); + } + return get_string ( + awk, QSE_T('/'), QSE_T('\\'), QSE_TRUE, escaped, token); + } +} + static int get_char (qse_awk_t* awk) { qse_ssize_t n; @@ -5516,10 +5040,7 @@ static int skip_comment (qse_awk_t* awk) if (c == QSE_T('#')) { - do - { - GET_CHAR_TO (awk, c); - } + do { GET_CHAR_TO (awk, c); } while (c != QSE_T('\n') && c != QSE_CHAR_EOF); if (!(awk->option & QSE_AWK_NEWLINE)) GET_CHAR (awk); @@ -5573,6 +5094,245 @@ static int skip_comment (qse_awk_t* awk) return 0; } +static int get_operators (qse_awk_t* awk, qse_cint_t c, qse_awk_token_t* token) +{ + struct ops_t + { + const qse_char_t* str; + qse_size_t len; + int tid; + int opt; + }; + + static struct ops_t ops[] = + { + { QSE_T("=="), 2, TOKEN_EQ, 0 }, + { QSE_T("="), 1, TOKEN_ASSIGN, 0 }, + { QSE_T("!="), 2, TOKEN_NE, 0 }, + { QSE_T("!~"), 2, TOKEN_NM, 0 }, + { QSE_T("!"), 1, TOKEN_LNOT, 0 }, + { QSE_T(">>="), 3, TOKEN_RS_ASSIGN, QSE_AWK_EXTRAOPS }, + { QSE_T(">>"), 2, TOKEN_RS, 0 }, + { QSE_T(">="), 2, TOKEN_GE, 0 }, + { QSE_T(">"), 1, TOKEN_GT, 0 }, + { QSE_T("<<="), 3, TOKEN_LS_ASSIGN, QSE_AWK_EXTRAOPS }, + { QSE_T("<<"), 2, TOKEN_LS, 0 }, + { QSE_T("<="), 2, TOKEN_LE, 0 }, + { QSE_T("<"), 1, TOKEN_LT, 0 }, + { QSE_T("||"), 2, TOKEN_LOR, 0 }, + { QSE_T("|="), 2, TOKEN_BOR_ASSIGN, 0 }, + { QSE_T("|"), 1, TOKEN_BOR, 0 }, + { QSE_T("&&"), 2, TOKEN_LAND, 0 }, + { QSE_T("&="), 2, TOKEN_BAND_ASSIGN, 0 }, + { QSE_T("&"), 1, TOKEN_BAND, 0 }, + { QSE_T("^^="), 3, TOKEN_BXOR_ASSIGN, QSE_AWK_EXTRAOPS }, + { QSE_T("^^"), 2, TOKEN_BXOR, QSE_AWK_EXTRAOPS }, + { QSE_T("^="), 2, TOKEN_EXP_ASSIGN, 0 }, + { QSE_T("^"), 1, TOKEN_EXP, 0 }, + { QSE_T("++"), 2, TOKEN_PLUSPLUS, 0 }, + { QSE_T("+="), 2, TOKEN_PLUS_ASSIGN, 0 }, + { QSE_T("+"), 1, TOKEN_PLUS, 0 }, + { QSE_T("--"), 2, TOKEN_MINUSMINUS, 0 }, + { QSE_T("-="), 2, TOKEN_MINUS_ASSIGN, 0 }, + { QSE_T("-"), 1, TOKEN_MINUS, 0 }, + { QSE_T("**="), 3, TOKEN_EXP_ASSIGN, QSE_AWK_EXTRAOPS }, + { QSE_T("**"), 2, TOKEN_EXP, QSE_AWK_EXTRAOPS }, + { QSE_T("*="), 2, TOKEN_MUL_ASSIGN, 0 }, + { QSE_T("*"), 1, TOKEN_MUL, 0 }, + { QSE_T("//="), 3, TOKEN_IDIV_ASSIGN, 0 }, + { QSE_T("//"), 2, TOKEN_IDIV, QSE_AWK_EXTRAOPS }, + { QSE_T("/="), 2, TOKEN_DIV_ASSIGN, QSE_AWK_EXTRAOPS }, + { QSE_T("/"), 1, TOKEN_DIV, 0 }, + { QSE_T("%="), 2, TOKEN_MOD_ASSIGN, 0 }, + { QSE_T("%"), 1, TOKEN_MOD, 0 }, + { QSE_T("~"), 1, TOKEN_TILDE, 0 }, + { QSE_T("("), 1, TOKEN_LPAREN, 0 }, + { QSE_T(")"), 1, TOKEN_RPAREN, 0 }, + { QSE_T("{"), 1, TOKEN_LBRACE, 0 }, + { QSE_T("}"), 1, TOKEN_RBRACE, 0 }, + { QSE_T("["), 1, TOKEN_LBRACK, 0 }, + { QSE_T("]"), 1, TOKEN_RBRACK, 0 }, + { QSE_T("$"), 1, TOKEN_DOLLAR, 0 }, + { QSE_T(","), 1, TOKEN_COMMA, 0 }, + { QSE_T(";"), 1, TOKEN_SEMICOLON, 0 }, + { QSE_T(":"), 1, TOKEN_COLON, 0 }, + { QSE_T("?"), 1, TOKEN_QUEST, 0 }, + { QSE_NULL, 0, 0, 0 } + }; + + struct ops_t* p; + int idx = 0; + + /* note that the loop below is not generaic enough. + * you must keep the operators strings in a particular order */ + + for (p = ops; p->str != QSE_NULL; ) + { + if (p->opt == 0 || (awk->option & p->opt)) + { + if (p->str[idx] == QSE_T('\0')) + { + ADD_TOKEN_STR (awk, token, p->str, p->len); + SET_TOKEN_TYPE (awk, token, p->tid); + return 1; + } + + if (c == p->str[idx]) + { + idx++; + GET_CHAR_TO (awk, c); + continue; + } + } + + p++; + } + + return 0; +} + +static int get_token_into (qse_awk_t* awk, qse_awk_token_t* token) +{ + qse_cint_t c; + int n; + + do + { + if (skip_spaces(awk) <= -1) return -1; + if ((n = skip_comment(awk)) <= -1) return -1; + } + while (n >= 1); + + qse_str_clear (token->name); + token->line = awk->src.lex.line; + token->column = awk->src.lex.column; + + c = awk->src.lex.curc; + + if (c == QSE_CHAR_EOF) + { + ADD_TOKEN_STR (awk, token, QSE_T(""), 5); + SET_TOKEN_TYPE (awk, token, TOKEN_EOF); + } + else if (c == QSE_T('\n')) + { + /*ADD_TOKEN_CHAR (awk, token, QSE_T('\n'));*/ + ADD_TOKEN_STR (awk, token, QSE_T(""), 4); + SET_TOKEN_TYPE (awk, token, TOKEN_NEWLINE); + GET_CHAR (awk); + } + else if (QSE_AWK_ISDIGIT (awk, c)/*|| c == QSE_T('.')*/) + { + if (get_number (awk, token) <= -1) return -1; + } + else if (c == QSE_T('.')) + { + GET_CHAR_TO (awk, c); + + if ((awk->option & QSE_AWK_EXPLICIT) == 0 && + QSE_AWK_ISDIGIT (awk, c)) + { + awk->src.lex.curc = QSE_T('.'); + UNGET_CHAR (awk, c); + if (get_number (awk, token) <= -1) return -1; + + } + else /*if (QSE_AWK_ISSPACE (awk, c) || c == QSE_CHAR_EOF)*/ + { + SET_TOKEN_TYPE (awk, token, TOKEN_PERIOD); + ADD_TOKEN_CHAR (awk, token, QSE_T('.')); + } + /* + else + { + qse_awk_seterror ( + awk, QSE_AWK_ELXCHR, token->line, + QSE_T("floating point not followed by any valid digits")); + return -1; + } + */ + } + else if (c == QSE_T('_') || QSE_AWK_ISALPHA (awk, c)) + { + int type; + + /* identifier */ + do + { + ADD_TOKEN_CHAR (awk, token, 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_PTR(token->name), + QSE_STR_LEN(token->name)); + SET_TOKEN_TYPE (awk, token, type); + } + else if (c == QSE_T('\"')) + { + SET_TOKEN_TYPE (awk, token, TOKEN_STR); + if (get_charstr(awk, token) <= -1) return -1; + } + else + { + n = get_operators (awk, c, token); + if (n <= -1) return -1; + if (n == 0) + { + /* not handled yet */ + if (c == QSE_T('\0')) + { + SETERRARG ( + awk, QSE_AWK_ELXCHR, token->line, + QSE_T(""), 5 + ); + } + else + { + qse_char_t cc = (qse_char_t)c; + SETERRARG ( + awk, QSE_AWK_ELXCHR, token->line, + &cc, 1 + ); + } + return -1; + } + } + +/*get_token_ok:*/ + return 0; +} + +static int get_token (qse_awk_t* awk) +{ + awk->ptoken.type = awk->token.type; + awk->ptoken.line = awk->token.line; + awk->ptoken.column = awk->token.column; + + if (QSE_STR_LEN(awk->atoken.name) > 0) + { + awk->token.type = awk->atoken.type; + awk->token.line = awk->atoken.line; + awk->token.column = awk->token.column; + + qse_str_swap (awk->token.name, awk->atoken.name); + qse_str_clear (awk->atoken.name); + + return 0; + } + + return get_token_into (awk, &awk->token); +} + +static int preget_token (qse_awk_t* awk) +{ + return get_token_into (awk, &awk->atoken); +} + + static int classify_ident ( qse_awk_t* awk, const qse_char_t* name, qse_size_t len) { @@ -5649,35 +5409,6 @@ static int classify_ident ( return TOKEN_IDENT; } -static int assign_to_opcode (qse_awk_t* awk) -{ - /* synchronize it with qse_awk_assop_type_t in run.h */ - static int assop[] = - { - QSE_AWK_ASSOP_NONE, - QSE_AWK_ASSOP_PLUS, - QSE_AWK_ASSOP_MINUS, - QSE_AWK_ASSOP_MUL, - QSE_AWK_ASSOP_DIV, - QSE_AWK_ASSOP_IDIV, - QSE_AWK_ASSOP_MOD, - QSE_AWK_ASSOP_EXP, - QSE_AWK_ASSOP_RS, - QSE_AWK_ASSOP_LS, - QSE_AWK_ASSOP_BAND, - QSE_AWK_ASSOP_BXOR, - QSE_AWK_ASSOP_BOR - }; - - if (awk->token.type >= TOKEN_ASSIGN && - awk->token.type <= TOKEN_BOR_ASSIGN) - { - return assop[awk->token.type - TOKEN_ASSIGN]; - } - - return -1; -} - static int is_plain_var (qse_awk_nde_t* nde) { return nde->type == QSE_AWK_NDE_GBL || diff --git a/qse/lib/awk/parse.h b/qse/lib/awk/parse.h index 4cbc4f9d..0ecc76af 100644 --- a/qse/lib/awk/parse.h +++ b/qse/lib/awk/parse.h @@ -1,5 +1,5 @@ /* - * $Id: parse.h 75 2009-02-22 14:10:34Z hyunghwan.chung $ + * $Id: parse.h 239 2009-07-18 12:02:24Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -36,6 +36,7 @@ enum kw_t KW_GLOBAL, KW_IF, KW_IN, + KW_INCLUDE, KW_LOCAL, KW_NEXT, KW_NEXTFILE,