*** empty log message ***

This commit is contained in:
hyung-hwan 2006-04-29 12:41:47 +00:00
parent 35fc7484da
commit 1a01c08001
2 changed files with 22 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c,v 1.95 2006-04-29 12:09:29 bacon Exp $ * $Id: parse.c,v 1.96 2006-04-29 12:41:47 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -162,6 +162,7 @@ static int __skip_spaces (xp_awk_t* awk);
static int __skip_comment (xp_awk_t* awk); static int __skip_comment (xp_awk_t* awk);
static int __classify_ident (xp_awk_t* awk, const xp_char_t* ident); static int __classify_ident (xp_awk_t* awk, const xp_char_t* ident);
static int __assign_to_opcode (xp_awk_t* awk); static int __assign_to_opcode (xp_awk_t* awk);
static int __is_plain_var (xp_awk_nde_t* nde);
struct __kwent struct __kwent
{ {
@ -1336,10 +1337,7 @@ static xp_awk_nde_t* __parse_in (xp_awk_t* awk)
return XP_NULL; return XP_NULL;
} }
if (right->type != XP_AWK_NDE_NAMED && if (!__is_plain_var(right))
right->type != XP_AWK_NDE_GLOBAL &&
right->type != XP_AWK_NDE_LOCAL &&
right->type != XP_AWK_NDE_ARG)
{ {
xp_awk_clrpt (right); xp_awk_clrpt (right);
xp_awk_clrpt (left); xp_awk_clrpt (left);
@ -2178,11 +2176,17 @@ static xp_awk_nde_t* __parse_for (xp_awk_t* awk)
if (MATCH(awk,TOKEN_SEMICOLON)) init = XP_NULL; if (MATCH(awk,TOKEN_SEMICOLON)) init = XP_NULL;
else else
{ {
/* this line is very ugly. it checks the entire next
* expression or the first element in the expression
* is wrapped by a parenthesis */
int no_foreach = MATCH(awk,TOKEN_LPAREN);
init = __parse_expression (awk); init = __parse_expression (awk);
if (init == XP_NULL) return XP_NULL; if (init == XP_NULL) return XP_NULL;
if (init->type == XP_AWK_NDE_EXP_BIN && if (!no_foreach && init->type == XP_AWK_NDE_EXP_BIN &&
((xp_awk_nde_exp_t*)init)->opcode == XP_AWK_BINOP_IN) ((xp_awk_nde_exp_t*)init)->opcode == XP_AWK_BINOP_IN &&
__is_plain_var(((xp_awk_nde_exp_t*)init)->left))
{ {
/* switch to foreach */ /* switch to foreach */
@ -3168,3 +3172,11 @@ static int __assign_to_opcode (xp_awk_t* awk)
return -1; return -1;
} }
static int __is_plain_var (xp_awk_nde_t* nde)
{
return nde->type == XP_AWK_NDE_GLOBAL ||
nde->type == XP_AWK_NDE_LOCAL ||
nde->type == XP_AWK_NDE_ARG ||
nde->type == XP_AWK_NDE_NAMED;
}

View File

@ -1,5 +1,5 @@
/* /*
* $Id: tree.c,v 1.43 2006-04-29 12:09:29 bacon Exp $ * $Id: tree.c,v 1.44 2006-04-29 12:41:47 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -25,6 +25,8 @@ static const xp_char_t* __binop_str[] =
{ {
XP_TEXT("||"), XP_TEXT("||"),
XP_TEXT("&&"), XP_TEXT("&&"),
XP_TEXT("in"),
XP_TEXT("|"), XP_TEXT("|"),
XP_TEXT("^"), XP_TEXT("^"),
XP_TEXT("&"), XP_TEXT("&"),
@ -46,7 +48,6 @@ static const xp_char_t* __binop_str[] =
XP_TEXT("%"), XP_TEXT("%"),
XP_TEXT("**"), XP_TEXT("**"),
XP_TEXT("in"),
XP_TEXT("~"), XP_TEXT("~"),
XP_TEXT("!~") XP_TEXT("!~")
}; };