*** empty log message ***

This commit is contained in:
hyung-hwan 2006-04-10 15:52:07 +00:00
parent 29848c7356
commit 951a4bb95b
3 changed files with 63 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h,v 1.46 2006-04-09 15:31:13 bacon Exp $
* $Id: awk.h,v 1.47 2006-04-10 15:52:07 bacon Exp $
*/
#ifndef _XP_AWK_AWK_H_
@ -59,6 +59,7 @@ enum
XP_AWK_ERBRACK, /* right bracket expected */
XP_AWK_ECOMMA, /* comma expected */
XP_AWK_ESEMICOLON, /* semicolon expected */
XP_AWK_ECOLON, /* colon expected */
XP_AWK_EEXPRESSION, /* expression expected */
XP_AWK_EWHILE, /* keyword 'while' is expected */

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c,v 1.8 2006-04-09 15:31:13 bacon Exp $
* $Id: err.c,v 1.9 2006-04-10 15:52:07 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -29,7 +29,9 @@ const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk)
XP_TEXT("right bracket expected"),
XP_TEXT("comma expected"),
XP_TEXT("semicolon expected"),
XP_TEXT("colon expected"),
XP_TEXT("expression expected"),
XP_TEXT("keyword 'while' expected"),
XP_TEXT("assignment statement expected"),
XP_TEXT("identifier expected"),

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c,v 1.75 2006-04-10 14:53:48 bacon Exp $
* $Id: parse.c,v 1.76 2006-04-10 15:52:07 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -52,6 +52,8 @@ enum
TOKEN_DOLLAR,
TOKEN_COMMA,
TOKEN_SEMICOLON,
TOKEN_COLON,
TOKEN_QUEST,
TOKEN_INT,
TOKEN_REAL,
@ -110,11 +112,12 @@ static xp_awk_nde_t* __parse_statement (xp_awk_t* awk);
static xp_awk_nde_t* __parse_statement_nb (xp_awk_t* awk);
static xp_awk_nde_t* __parse_expression (xp_awk_t* awk);
static xp_awk_nde_t* __parse_basic_expr (xp_awk_t* awk);
static xp_awk_nde_t* __parse_binary_expr (
xp_awk_t* awk, const __binmap_t* binmap,
xp_awk_nde_t*(*next_level_func)(xp_awk_t*));
static xp_awk_nde_t* __parse_basic_expr (xp_awk_t* awk);
static xp_awk_nde_t* __parse_logical_or (xp_awk_t* awk);
static xp_awk_nde_t* __parse_logical_and (xp_awk_t* awk);
static xp_awk_nde_t* __parse_bitwise_or (xp_awk_t* awk);
@ -125,9 +128,11 @@ static xp_awk_nde_t* __parse_relational (xp_awk_t* awk);
static xp_awk_nde_t* __parse_shift (xp_awk_t* awk);
static xp_awk_nde_t* __parse_additive (xp_awk_t* awk);
static xp_awk_nde_t* __parse_multiplicative (xp_awk_t* awk);
static xp_awk_nde_t* __parse_unary (xp_awk_t* awk);
static xp_awk_nde_t* __parse_increment (xp_awk_t* awk);
static xp_awk_nde_t* __parse_primary (xp_awk_t* awk);
static xp_awk_nde_t* __parse_hashidx (xp_awk_t* awk, xp_char_t* name);
static xp_awk_nde_t* __parse_funcall (xp_awk_t* awk, xp_char_t* name);
static xp_awk_nde_t* __parse_if (xp_awk_t* awk);
@ -1050,6 +1055,38 @@ static xp_awk_nde_t* __parse_expression (xp_awk_t* awk)
return (xp_awk_nde_t*)nde;
}
static xp_awk_nde_t* __parse_basic_expr (xp_awk_t* awk)
{
xp_awk_nde_t* nde, * n1, * n2;
nde = __parse_logical_or (awk);
if (nde == XP_NULL) return XP_NULL;
if (MATCH(awk,TOKEN_QUEST))
{
if (__get_token(awk) == -1) return XP_NULL;
n1 = __parse_basic_expr (awk);
if (n1 == XP_NULL)
{
//TODO: error handling...
}
if (!MATCH(awk,TOKEN_COLON)) PANIC (awk, XP_AWK_ECOLON);
if (__get_token(awk) == -1) return XP_NULL;
n2 = __parse_basic_expr (awk);
if (n2 == XP_NULL)
{
//TODO: error handling
}
// TODO: compose the new node...
}
return nde;
}
static xp_awk_nde_t* __parse_binary_expr (
xp_awk_t* awk, const __binmap_t* binmap,
xp_awk_nde_t*(*next_level_func)(xp_awk_t*))
@ -1135,7 +1172,8 @@ static xp_awk_nde_t* __parse_binary_expr (
// TODO: enhance constant folding more...
skip_constant_folding:
nde = (xp_awk_nde_exp_t*)xp_malloc(xp_sizeof(xp_awk_nde_exp_t));
nde = (xp_awk_nde_exp_t*)
xp_malloc (xp_sizeof(xp_awk_nde_exp_t));
if (nde == XP_NULL)
{
xp_awk_clrpt (right);
@ -1155,11 +1193,6 @@ static xp_awk_nde_t* __parse_binary_expr (
return left;
}
static xp_awk_nde_t* __parse_basic_expr (xp_awk_t* awk)
{
return __parse_logical_or (awk);
}
static xp_awk_nde_t* __parse_logical_or (xp_awk_t* awk)
{
__binmap_t map[] =
@ -1543,6 +1576,10 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
return (xp_awk_nde_t*)nde;
}
else if (MATCH(awk,TOKEN_REGEX))
{
// TODO: ....
}
else if (MATCH(awk,TOKEN_DOLLAR))
{
xp_awk_nde_pos_t* nde;
@ -2381,6 +2418,7 @@ static int __get_token (xp_awk_t* awk)
else if (c == XP_CHAR('/'))
{
// TODO: handle regular expression here... /^pattern$/
SET_TOKEN_TYPE (awk, TOKEN_DIV);
ADD_TOKEN_CHAR (awk, c);
GET_CHAR_TO (awk, c);
@ -2445,6 +2483,18 @@ static int __get_token (xp_awk_t* awk)
ADD_TOKEN_CHAR (awk, c);
GET_CHAR_TO (awk, c);
}
else if (c == XP_CHAR(':'))
{
SET_TOKEN_TYPE (awk, TOKEN_COLON);
ADD_TOKEN_CHAR (awk, c);
GET_CHAR_TO (awk, c);
}
else if (c == XP_CHAR('?'))
{
SET_TOKEN_TYPE (awk, TOKEN_QUEST);
ADD_TOKEN_CHAR (awk, c);
GET_CHAR_TO (awk, c);
}
else
{
awk->errnum = XP_AWK_ELXCHR;