*** empty log message ***

This commit is contained in:
hyung-hwan 2006-04-14 10:56:42 +00:00
parent c1c403e83d
commit c5dd529c73
12 changed files with 101 additions and 86 deletions

17
ase/awk/Makefile.sco Normal file
View File

@ -0,0 +1,17 @@
SRCS = awk.c err.c tree.c tab.c map.c parse.c run.c sa.c val.c misc.c
OBJS = $(SRCS:.c=.o)
OUT = libxpawk.a
CC = cc
CFLAGS = -Xc -a ansi -O2 -I../.. -D__STAND_ALONE
all: $(OBJS)
clean:
rm -rf $(OBJS) $(OUT) *.obj
.SUFFIXES: .c .o
.c.o:
$(CC) $(CFLAGS) -c $<

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.39 2006-04-09 15:31:13 bacon Exp $ * $Id: awk.c,v 1.40 2006-04-14 10:56:42 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -54,7 +54,7 @@ xp_awk_t* xp_awk_open (void)
return XP_NULL; return XP_NULL;
} }
// TODO: initial map size... /* TODO: initial map size... */
if (xp_awk_map_open(&awk->run.named,awk,256,__free_namedval) == XP_NULL) { if (xp_awk_map_open(&awk->run.named,awk,256,__free_namedval) == XP_NULL) {
xp_str_close (&awk->token.name); xp_str_close (&awk->token.name);
xp_awk_map_close (&awk->tree.funcs); xp_awk_map_close (&awk->tree.funcs);
@ -114,9 +114,9 @@ int xp_awk_close (xp_awk_t* awk)
return 0; return 0;
} }
// TODO: write a function to clear awk->parse data structure. /* TODO: write a function to clear awk->parse data structure.
// this would be need either as a separate function or as a part of xp_awk_clear... this would be need either as a separate function or as a part of xp_awk_clear...
// do i have to pass an option to xp_awk_clear to do this??? do i have to pass an option to xp_awk_clear to do this??? */
void xp_awk_clear (xp_awk_t* awk) void xp_awk_clear (xp_awk_t* awk)
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h,v 1.47 2006-04-10 15:52:07 bacon Exp $ * $Id: awk.h,v 1.48 2006-04-14 10:56:42 bacon Exp $
*/ */
#ifndef _XP_AWK_AWK_H_ #ifndef _XP_AWK_AWK_H_
@ -35,7 +35,7 @@ enum
/* run options */ /* run options */
enum enum
{ {
XP_AWK_RUNMAIN = (1 << 0), /* execution starts from main */ XP_AWK_RUNMAIN = (1 << 0) /* execution starts from main */
}; };
/* error code */ /* error code */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk_i.h,v 1.2 2006-04-02 12:41:14 bacon Exp $ * $Id: awk_i.h,v 1.3 2006-04-14 10:56:42 bacon Exp $
*/ */
#ifndef _XP_AWK_AWKI_H_ #ifndef _XP_AWK_AWKI_H_
@ -69,8 +69,8 @@ struct xp_awk_t
xp_size_t stack_limit; xp_size_t stack_limit;
int exit_level; int exit_level;
xp_awk_val_int_t* icache[100]; // TODO: ... xp_awk_val_int_t* icache[100]; /* TODO: ... */
xp_awk_val_real_t* rcache[100]; // TODO: ... xp_awk_val_real_t* rcache[100]; /* TODO: ... */
xp_size_t icache_count; xp_size_t icache_count;
xp_size_t rcache_count; xp_size_t rcache_count;
} run; } run;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: map.c,v 1.9 2006-03-31 16:35:37 bacon Exp $ * $Id: map.c,v 1.10 2006-04-14 10:56:42 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -10,8 +10,8 @@
#include <xp/bas/assert.h> #include <xp/bas/assert.h>
#endif #endif
// TODO: improve the entire map routines. /* TODO: improve the entire map routines.
// support automatic bucket resizing and remaping, etc. support automatic bucket resizing and remaping, etc. */
static xp_size_t __hash (const xp_char_t* key); static xp_size_t __hash (const xp_char_t* key);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c,v 1.79 2006-04-12 03:54:12 bacon Exp $ * $Id: parse.c,v 1.80 2006-04-14 10:56:42 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -235,7 +235,7 @@ do { \
#define PANIC(awk,code) do { (awk)->errnum = (code); return XP_NULL; } while (0); #define PANIC(awk,code) do { (awk)->errnum = (code); return XP_NULL; } while (0);
// TODO: remove stdio.h /* TODO: remove stdio.h */
#ifndef __STAND_ALONE #ifndef __STAND_ALONE
#include <xp/bas/stdio.h> #include <xp/bas/stdio.h>
#endif #endif
@ -314,8 +314,8 @@ int xp_awk_parse (xp_awk_t* awk)
if (__parse_progunit(awk) == XP_NULL) if (__parse_progunit(awk) == XP_NULL)
{ {
// TODO: cleanup the parse tree created so far.... /* TODO: cleanup the parse tree created so far....
// function tables also etc... function tables also etc... */
return -1; return -1;
} }
} }
@ -556,7 +556,7 @@ static xp_awk_nde_t* __parse_function (xp_awk_t* awk)
return XP_NULL; return XP_NULL;
} }
// TODO: consider if the parameters should be saved for some reasons.. /* TODO: consider if the parameters should be saved for some reasons.. */
nargs = xp_awk_tab_getsize(&awk->parse.params); nargs = xp_awk_tab_getsize(&awk->parse.params);
/* parameter names are not required anymore. clear them */ /* parameter names are not required anymore. clear them */
xp_awk_tab_clear (&awk->parse.params); xp_awk_tab_clear (&awk->parse.params);
@ -1022,8 +1022,7 @@ static xp_awk_nde_t* __parse_expression (xp_awk_t* awk)
if (x == XP_NULL) return XP_NULL; if (x == XP_NULL) return XP_NULL;
if (!MATCH(awk,TOKEN_ASSIGN)) return x; if (!MATCH(awk,TOKEN_ASSIGN)) return x;
//TODO: PLUS_ASSIGN, MINUS_ASSIGN, .... /*TODO: PLUS_ASSIGN, MINUS_ASSIGN, .... */
//
xp_assert (x->next == XP_NULL); xp_assert (x->next == XP_NULL);
if (x->type != XP_AWK_NDE_ARG && if (x->type != XP_AWK_NDE_ARG &&
x->type != XP_AWK_NDE_ARGIDX && x->type != XP_AWK_NDE_ARGIDX &&
@ -1202,7 +1201,7 @@ static xp_awk_nde_t* __parse_binary_expr (
((xp_awk_nde_real_t*)left)->val = l; ((xp_awk_nde_real_t*)left)->val = l;
continue; continue;
} }
// TODO: enhance constant folding more... /* TODO: enhance constant folding more... */
skip_constant_folding: skip_constant_folding:
nde = (xp_awk_nde_exp_t*) nde = (xp_awk_nde_exp_t*)
@ -1500,7 +1499,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
{ {
nde->type = XP_AWK_NDE_ARG; nde->type = XP_AWK_NDE_ARG;
nde->next = XP_NULL; nde->next = XP_NULL;
//nde->id.name = XP_NULL; /*nde->id.name = XP_NULL;*/
nde->id.name = name_dup; nde->id.name = name_dup;
nde->id.idxa = idxa; nde->id.idxa = idxa;
@ -1513,7 +1512,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
{ {
nde->type = XP_AWK_NDE_LOCAL; nde->type = XP_AWK_NDE_LOCAL;
nde->next = XP_NULL; nde->next = XP_NULL;
//nde->id.name = XP_NULL; /*nde->id.name = XP_NULL;*/
nde->id.name = name_dup; nde->id.name = name_dup;
nde->id.idxa = idxa; nde->id.idxa = idxa;
@ -1526,7 +1525,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
{ {
nde->type = XP_AWK_NDE_GLOBAL; nde->type = XP_AWK_NDE_GLOBAL;
nde->next = XP_NULL; nde->next = XP_NULL;
//nde->id.name = XP_NULL; /*nde->id.name = XP_NULL;*/
nde->id.name = name_dup; nde->id.name = name_dup;
nde->id.idxa = idxa; nde->id.idxa = idxa;
@ -1624,7 +1623,7 @@ static xp_awk_nde_t* __parse_primary (xp_awk_t* awk)
} }
else if (MATCH(awk,TOKEN_REGEX)) else if (MATCH(awk,TOKEN_REGEX))
{ {
// TODO: .... /* TODO: .... */
} }
else if (MATCH(awk,TOKEN_DOLLAR)) else if (MATCH(awk,TOKEN_DOLLAR))
{ {
@ -1716,7 +1715,7 @@ static xp_awk_nde_t* __parse_hashidx (xp_awk_t* awk, xp_char_t* name)
{ {
nde->type = XP_AWK_NDE_ARGIDX; nde->type = XP_AWK_NDE_ARGIDX;
nde->next = XP_NULL; nde->next = XP_NULL;
//nde->id.name = XP_NULL; /*nde->id.name = XP_NULL; */
nde->id.name = name; nde->id.name = name;
nde->id.idxa = idxa; nde->id.idxa = idxa;
nde->idx = idx; nde->idx = idx;
@ -1730,7 +1729,7 @@ static xp_awk_nde_t* __parse_hashidx (xp_awk_t* awk, xp_char_t* name)
{ {
nde->type = XP_AWK_NDE_LOCALIDX; nde->type = XP_AWK_NDE_LOCALIDX;
nde->next = XP_NULL; nde->next = XP_NULL;
//nde->id.name = XP_NULL; /*nde->id.name = XP_NULL; */
nde->id.name = name; nde->id.name = name;
nde->id.idxa = idxa; nde->id.idxa = idxa;
nde->idx = idx; nde->idx = idx;
@ -1744,7 +1743,7 @@ static xp_awk_nde_t* __parse_hashidx (xp_awk_t* awk, xp_char_t* name)
{ {
nde->type = XP_AWK_NDE_GLOBALIDX; nde->type = XP_AWK_NDE_GLOBALIDX;
nde->next = XP_NULL; nde->next = XP_NULL;
//nde->id.name = XP_NULL; /*nde->id.name = XP_NULL;*/
nde->id.name = name; nde->id.name = name;
nde->id.idxa = idxa; nde->id.idxa = idxa;
@ -1957,7 +1956,7 @@ static xp_awk_nde_t* __parse_for (xp_awk_t* awk)
xp_awk_nde_t* init, * test, * incr, * body; xp_awk_nde_t* init, * test, * incr, * body;
xp_awk_nde_for_t* nde; xp_awk_nde_for_t* nde;
// TODO: parse for (x in list) ... /* TODO: parse for (x in list) ... */
if (!MATCH(awk,TOKEN_LPAREN)) PANIC (awk, XP_AWK_ELPAREN); if (!MATCH(awk,TOKEN_LPAREN)) PANIC (awk, XP_AWK_ELPAREN);
if (__get_token(awk) == -1) return XP_NULL; if (__get_token(awk) == -1) return XP_NULL;
@ -2216,7 +2215,7 @@ static xp_awk_nde_t* __parse_exit (xp_awk_t* awk)
static xp_awk_nde_t* __parse_delete (xp_awk_t* awk) static xp_awk_nde_t* __parse_delete (xp_awk_t* awk)
{ {
// TODO: implement this... /* TODO: implement this... */
return XP_NULL; return XP_NULL;
} }
@ -2494,7 +2493,7 @@ static int __get_token (xp_awk_t* awk)
} }
else if (c == XP_CHAR('/')) else if (c == XP_CHAR('/'))
{ {
// TODO: handle regular expression here... /^pattern$/ /* TODO: handle regular expression here... /^pattern$/ */
GET_CHAR_TO (awk, c); GET_CHAR_TO (awk, c);
if (c == XP_CHAR('=')) if (c == XP_CHAR('='))

View File

@ -1,10 +1,10 @@
/* /*
* $Id: run.c,v 1.47 2006-04-12 03:54:12 bacon Exp $ * $Id: run.c,v 1.48 2006-04-14 10:56:42 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
// TODO: remove this dependency... /* TODO: remove this dependency...*/
#include <math.h> #include <math.h>
#ifndef __STAND_ALONE #ifndef __STAND_ALONE
@ -238,9 +238,9 @@ int xp_awk_run (xp_awk_t* awk)
{ {
awk->run.exit_level = EXIT_NONE; awk->run.exit_level = EXIT_NONE;
// /*
// TODO: execute pattern blocks. * TODO: execute pattern blocks.
// */
break; break;
} }
@ -309,7 +309,7 @@ static int __run_block (xp_awk_t* awk, xp_awk_nde_blk_t* nde)
p = nde->body; p = nde->body;
nlocals = nde->nlocals; nlocals = nde->nlocals;
//xp_printf (XP_TEXT("securing space for local variables nlocals = %d\n"), nlocals); /*xp_printf (XP_TEXT("securing space for local variables nlocals = %d\n"), nlocals);*/
saved_stack_top = awk->run.stack_top; saved_stack_top = awk->run.stack_top;
/* secure space for local variables */ /* secure space for local variables */
@ -326,7 +326,7 @@ static int __run_block (xp_awk_t* awk, xp_awk_nde_blk_t* nde)
/* refupval is not required for xp_awk_val_nil */ /* refupval is not required for xp_awk_val_nil */
} }
//xp_printf (XP_TEXT("executing block statements\n")); /*xp_printf (XP_TEXT("executing block statements\n"));*/
while (p != XP_NULL && awk->run.exit_level == EXIT_NONE) while (p != XP_NULL && awk->run.exit_level == EXIT_NONE)
{ {
if (__run_statement(awk,p) == -1) if (__run_statement(awk,p) == -1)
@ -337,7 +337,7 @@ static int __run_block (xp_awk_t* awk, xp_awk_nde_blk_t* nde)
p = p->next; p = p->next;
} }
//xp_printf (XP_TEXT("popping off local variables\n")); /*xp_printf (XP_TEXT("popping off local variables\n"));*/
/* pop off local variables */ /* pop off local variables */
nlocals = nde->nlocals; nlocals = nde->nlocals;
while (nlocals > 0) while (nlocals > 0)
@ -399,11 +399,11 @@ static int __run_statement (xp_awk_t* awk, xp_awk_nde_t* nde)
break; break;
case XP_AWK_NDE_NEXT: case XP_AWK_NDE_NEXT:
// TODO: /* TODO: */
break; break;
case XP_AWK_NDE_NEXTFILE: case XP_AWK_NDE_NEXTFILE:
// TODO: /* TODO: */
break; break;
default: default:
@ -432,18 +432,17 @@ static int __run_if_statement (xp_awk_t* awk, xp_awk_nde_if_t* nde)
n = __run_statement (awk, nde->else_part); n = __run_statement (awk, nde->else_part);
} }
xp_awk_refdownval (awk, test); // TODO: is this correct? xp_awk_refdownval (awk, test); /* TODO: is this correct?*/
return n; return n;
} }
static int __run_while_statement (xp_awk_t* awk, xp_awk_nde_while_t* nde) static int __run_while_statement (xp_awk_t* awk, xp_awk_nde_while_t* nde)
{ {
xp_awk_val_t* test; xp_awk_val_t* test;
int n = 0;
if (nde->type == XP_AWK_NDE_WHILE) if (nde->type == XP_AWK_NDE_WHILE)
{ {
// TODO: handle run-time abortion... /* TODO: handle run-time abortion... */
while (1) while (1)
{ {
test = __eval_expression (awk, nde->test); test = __eval_expression (awk, nde->test);
@ -481,7 +480,7 @@ static int __run_while_statement (xp_awk_t* awk, xp_awk_nde_while_t* nde)
} }
else if (nde->type == XP_AWK_NDE_DOWHILE) else if (nde->type == XP_AWK_NDE_DOWHILE)
{ {
// TODO: handle run-time abortion... /* TODO: handle run-time abortion... */
do do
{ {
if (__run_statement(awk,nde->body) == -1) return -1; if (__run_statement(awk,nde->body) == -1) return -1;
@ -605,7 +604,7 @@ static int __run_return_statement (xp_awk_t* awk, xp_awk_nde_return_t* nde)
if (nde->val != XP_NULL) if (nde->val != XP_NULL)
{ {
xp_awk_val_t* val; xp_awk_val_t* val;
//xp_printf (XP_TEXT("returning....\n")); /*xp_printf (XP_TEXT("returning....\n"));*/
val = __eval_expression(awk, nde->val); val = __eval_expression(awk, nde->val);
if (val == XP_NULL) return -1; if (val == XP_NULL) return -1;
@ -613,7 +612,7 @@ static int __run_return_statement (xp_awk_t* awk, xp_awk_nde_return_t* nde)
STACK_RETVAL(awk) = val; STACK_RETVAL(awk) = val;
xp_awk_refupval (val); /* see __eval_call for the trick */ xp_awk_refupval (val); /* see __eval_call for the trick */
//xp_printf (XP_TEXT("set return value....\n")); /*xp_printf (XP_TEXT("set return value....\n"));*/
} }
awk->run.exit_level = EXIT_FUNCTION; awk->run.exit_level = EXIT_FUNCTION;
@ -738,19 +737,19 @@ static xp_awk_val_t* __do_assignment (
} }
else if (var->type == XP_AWK_NDE_NAMEDIDX) else if (var->type == XP_AWK_NDE_NAMEDIDX)
{ {
// TODO: /* TODO: */
} }
else if (var->type == XP_AWK_NDE_GLOBALIDX) else if (var->type == XP_AWK_NDE_GLOBALIDX)
{ {
// TODO: /* TODO: */
} }
else if (var->type == XP_AWK_NDE_LOCALIDX) else if (var->type == XP_AWK_NDE_LOCALIDX)
{ {
// TODO: /* TODO: */
} }
else if (var->type == XP_AWK_NDE_ARGIDX) else if (var->type == XP_AWK_NDE_ARGIDX)
{ {
// TODO: /* TODO: */
} }
else else
{ {
@ -1309,7 +1308,7 @@ static xp_awk_val_t* __eval_binop_plus (
{ {
PANIC (awk, XP_AWK_EOPERAND); PANIC (awk, XP_AWK_EOPERAND);
} }
// TODO: addition between integer and astring??? 1 + "123" /* TODO: addition between integer and astring??? 1 + "123" */
if (res == XP_NULL) PANIC (awk, XP_AWK_ENOMEM); if (res == XP_NULL) PANIC (awk, XP_AWK_ENOMEM);
return res; return res;
@ -1505,7 +1504,7 @@ static xp_awk_val_t* __eval_binop_exp (
else if (left->type == XP_AWK_VAL_INT && else if (left->type == XP_AWK_VAL_INT &&
right->type == XP_AWK_VAL_REAL) right->type == XP_AWK_VAL_REAL)
{ {
// TODO: write own pow... /* TODO: write own pow... */
double x = ((xp_awk_val_int_t*)left)->val; double x = ((xp_awk_val_int_t*)left)->val;
double y = ((xp_awk_val_real_t*)right)->val; double y = ((xp_awk_val_real_t*)right)->val;
res = xp_awk_makerealval (awk, pow (x, y)); res = xp_awk_makerealval (awk, pow (x, y));
@ -1513,7 +1512,7 @@ static xp_awk_val_t* __eval_binop_exp (
else if (left->type == XP_AWK_VAL_REAL && else if (left->type == XP_AWK_VAL_REAL &&
right->type == XP_AWK_VAL_INT) right->type == XP_AWK_VAL_INT)
{ {
// TODO: write own pow... /* TODO: write own pow... */
double x = ((xp_awk_val_real_t*)left)->val; double x = ((xp_awk_val_real_t*)left)->val;
double y = ((xp_awk_val_int_t*)right)->val; double y = ((xp_awk_val_int_t*)right)->val;
res = xp_awk_makerealval (awk, pow (x, y)); res = xp_awk_makerealval (awk, pow (x, y));
@ -1521,7 +1520,7 @@ static xp_awk_val_t* __eval_binop_exp (
else if (left->type == XP_AWK_VAL_REAL && else if (left->type == XP_AWK_VAL_REAL &&
right->type == XP_AWK_VAL_REAL) right->type == XP_AWK_VAL_REAL)
{ {
// TODO: wirte own pow... /* TODO: wirte own pow... */
double x = ((xp_awk_val_real_t*)left)->val; double x = ((xp_awk_val_real_t*)left)->val;
double y = ((xp_awk_val_real_t*)right)->val; double y = ((xp_awk_val_real_t*)right)->val;
res = xp_awk_makerealval (awk, pow (x, y)); res = xp_awk_makerealval (awk, pow (x, y));
@ -1538,7 +1537,7 @@ static xp_awk_val_t* __eval_binop_exp (
static xp_awk_val_t* __eval_binop_ma ( static xp_awk_val_t* __eval_binop_ma (
xp_awk_t* awk, xp_awk_val_t* left, xp_awk_val_t* right) xp_awk_t* awk, xp_awk_val_t* left, xp_awk_val_t* right)
{ {
// TODO: ... /* TODO: ... */
PANIC (awk, XP_AWK_EINTERNAL); PANIC (awk, XP_AWK_EINTERNAL);
return XP_NULL; return XP_NULL;
} }
@ -1546,7 +1545,7 @@ static xp_awk_val_t* __eval_binop_ma (
static xp_awk_val_t* __eval_binop_nm ( static xp_awk_val_t* __eval_binop_nm (
xp_awk_t* awk, xp_awk_val_t* left, xp_awk_val_t* right) xp_awk_t* awk, xp_awk_val_t* left, xp_awk_val_t* right)
{ {
// TODO: ... /* TODO: ... */
PANIC (awk, XP_AWK_EINTERNAL); PANIC (awk, XP_AWK_EINTERNAL);
return XP_NULL; return XP_NULL;
} }
@ -1919,7 +1918,7 @@ static xp_awk_val_t* __eval_call (xp_awk_t* awk, xp_awk_nde_t* nde)
saved_stack_top = awk->run.stack_top; saved_stack_top = awk->run.stack_top;
//xp_printf (XP_TEXT("setting up function stack frame stack_top = %ld stack_base = %ld\n"), awk->run.stack_top, awk->run.stack_base); /*xp_printf (XP_TEXT("setting up function stack frame stack_top = %ld stack_base = %ld\n"), awk->run.stack_top, awk->run.stack_base); */
if (__raw_push(awk,(void*)awk->run.stack_base) == -1) if (__raw_push(awk,(void*)awk->run.stack_base) == -1)
{ {
PANIC (awk, XP_AWK_ENOMEM); PANIC (awk, XP_AWK_ENOMEM);
@ -1956,7 +1955,7 @@ static xp_awk_val_t* __eval_call (xp_awk_t* awk, xp_awk_nde_t* nde)
{ {
while (nargs > 0) while (nargs > 0)
{ {
// TODO: test this portion. /* TODO: test this portion. */
--nargs; --nargs;
xp_awk_refdownval (awk, STACK_ARG(awk,nargs)); xp_awk_refdownval (awk, STACK_ARG(awk,nargs));
__raw_pop (awk); __raw_pop (awk);
@ -1979,7 +1978,7 @@ static xp_awk_val_t* __eval_call (xp_awk_t* awk, xp_awk_nde_t* nde)
while (nargs > 0) while (nargs > 0)
{ {
// TODO: test this portion. /* TODO: test this portion. */
--nargs; --nargs;
xp_awk_refdownval (awk, STACK_ARG(awk,nargs)); xp_awk_refdownval (awk, STACK_ARG(awk,nargs));
__raw_pop (awk); __raw_pop (awk);
@ -2002,23 +2001,23 @@ static xp_awk_val_t* __eval_call (xp_awk_t* awk, xp_awk_nde_t* nde)
func = (xp_awk_func_t*)pair->val; func = (xp_awk_func_t*)pair->val;
xp_assert (func != XP_NULL); xp_assert (func != XP_NULL);
// TODO: do i need to check if the number of arguments matches the actual arguments...???? this might be the compiler job... /* TODO: do i need to check if the number of arguments matches the actual arguments...???? this might be the compiler job... */
//xp_printf (XP_TEXT("running function body\n")); /*xp_printf (XP_TEXT("running function body\n")); */
xp_assert (func->body->type == XP_AWK_NDE_BLK); xp_assert (func->body->type == XP_AWK_NDE_BLK);
n = __run_block(awk,(xp_awk_nde_blk_t*)func->body); n = __run_block(awk,(xp_awk_nde_blk_t*)func->body);
//xp_printf (XP_TEXT("block run complete\n")); /*xp_printf (XP_TEXT("block run complete\n")); */
/* refdown args in the run.stack */ /* refdown args in the run.stack */
nargs = (xp_size_t)STACK_NARGS(awk); nargs = (xp_size_t)STACK_NARGS(awk);
//xp_printf (XP_TEXT("block run complete nargs = %d\n"), nargs); /*xp_printf (XP_TEXT("block run complete nargs = %d\n"), nargs); */
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {
xp_awk_refdownval (awk, STACK_ARG(awk,i)); xp_awk_refdownval (awk, STACK_ARG(awk,i));
} }
//xp_printf (XP_TEXT("got return value\n")); /*xp_printf (XP_TEXT("got return value\n")); */
/* this is the trick mentioned in __run_return_statement. /* this is the trick mentioned in __run_return_statement.
* adjust the reference count of the return value. * adjust the reference count of the return value.
@ -2036,7 +2035,7 @@ static xp_awk_val_t* __eval_call (xp_awk_t* awk, xp_awk_nde_t* nde)
awk->run.exit_level = EXIT_NONE; awk->run.exit_level = EXIT_NONE;
} }
//xp_printf (XP_TEXT("returning from function stack_top=%ld, stack_base=%ld\n"), awk->run.stack_top, awk->run.stack_base); /*xp_printf (XP_TEXT("returning from function stack_top=%ld, stack_base=%ld\n"), awk->run.stack_top, awk->run.stack_base); */
return (n == -1)? XP_NULL: v; return (n == -1)? XP_NULL: v;
} }
@ -2097,31 +2096,31 @@ static xp_awk_val_t* __eval_arg (xp_awk_t* awk, xp_awk_nde_t* nde)
static xp_awk_val_t* __eval_namedidx (xp_awk_t* awk, xp_awk_nde_t* nde) static xp_awk_val_t* __eval_namedidx (xp_awk_t* awk, xp_awk_nde_t* nde)
{ {
// TODO: /* TODO: */
return XP_NULL; return XP_NULL;
} }
static xp_awk_val_t* __eval_globalidx (xp_awk_t* awk, xp_awk_nde_t* nde) static xp_awk_val_t* __eval_globalidx (xp_awk_t* awk, xp_awk_nde_t* nde)
{ {
// TODO: /* TODO: */
return XP_NULL; return XP_NULL;
} }
static xp_awk_val_t* __eval_localidx (xp_awk_t* awk, xp_awk_nde_t* nde) static xp_awk_val_t* __eval_localidx (xp_awk_t* awk, xp_awk_nde_t* nde)
{ {
// TODO: /* TODO: */
return XP_NULL; return XP_NULL;
} }
static xp_awk_val_t* __eval_argidx (xp_awk_t* awk, xp_awk_nde_t* nde) static xp_awk_val_t* __eval_argidx (xp_awk_t* awk, xp_awk_nde_t* nde)
{ {
// TODO: /* TODO: */
return XP_NULL; return XP_NULL;
} }
static xp_awk_val_t* __eval_pos (xp_awk_t* awk, xp_awk_nde_t* nde) static xp_awk_val_t* __eval_pos (xp_awk_t* awk, xp_awk_nde_t* nde)
{ {
// TODO: /* TODO: */
return XP_NULL; return XP_NULL;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: tab.h,v 1.5 2006-03-07 15:55:14 bacon Exp $ * $Id: tab.h,v 1.6 2006-04-14 10:56:42 bacon Exp $
*/ */
#ifndef _XP_AWK_TAB_H_ #ifndef _XP_AWK_TAB_H_
@ -16,8 +16,8 @@
#include <xp/macros.h> #include <xp/macros.h>
#endif #endif
// TODO: you have to turn this into a hash table. /* TODO: you have to turn this into a hash table.
// as of now, this is an arrayed table. as of now, this is an arrayed table. */
typedef struct xp_awk_tab_t xp_awk_tab_t; typedef struct xp_awk_tab_t xp_awk_tab_t;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: tree.c,v 1.35 2006-04-12 03:54:12 bacon Exp $ * $Id: tree.c,v 1.36 2006-04-14 10:56:42 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -142,7 +142,7 @@ static int __print_expression (xp_awk_nde_t* nde)
xp_printf (XP_TEXT("%lld"), (long long)((xp_awk_nde_int_t*)nde)->val); xp_printf (XP_TEXT("%lld"), (long long)((xp_awk_nde_int_t*)nde)->val);
#elif defined(__BORLANDC__) || defined(_MSC_VER) #elif defined(__BORLANDC__) || defined(_MSC_VER)
xp_printf (XP_TEXT("%I64d"), (__int64)((xp_awk_nde_int_t*)nde)->val); xp_printf (XP_TEXT("%I64d"), (__int64)((xp_awk_nde_int_t*)nde)->val);
#elif defined(vax) || defined(__vax) #elif defined(vax) || defined(__vax) || defined(_SCO_DS)
xp_printf (XP_TEXT("%ld"), (long)((xp_awk_nde_int_t*)nde)->val); xp_printf (XP_TEXT("%ld"), (long)((xp_awk_nde_int_t*)nde)->val);
#else #else
xp_printf (XP_TEXT("%lld"), (long long)((xp_awk_nde_int_t*)nde)->val); xp_printf (XP_TEXT("%lld"), (long long)((xp_awk_nde_int_t*)nde)->val);
@ -154,7 +154,7 @@ static int __print_expression (xp_awk_nde_t* nde)
break; break;
case XP_AWK_NDE_STR: case XP_AWK_NDE_STR:
// TODO: buf, len /* TODO: buf, len */
xp_printf (XP_TEXT("\"%s\""), ((xp_awk_nde_str_t*)nde)->buf); xp_printf (XP_TEXT("\"%s\""), ((xp_awk_nde_str_t*)nde)->buf);
break; break;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: tree.h,v 1.31 2006-04-11 09:16:20 bacon Exp $ * $Id: tree.h,v 1.32 2006-04-14 10:56:42 bacon Exp $
*/ */
#ifndef _XP_AWK_TREE_H_ #ifndef _XP_AWK_TREE_H_
@ -155,7 +155,7 @@ struct xp_awk_nde_str_t
struct xp_awk_nde_var_t struct xp_awk_nde_var_t
{ {
XP_AWK_NDE_HDR; XP_AWK_NDE_HDR;
struct // union struct /* could it be union? */
{ {
xp_char_t* name; xp_char_t* name;
xp_size_t idxa; xp_size_t idxa;
@ -165,7 +165,7 @@ struct xp_awk_nde_var_t
struct xp_awk_nde_idx_t struct xp_awk_nde_idx_t
{ {
XP_AWK_NDE_HDR; XP_AWK_NDE_HDR;
struct // union struct /* could it be union? */
{ {
xp_char_t* name; xp_char_t* name;
xp_size_t idxa; xp_size_t idxa;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.c,v 1.17 2006-04-07 04:23:11 bacon Exp $ * $Id: val.c,v 1.18 2006-04-14 10:56:42 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -254,7 +254,7 @@ xp_bool_t xp_awk_boolval (xp_awk_val_t* val)
void xp_awk_printval (xp_awk_val_t* val) void xp_awk_printval (xp_awk_val_t* val)
{ {
// TODO: better value printing...................... /* TODO: better value printing...................... */
switch (val->type) switch (val->type)
{ {
case XP_AWK_VAL_NIL: case XP_AWK_VAL_NIL:
@ -268,7 +268,7 @@ void xp_awk_printval (xp_awk_val_t* val)
#elif defined(__BORLANDC__) || defined(_MSC_VER) #elif defined(__BORLANDC__) || defined(_MSC_VER)
xp_printf (XP_TEXT("%I64d"), xp_printf (XP_TEXT("%I64d"),
(__int64)((xp_awk_nde_int_t*)val)->val); (__int64)((xp_awk_nde_int_t*)val)->val);
#elif defined(vax) || defined(__vax) #elif defined(vax) || defined(__vax) || defined(_SCO_DS)
xp_printf (XP_TEXT("%ld"), xp_printf (XP_TEXT("%ld"),
(long)((xp_awk_val_int_t*)val)->val); (long)((xp_awk_val_int_t*)val)->val);
#else #else

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.h,v 1.14 2006-04-07 04:23:11 bacon Exp $ * $Id: val.h,v 1.15 2006-04-14 10:56:42 bacon Exp $
*/ */
#ifndef _XP_AWK_VAL_H_ #ifndef _XP_AWK_VAL_H_
@ -66,7 +66,7 @@ struct xp_awk_val_str_t
struct xp_awk_val_map_t struct xp_awk_val_map_t
{ {
XP_AWK_VAL_HDR; XP_AWK_VAL_HDR;
//xp_awk_vap_t vap; /* xp_awk_vap_t vap; */
}; };
#ifdef __cplusplus #ifdef __cplusplus
@ -81,7 +81,7 @@ xp_awk_val_t* xp_awk_makestrval (const xp_char_t* str, xp_size_t len);
xp_awk_val_t* xp_awk_makestrval2 ( xp_awk_val_t* xp_awk_makestrval2 (
const xp_char_t* str1, xp_size_t len1, const xp_char_t* str1, xp_size_t len1,
const xp_char_t* str2, xp_size_t len2); const xp_char_t* str2, xp_size_t len2);
//xp_awk_val_t* xp_awk_makemapval (); /*xp_awk_val_t* xp_awk_makemapval ();*/
xp_bool_t xp_awk_isbuiltinval (xp_awk_val_t* val); xp_bool_t xp_awk_isbuiltinval (xp_awk_val_t* val);
void xp_awk_freeval (xp_awk_t* awk, xp_awk_val_t* val); void xp_awk_freeval (xp_awk_t* awk, xp_awk_val_t* val);