This commit is contained in:
hyung-hwan 2008-07-15 07:53:31 +00:00
parent 95b36c4c8c
commit 57aa2517e1

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c 242 2008-07-13 14:20:48Z baconevi $ * $Id: parse.c 243 2008-07-14 13:53:31Z baconevi $
* *
* {License} * {License}
*/ */
@ -163,7 +163,7 @@ static ase_awk_nde_t* parse_expression0 (ase_awk_t* awk, ase_size_t line);
static ase_awk_nde_t* parse_basic_expr (ase_awk_t* awk, ase_size_t line); static ase_awk_nde_t* parse_basic_expr (ase_awk_t* awk, ase_size_t line);
static ase_awk_nde_t* parse_binary_expr ( static ase_awk_nde_t* parse_binary_expr (
ase_awk_t* awk, ase_size_t line, const binmap_t* binmap, ase_awk_t* awk, ase_size_t line, int skipnl, const binmap_t* binmap,
ase_awk_nde_t*(*next_level_func)(ase_awk_t*,ase_size_t)); ase_awk_nde_t*(*next_level_func)(ase_awk_t*,ase_size_t));
static ase_awk_nde_t* parse_logical_or (ase_awk_t* awk, ase_size_t line); static ase_awk_nde_t* parse_logical_or (ase_awk_t* awk, ase_size_t line);
@ -2110,7 +2110,7 @@ static ase_awk_nde_t* parse_basic_expr (ase_awk_t* awk, ase_size_t line)
} }
static ase_awk_nde_t* parse_binary_expr ( static ase_awk_nde_t* parse_binary_expr (
ase_awk_t* awk, ase_size_t line, const binmap_t* binmap, ase_awk_t* awk, ase_size_t line, int skipnl, const binmap_t* binmap,
ase_awk_nde_t*(*next_level_func)(ase_awk_t*,ase_size_t)) ase_awk_nde_t*(*next_level_func)(ase_awk_t*,ase_size_t))
{ {
ase_awk_nde_exp_t* nde; ase_awk_nde_exp_t* nde;
@ -2137,11 +2137,15 @@ static ase_awk_nde_t* parse_binary_expr (
} }
if (!matched) break; if (!matched) break;
do
{
if (get_token(awk) == -1) if (get_token(awk) == -1)
{ {
ase_awk_clrpt (awk, left); ase_awk_clrpt (awk, left);
return ASE_NULL; return ASE_NULL;
} }
}
while (skipnl && MATCH(awk,TOKEN_NEWLINE));
right = next_level_func (awk, awk->token.line); right = next_level_func (awk, awk->token.line);
if (right == ASE_NULL) if (right == ASE_NULL)
@ -2182,7 +2186,7 @@ static ase_awk_nde_t* parse_logical_or (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return parse_binary_expr (awk, line, map, parse_logical_and); return parse_binary_expr (awk, line, 1, map, parse_logical_and);
} }
static ase_awk_nde_t* parse_logical_and (ase_awk_t* awk, ase_size_t line) static ase_awk_nde_t* parse_logical_and (ase_awk_t* awk, ase_size_t line)
@ -2193,7 +2197,7 @@ static ase_awk_nde_t* parse_logical_and (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return parse_binary_expr (awk, line, map, parse_in); return parse_binary_expr (awk, line, 1, map, parse_in);
} }
static ase_awk_nde_t* parse_in (ase_awk_t* awk, ase_size_t line) static ase_awk_nde_t* parse_in (ase_awk_t* awk, ase_size_t line)
@ -2205,7 +2209,7 @@ static ase_awk_nde_t* parse_in (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return parse_binary_expr (awk, line, map, parse_regex_match); return parse_binary_expr (awk, line, 0, map, parse_regex_match);
*/ */
ase_awk_nde_exp_t* nde; ase_awk_nde_exp_t* nde;
@ -2276,7 +2280,7 @@ static ase_awk_nde_t* parse_regex_match (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 }, { TOKEN_EOF, 0 },
}; };
return parse_binary_expr (awk, line, map, parse_bitwise_or); return parse_binary_expr (awk, line, 0, map, parse_bitwise_or);
} }
static ase_awk_nde_t* parse_bitwise_or (ase_awk_t* awk, ase_size_t line) static ase_awk_nde_t* parse_bitwise_or (ase_awk_t* awk, ase_size_t line)
@ -2294,7 +2298,7 @@ static ase_awk_nde_t* parse_bitwise_or (ase_awk_t* awk, ase_size_t line)
}; };
return parse_binary_expr ( return parse_binary_expr (
awk, line, map, parse_bitwise_xor); awk, line, 0, map, parse_bitwise_xor);
} }
} }
@ -2419,7 +2423,7 @@ static ase_awk_nde_t* parse_bitwise_xor (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return parse_binary_expr (awk, line, map, parse_bitwise_and); return parse_binary_expr (awk, line, 0, map, parse_bitwise_and);
} }
static ase_awk_nde_t* parse_bitwise_and (ase_awk_t* awk, ase_size_t line) static ase_awk_nde_t* parse_bitwise_and (ase_awk_t* awk, ase_size_t line)
@ -2430,7 +2434,7 @@ static ase_awk_nde_t* parse_bitwise_and (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return parse_binary_expr (awk, line, map, parse_equality); return parse_binary_expr (awk, line, 0, map, parse_equality);
} }
static ase_awk_nde_t* parse_equality (ase_awk_t* awk, ase_size_t line) static ase_awk_nde_t* parse_equality (ase_awk_t* awk, ase_size_t line)
@ -2442,7 +2446,7 @@ static ase_awk_nde_t* parse_equality (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return parse_binary_expr (awk, line, map, parse_relational); return parse_binary_expr (awk, line, 0, map, parse_relational);
} }
static ase_awk_nde_t* parse_relational (ase_awk_t* awk, ase_size_t line) static ase_awk_nde_t* parse_relational (ase_awk_t* awk, ase_size_t line)
@ -2456,7 +2460,7 @@ static ase_awk_nde_t* parse_relational (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return parse_binary_expr (awk, line, map, return parse_binary_expr (awk, line, 0, map,
((awk->option & ASE_AWK_SHIFT)? parse_shift: parse_concat)); ((awk->option & ASE_AWK_SHIFT)? parse_shift: parse_concat));
} }
@ -2469,7 +2473,7 @@ static ase_awk_nde_t* parse_shift (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return parse_binary_expr (awk, line, map, parse_concat); return parse_binary_expr (awk, line, 0, map, parse_concat);
} }
static ase_awk_nde_t* parse_concat (ase_awk_t* awk, ase_size_t line) static ase_awk_nde_t* parse_concat (ase_awk_t* awk, ase_size_t line)
@ -2540,7 +2544,7 @@ static ase_awk_nde_t* parse_additive (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return parse_binary_expr (awk, line, map, parse_multiplicative); return parse_binary_expr (awk, line, 0, map, parse_multiplicative);
} }
static ase_awk_nde_t* parse_multiplicative (ase_awk_t* awk, ase_size_t line) static ase_awk_nde_t* parse_multiplicative (ase_awk_t* awk, ase_size_t line)
@ -2555,7 +2559,7 @@ static ase_awk_nde_t* parse_multiplicative (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return parse_binary_expr (awk, line, map, parse_unary); return parse_binary_expr (awk, line, 0, map, parse_unary);
} }
static ase_awk_nde_t* parse_unary (ase_awk_t* awk, ase_size_t line) static ase_awk_nde_t* parse_unary (ase_awk_t* awk, ase_size_t line)
@ -2613,7 +2617,7 @@ static ase_awk_nde_t* parse_exponent (ase_awk_t* awk, ase_size_t line)
{ TOKEN_EOF, 0 } { TOKEN_EOF, 0 }
}; };
return parse_binary_expr (awk, line, map, parse_unary_exp); return parse_binary_expr (awk, line, 0, map, parse_unary_exp);
} }
static ase_awk_nde_t* parse_unary_exp (ase_awk_t* awk, ase_size_t line) static ase_awk_nde_t* parse_unary_exp (ase_awk_t* awk, ase_size_t line)
@ -4794,12 +4798,6 @@ static int get_token (ase_awk_t* awk)
SET_TOKEN_TYPE (awk, TOKEN_BXOR); SET_TOKEN_TYPE (awk, TOKEN_BXOR);
} }
} }
else if (c == ASE_T('~'))
{
SET_TOKEN_TYPE (awk, TOKEN_TILDE);
ADD_TOKEN_CHAR (awk, c);
GET_CHAR (awk);
}
else if (c == ASE_T('+')) else if (c == ASE_T('+'))
{ {
ADD_TOKEN_CHAR (awk, c); ADD_TOKEN_CHAR (awk, c);
@ -4949,6 +4947,7 @@ static int get_token (ase_awk_t* awk)
int t; int t;
} tab[] = } tab[] =
{ {
{ ASE_T('~'), TOKEN_TILDE },
{ ASE_T('('), TOKEN_LPAREN }, { ASE_T('('), TOKEN_LPAREN },
{ ASE_T(')'), TOKEN_RPAREN }, { ASE_T(')'), TOKEN_RPAREN },
{ ASE_T('{'), TOKEN_LBRACE }, { ASE_T('{'), TOKEN_LBRACE },
@ -4980,6 +4979,7 @@ static int get_token (ase_awk_t* awk)
} }
get_token_ok: get_token_ok:
wprintf (L"token = [%S]\n", awk->token.name.buf);
return 0; return 0;
} }
@ -5349,7 +5349,12 @@ static int skip_spaces (ase_awk_t* awk)
cr = 1; cr = 1;
GET_CHAR_TO (awk, c); GET_CHAR_TO (awk, c);
} }
if (c != ASE_T('\n')) if (c == ASE_T('\n'))
{
GET_CHAR_TO (awk, c);
continue;
}
else
{ {
UNGET_CHAR (awk, c); UNGET_CHAR (awk, c);
if (cr) UNGET_CHAR(awk, ASE_T('\r')); if (cr) UNGET_CHAR(awk, ASE_T('\r'));