This commit is contained in:
hyung-hwan 2007-12-06 00:20:44 +00:00
parent df755c2bd1
commit 3b82e5c00f
3 changed files with 46 additions and 30 deletions

View File

@ -2366,15 +2366,19 @@ static ase_awk_nde_t* parse_concat (ase_awk_t* awk, ase_size_t line)
{
if (MATCH(awk,TOKEN_PERIOD))
{
if ((awk->option & ASE_AWK_EXPLICIT) == 0) break;
if (!(awk->option & ASE_AWK_EXPLICIT)) break;
if (get_token(awk) == -1) return ASE_NULL;
}
else if (MATCH(awk,TOKEN_LPAREN) ||
MATCH(awk,TOKEN_DOLLAR) ||
awk->token.type >= TOKEN_GETLINE)
MATCH(awk,TOKEN_PLUS) ||
MATCH(awk,TOKEN_MINUS) ||
MATCH(awk,TOKEN_PLUSPLUS) ||
MATCH(awk,TOKEN_MINUSMINUS) ||
awk->token.type >= TOKEN_GETLINE)
{
/* TODO: is the check above sufficient? */
if ((awk->option & ASE_AWK_IMPLICIT) == 0) break;
if (!(awk->option & ASE_AWK_IMPLICIT)) break;
}
else break;
@ -2558,6 +2562,16 @@ static ase_awk_nde_t* parse_increment (ase_awk_t* awk, ase_size_t line)
left = parse_primary (awk, line);
if (left == ASE_NULL) return ASE_NULL;
if (awk->option & ASE_AWK_IMPLICIT)
{
/* concatenation operation by whitepaces are allowed
* if this option is set. the ++/-- operator following
* the primary should be treated specially.
* for example, "abc" ++ 10 => "abc" . ++10
*/
if (!is_var(left)) return left;
}
/* check for postfix increment operator */
opcode2 = MATCH(awk,TOKEN_PLUSPLUS)? ASE_AWK_INCOP_PLUS:
MATCH(awk,TOKEN_MINUSMINUS)? ASE_AWK_INCOP_MINUS: -1;
@ -5374,12 +5388,14 @@ static int deparse (ase_awk_t* awk)
if (ase_awk_putsrcstr (awk, ASE_T(" ")) == -1) EXIT_DEPARSE ();
if (ase_awk_prnpt (awk, nde) == -1) EXIT_DEPARSE ();
/*
if (awk->option & ASE_AWK_CRLF)
{
if (put_char (awk, ASE_T('\r')) == -1) EXIT_DEPARSE ();
}
if (put_char (awk, ASE_T('\n')) == -1) EXIT_DEPARSE ();
*/
}
if (flush_out (awk) == -1) EXIT_DEPARSE ();

View File

@ -18,37 +18,37 @@ static const ase_char_t* assop_str[] =
ASE_T("**=")
};
static const ase_char_t* binop_str[] =
static const ase_char_t* binop_str[][2] =
{
ASE_T("||"),
ASE_T("&&"),
ASE_T("in"),
{ ASE_T("||"), ASE_T("||") },
{ ASE_T("&&"), ASE_T("&&") },
{ ASE_T("in"), ASE_T("in") },
ASE_T("|"),
ASE_T("^"),
ASE_T("&"),
{ ASE_T("|"), ASE_T("|") },
{ ASE_T("^"), ASE_T("^") },
{ ASE_T("&"), ASE_T("&") },
ASE_T("=="),
ASE_T("!="),
ASE_T(">"),
ASE_T(">="),
ASE_T("<"),
ASE_T("<="),
{ ASE_T("=="), ASE_T("==") },
{ ASE_T("!="), ASE_T("!=") },
{ ASE_T(">"), ASE_T(">") },
{ ASE_T(">="), ASE_T(">=") },
{ ASE_T("<"), ASE_T("<") },
{ ASE_T("<="), ASE_T("<=") },
ASE_T("<<"),
ASE_T(">>"),
{ ASE_T("<<"), ASE_T("<<") },
{ ASE_T(">>"), ASE_T(">>") },
ASE_T("+"),
ASE_T("-"),
ASE_T("*"),
ASE_T("/"),
ASE_T("//"),
ASE_T("%"),
ASE_T("**"),
{ ASE_T("+"), ASE_T("+") },
{ ASE_T("-"), ASE_T("-") },
{ ASE_T("*"), ASE_T("*") },
{ ASE_T("/"), ASE_T("/") },
{ ASE_T("//"), ASE_T("//") },
{ ASE_T("%"), ASE_T("%") },
{ ASE_T("**"), ASE_T("**") },
ASE_T(" "),
ASE_T("~"),
ASE_T("!~")
{ ASE_T(" "), ASE_T(".") },
{ ASE_T("~"), ASE_T("~") },
{ ASE_T("!~"), ASE_T("!~") }
};
static const ase_char_t* unrop_str[] =
@ -167,7 +167,7 @@ static int print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
ASE_ASSERT (px->left->next == ASE_NULL);
PUT_SRCSTR (awk, ASE_T(" "));
PUT_SRCSTR (awk, binop_str[px->opcode]);
PUT_SRCSTR (awk, binop_str[px->opcode][(awk->option & ASE_AWK_IMPLICIT)? 0: 1]);
PUT_SRCSTR (awk, ASE_T(" "));
if (px->right->type == ASE_AWK_NDE_ASS)

View File

@ -1,6 +1,6 @@
#!/bin/sh
OPTION=-explicit
OPTION="-explicit -implicit"
run_script_for_init()
{