* changed the explicit concatenation operator from a period to %% for qse_awk_t
* added the concatenative assignment operator(%%=) for qse_awk_t
This commit is contained in:
parent
8da90da039
commit
4403c33aea
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: parse.c 547 2011-08-13 16:04:14Z hyunghwan.chung $
|
||||
* $Id: parse.c 551 2011-08-15 13:52:48Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -38,6 +38,7 @@ enum tok_t
|
||||
TOK_IDIV_ASSN,
|
||||
TOK_MOD_ASSN,
|
||||
TOK_EXP_ASSN,
|
||||
TOK_CONCAT_ASSN,
|
||||
TOK_RS_ASSN,
|
||||
TOK_LS_ASSN,
|
||||
TOK_BAND_ASSN,
|
||||
@ -70,6 +71,7 @@ enum tok_t
|
||||
TOK_LS,
|
||||
TOK_IN,
|
||||
TOK_EXP,
|
||||
TOK_CONCAT,
|
||||
|
||||
TOK_LPAREN,
|
||||
TOK_RPAREN,
|
||||
@ -80,7 +82,6 @@ enum tok_t
|
||||
|
||||
TOK_DOLLAR,
|
||||
TOK_COMMA,
|
||||
TOK_PERIOD,
|
||||
TOK_SEMICOLON,
|
||||
TOK_COLON,
|
||||
TOK_QUEST,
|
||||
@ -3090,6 +3091,7 @@ static int assign_to_opcode (qse_awk_t* awk)
|
||||
QSE_AWK_ASSOP_IDIV,
|
||||
QSE_AWK_ASSOP_MOD,
|
||||
QSE_AWK_ASSOP_EXP,
|
||||
QSE_AWK_ASSOP_CONCAT,
|
||||
QSE_AWK_ASSOP_RS,
|
||||
QSE_AWK_ASSOP_LS,
|
||||
QSE_AWK_ASSOP_BAND,
|
||||
@ -3844,9 +3846,8 @@ static qse_awk_nde_t* parse_concat (
|
||||
qse_awk_nde_t* tmp;
|
||||
qse_awk_loc_t rloc;
|
||||
|
||||
if (MATCH(awk,TOK_PERIOD))
|
||||
if (MATCH(awk,TOK_CONCAT))
|
||||
{
|
||||
if (!(awk->option & QSE_AWK_EXPLICIT)) break;
|
||||
if (get_token(awk) <= -1) goto oops;
|
||||
}
|
||||
else if (MATCH(awk,TOK_LPAREN) ||
|
||||
@ -5759,6 +5760,8 @@ static int get_symbols (qse_awk_t* awk, qse_cint_t c, qse_awk_tok_t* tok)
|
||||
{ QSE_T("/"), 1, TOK_DIV, 0 },
|
||||
{ QSE_T("\\="), 2, TOK_IDIV_ASSN, QSE_AWK_EXTRAOPS },
|
||||
{ QSE_T("\\"), 1, TOK_IDIV, QSE_AWK_EXTRAOPS },
|
||||
{ QSE_T("%%="), 3, TOK_CONCAT_ASSN, QSE_AWK_EXPLICIT },
|
||||
{ QSE_T("%%"), 2, TOK_CONCAT, QSE_AWK_EXPLICIT },
|
||||
{ QSE_T("%="), 2, TOK_MOD_ASSN, 0 },
|
||||
{ QSE_T("%"), 1, TOK_MOD, 0 },
|
||||
{ QSE_T("~"), 1, TOK_TILDE, 0 },
|
||||
@ -5859,18 +5862,18 @@ retry:
|
||||
lc = awk->sio.last;
|
||||
GET_CHAR_TO (awk, c);
|
||||
|
||||
if (!(awk->option & QSE_AWK_EXPLICIT) &&
|
||||
QSE_AWK_ISDIGIT (awk, c))
|
||||
{
|
||||
/* for a token such as .123 */
|
||||
unget_char (awk, &awk->sio.last);
|
||||
awk->sio.last = lc;
|
||||
|
||||
if (QSE_AWK_ISDIGIT (awk, c))
|
||||
{
|
||||
/* for a token such as .123 */
|
||||
if (get_number (awk, tok) <= -1) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
SET_TOKEN_TYPE (awk, tok, TOK_PERIOD);
|
||||
ADD_TOKEN_CHAR (awk, tok, QSE_T('.'));
|
||||
c = QSE_T('.');
|
||||
goto try_get_symbols;
|
||||
}
|
||||
}
|
||||
else if (c == QSE_T('_') || QSE_AWK_ISALPHA (awk, c))
|
||||
@ -5899,6 +5902,7 @@ retry:
|
||||
}
|
||||
else
|
||||
{
|
||||
try_get_symbols:
|
||||
n = get_symbols (awk, c, tok);
|
||||
if (n <= -1) return -1;
|
||||
if (n == 0)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.c 549 2011-08-14 09:07:31Z hyunghwan.chung $
|
||||
* $Id: run.c 551 2011-08-15 13:52:48Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -3278,6 +3278,7 @@ static qse_awk_val_t* eval_assignment (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
eval_binop_idiv,
|
||||
eval_binop_mod,
|
||||
eval_binop_exp,
|
||||
eval_binop_concat,
|
||||
eval_binop_rshift,
|
||||
eval_binop_lshift,
|
||||
eval_binop_band,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.h 441 2011-04-22 14:28:43Z hyunghwan.chung $
|
||||
* $Id: run.h 551 2011-08-15 13:52:48Z hyunghwan.chung $
|
||||
*
|
||||
Copyright 2006-2011 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
@ -33,6 +33,7 @@ enum qse_awk_assop_type_t
|
||||
QSE_AWK_ASSOP_IDIV, /* //= */
|
||||
QSE_AWK_ASSOP_MOD, /* %= */
|
||||
QSE_AWK_ASSOP_EXP, /* **= */
|
||||
QSE_AWK_ASSOP_CONCAT, /* %%= */
|
||||
QSE_AWK_ASSOP_RS, /* >>= */
|
||||
QSE_AWK_ASSOP_LS, /* <<= */
|
||||
QSE_AWK_ASSOP_BAND, /* &= */
|
||||
|
@ -10,5 +10,10 @@ BEGIN {
|
||||
print c;
|
||||
|
||||
print 99++c;
|
||||
|
||||
|
||||
x="he" "ll" %% "o";
|
||||
x%%=" world"
|
||||
print x;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
BEGIN {
|
||||
while ("cat lang-033.awk" | getline x > 0)
|
||||
while ("cat /etc/passwd" | getline x > 0)
|
||||
print x
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user