*** empty log message ***

This commit is contained in:
hyung-hwan 2006-04-24 11:26:00 +00:00
parent 8865e9708d
commit e5224ad96d
8 changed files with 78 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h,v 1.55 2006-04-22 16:16:40 bacon Exp $
* $Id: awk.h,v 1.56 2006-04-24 11:25:59 bacon Exp $
*/
#ifndef _XP_AWK_AWK_H_
@ -65,6 +65,7 @@ enum
XP_AWK_EENDSRC, /* unexpected end of source */
XP_AWK_EENDSTR, /* unexpected end of a string */
XP_AWK_EENDREX, /* unexpected end of a regular expression */
XP_AWK_ELBRACE, /* left brace expected */
XP_AWK_ELPAREN, /* left parenthesis expected */
XP_AWK_ERPAREN, /* right parenthesis expected */

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c,v 1.14 2006-04-22 16:16:40 bacon Exp $
* $Id: err.c,v 1.15 2006-04-24 11:25:59 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -31,6 +31,7 @@ const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk)
XP_TEXT("unexpected end of source"),
XP_TEXT("unexpected end of a string"),
XP_TEXT("unexpected end of a regular expression"),
XP_TEXT("left brace expected"),
XP_TEXT("left parenthesis expected"),
XP_TEXT("right parenthesis expected"),

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c,v 1.88 2006-04-24 11:22:42 bacon Exp $
* $Id: parse.c,v 1.89 2006-04-24 11:25:59 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -2832,7 +2832,7 @@ static int __get_regex (xp_awk_t* awk)
{
if (c == XP_CHAR_EOF)
{
awk->errnum = XP_AWK_EENDSTR;
awk->errnum = XP_AWK_EENDREX;
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.70 2006-04-24 11:22:42 bacon Exp $
* $Id: run.c,v 1.71 2006-04-24 11:26:00 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -1809,6 +1809,7 @@ static xp_awk_val_t* __eval_binop_ma (
xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right)
{
/* TODO: ... */
xp_printf (XP_TEXT("eval_binop_ma not implemented yet...\n"));
PANIC (run, XP_AWK_EINTERNAL);
return XP_NULL;
}
@ -2385,6 +2386,7 @@ static xp_awk_val_t* __eval_str (xp_awk_run_t* run, xp_awk_nde_t* nde)
static xp_awk_val_t* __eval_rex (xp_awk_run_t* run, xp_awk_nde_t* nde)
{
/* TODO */
xp_printf (XP_TEXT("eval_rex not implemented yet...\n"));
PANIC (run, XP_AWK_EINTERNAL);
return XP_NULL;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: tree.c,v 1.39 2006-04-16 16:30:59 bacon Exp $
* $Id: tree.c,v 1.40 2006-04-24 11:22:42 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -169,6 +169,11 @@ static int __print_expression (xp_awk_nde_t* nde)
xp_printf (XP_TEXT("\"%s\""), ((xp_awk_nde_str_t*)nde)->buf);
break;
case XP_AWK_NDE_REX:
/* TODO: buf, len */
xp_printf (XP_TEXT("/%s/"), ((xp_awk_nde_rex_t*)nde)->buf);
break;
case XP_AWK_NDE_ARG:
xp_assert (((xp_awk_nde_var_t*)nde)->id.idxa != (xp_size_t)-1);
xp_printf (XP_TEXT("__arg%lu"),
@ -604,6 +609,11 @@ void xp_awk_clrpt (xp_awk_nde_t* tree)
xp_free (p);
break;
case XP_AWK_NDE_REX:
xp_free (((xp_awk_nde_rex_t*)p)->buf);
xp_free (p);
break;
case XP_AWK_NDE_NAMED:
xp_assert (((xp_awk_nde_var_t*)p)->id.name != XP_NULL);
case XP_AWK_NDE_GLOBAL:

View File

@ -1,5 +1,5 @@
/*
* $Id: tree.h,v 1.36 2006-04-22 16:16:40 bacon Exp $
* $Id: tree.h,v 1.37 2006-04-24 11:22:42 bacon Exp $
*/
#ifndef _XP_AWK_TREE_H_
@ -41,6 +41,7 @@ enum
XP_AWK_NDE_INT,
XP_AWK_NDE_REAL,
XP_AWK_NDE_STR,
XP_AWK_NDE_REX,
XP_AWK_NDE_NAMED,
XP_AWK_NDE_GLOBAL,
XP_AWK_NDE_LOCAL,
@ -64,6 +65,7 @@ typedef struct xp_awk_nde_pos_t xp_awk_nde_pos_t;
typedef struct xp_awk_nde_int_t xp_awk_nde_int_t;
typedef struct xp_awk_nde_real_t xp_awk_nde_real_t;
typedef struct xp_awk_nde_str_t xp_awk_nde_str_t;
typedef struct xp_awk_nde_rex_t xp_awk_nde_rex_t;
typedef struct xp_awk_nde_var_t xp_awk_nde_var_t;
typedef struct xp_awk_nde_call_t xp_awk_nde_call_t;
@ -158,6 +160,15 @@ struct xp_awk_nde_str_t
xp_size_t len;
};
/* XP_AWK_NDE_REX */
struct xp_awk_nde_rex_t
{
XP_AWK_NDE_HDR;
/* TODO: */
xp_char_t* buf;
xp_size_t len;
};
struct xp_awk_nde_var_t
{
XP_AWK_NDE_HDR;

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c,v 1.25 2006-04-21 17:24:31 bacon Exp $
* $Id: val.c,v 1.26 2006-04-24 11:22:42 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -120,6 +120,27 @@ xp_awk_val_t* xp_awk_makestrval2 (
return (xp_awk_val_t*)val;
}
xp_awk_val_t* xp_awk_makerexval (const xp_char_t* str, xp_size_t len)
{
xp_awk_val_rex_t* val;
/* TDOO: XXXXXXXXXXXXxxx */
val = (xp_awk_val_rex_t*)xp_malloc(xp_sizeof(xp_awk_val_rex_t));
if (val == XP_NULL) return XP_NULL;
val->type = XP_AWK_VAL_STR;
val->ref = 0;
val->len = len;
val->buf = xp_strxdup (str, len);
if (val->buf == XP_NULL)
{
xp_free (val);
return XP_NULL;
}
return (xp_awk_val_t*)val;
}
static void __free_map_val (void* run, void* v)
{
/*
@ -149,6 +170,7 @@ xp_awk_val_t* xp_awk_makemapval (xp_awk_run_t* run)
return (xp_awk_val_t*)val;
}
xp_bool_t xp_awk_isbuiltinval (xp_awk_val_t* val)
{
return val == XP_NULL || val == xp_awk_val_nil ||
@ -194,6 +216,12 @@ xp_printf (XP_TEXT("\n"));
xp_free (val);
return;
case XP_AWK_VAL_REX:
/* TODO: XXXX */
xp_free (((xp_awk_val_rex_t*)val)->buf);
xp_free (val);
return;
case XP_AWK_VAL_MAP:
xp_awk_map_close (((xp_awk_val_map_t*)val)->map);
xp_free (val);
@ -335,6 +363,10 @@ void xp_awk_printval (xp_awk_val_t* val)
xp_printf (XP_TEXT("%s"), ((xp_awk_val_str_t*)val)->buf);
break;
case XP_AWK_VAL_REX:
xp_printf (XP_TEXT("REX[%s]"), ((xp_awk_val_rex_t*)val)->buf);
break;
case XP_AWK_VAL_MAP:
xp_printf (XP_TEXT("MAP["));
xp_awk_map_walk (((xp_awk_val_map_t*)val)->map, __print_pair);

View File

@ -1,5 +1,5 @@
/*
* $Id: val.h,v 1.19 2006-04-21 17:24:31 bacon Exp $
* $Id: val.h,v 1.20 2006-04-24 11:22:42 bacon Exp $
*/
#ifndef _XP_AWK_VAL_H_
@ -15,7 +15,8 @@ enum
XP_AWK_VAL_INT = 1,
XP_AWK_VAL_REAL = 2,
XP_AWK_VAL_STR = 3,
XP_AWK_VAL_MAP = 4
XP_AWK_VAL_REX = 4,
XP_AWK_VAL_MAP = 5
};
typedef struct xp_awk_val_t xp_awk_val_t;
@ -23,6 +24,7 @@ typedef struct xp_awk_val_nil_t xp_awk_val_nil_t;
typedef struct xp_awk_val_int_t xp_awk_val_int_t;
typedef struct xp_awk_val_real_t xp_awk_val_real_t;
typedef struct xp_awk_val_str_t xp_awk_val_str_t;
typedef struct xp_awk_val_rex_t xp_awk_val_rex_t;
typedef struct xp_awk_val_map_t xp_awk_val_map_t;
#define XP_AWK_VAL_HDR \
@ -67,6 +69,14 @@ struct xp_awk_val_str_t
xp_size_t len;
};
/* XP_AWK_VAL_REX */
struct xp_awk_val_rex_t
{
XP_AWK_VAL_HDR;
xp_char_t* buf;
xp_size_t len;
};
/* XP_AWK_VAL_MAP */
struct xp_awk_val_map_t
{
@ -86,6 +96,7 @@ xp_awk_val_t* xp_awk_makestrval (const xp_char_t* str, xp_size_t len);
xp_awk_val_t* xp_awk_makestrval2 (
const xp_char_t* str1, xp_size_t len1,
const xp_char_t* str2, xp_size_t len2);
xp_awk_val_t* xp_awk_makerexval (const xp_char_t* str, xp_size_t len);
xp_awk_val_t* xp_awk_makemapval (xp_awk_run_t* run);
xp_bool_t xp_awk_isbuiltinval (xp_awk_val_t* val);