*** empty log message ***
This commit is contained in:
parent
c4a54c070c
commit
3079f4aac4
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: awk.c,v 1.36 2006-03-29 16:37:31 bacon Exp $
|
||||
* $Id: awk.c,v 1.37 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef __STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
@ -12,30 +12,28 @@
|
||||
static void __free_func (xp_awk_t* awk, void* func);
|
||||
static void __free_namedval (xp_awk_t* awk, void* val);
|
||||
|
||||
xp_awk_t* xp_awk_open (xp_awk_t* awk)
|
||||
xp_awk_t* xp_awk_open (void)
|
||||
{
|
||||
if (awk == XP_NULL) {
|
||||
awk = (xp_awk_t*) xp_malloc (xp_sizeof(awk));
|
||||
if (awk == XP_NULL) return XP_NULL;
|
||||
awk->__dynamic = xp_true;
|
||||
}
|
||||
else awk->__dynamic = xp_false;
|
||||
xp_awk_t* awk;
|
||||
|
||||
awk = (xp_awk_t*) xp_malloc (xp_sizeof(awk));
|
||||
if (awk == XP_NULL) return XP_NULL;
|
||||
|
||||
if (xp_str_open(&awk->token.name, 128) == XP_NULL) {
|
||||
if (awk->__dynamic) xp_free (awk);
|
||||
xp_free (awk);
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
if (xp_awk_map_open (&awk->tree.funcs, awk, 256, __free_func) == XP_NULL) {
|
||||
xp_str_close (&awk->token.name);
|
||||
if (awk->__dynamic) xp_free (awk);
|
||||
xp_free (awk);
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
if (xp_awk_tab_open(&awk->parse.globals) == XP_NULL) {
|
||||
xp_str_close (&awk->token.name);
|
||||
xp_awk_map_close (&awk->tree.funcs);
|
||||
if (awk->__dynamic) xp_free (awk);
|
||||
xp_free (awk);
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
@ -43,7 +41,7 @@ xp_awk_t* xp_awk_open (xp_awk_t* awk)
|
||||
xp_str_close (&awk->token.name);
|
||||
xp_awk_map_close (&awk->tree.funcs);
|
||||
xp_awk_tab_close (&awk->parse.globals);
|
||||
if (awk->__dynamic) xp_free (awk);
|
||||
xp_free (awk);
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
@ -52,7 +50,7 @@ xp_awk_t* xp_awk_open (xp_awk_t* awk)
|
||||
xp_awk_map_close (&awk->tree.funcs);
|
||||
xp_awk_tab_close (&awk->parse.globals);
|
||||
xp_awk_tab_close (&awk->parse.locals);
|
||||
if (awk->__dynamic) xp_free (awk);
|
||||
xp_free (awk);
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
@ -63,7 +61,7 @@ xp_awk_t* xp_awk_open (xp_awk_t* awk)
|
||||
xp_awk_tab_close (&awk->parse.globals);
|
||||
xp_awk_tab_close (&awk->parse.locals);
|
||||
xp_awk_tab_close (&awk->parse.params);
|
||||
if (awk->__dynamic) xp_free (awk);
|
||||
xp_free (awk);
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
@ -112,7 +110,7 @@ int xp_awk_close (xp_awk_t* awk)
|
||||
xp_awk_tab_close (&awk->parse.params);
|
||||
xp_str_close (&awk->token.name);
|
||||
|
||||
if (awk->__dynamic) xp_free (awk);
|
||||
xp_free (awk);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -157,6 +155,11 @@ void xp_awk_clear (xp_awk_t* awk)
|
||||
/* TODO: destroy function list */
|
||||
}
|
||||
|
||||
void xp_awk_setparseopt (xp_awk_t* awk, int opt)
|
||||
{
|
||||
awk->opt.parse = opt;
|
||||
}
|
||||
|
||||
int xp_awk_attsrc (xp_awk_t* awk, xp_awk_io_t src, void* arg)
|
||||
{
|
||||
if (xp_awk_detsrc(awk) == -1) return -1;
|
||||
|
126
ase/awk/awk.h
126
ase/awk/awk.h
@ -1,34 +1,15 @@
|
||||
/*
|
||||
* $Id: awk.h,v 1.38 2006-03-28 16:33:09 bacon Exp $
|
||||
* $Id: awk.h,v 1.39 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_AWK_H_
|
||||
#define _XP_AWK_AWK_H_
|
||||
|
||||
#ifdef __STAND_ALONE
|
||||
#include <xp/awk/sa.h>
|
||||
#else
|
||||
#include <xp/types.h>
|
||||
#include <xp/macros.h>
|
||||
#include <xp/bas/str.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* TYPE: xp_awk_t
|
||||
*/
|
||||
typedef struct xp_awk_t xp_awk_t;
|
||||
typedef struct xp_awk_chain_t xp_awk_chain_t;
|
||||
|
||||
#include <xp/awk/err.h>
|
||||
#include <xp/awk/tree.h>
|
||||
#include <xp/awk/tab.h>
|
||||
#include <xp/awk/map.h>
|
||||
#include <xp/awk/val.h>
|
||||
#include <xp/awk/run.h>
|
||||
|
||||
/*
|
||||
* TYPE: xp_awk_io_t
|
||||
*/
|
||||
typedef xp_ssize_t (*xp_awk_io_t) (
|
||||
int cmd, void* arg, xp_char_t* data, xp_size_t count);
|
||||
|
||||
@ -50,124 +31,23 @@ enum
|
||||
XP_AWK_SHIFT = (1 << 4) /* support shift operators */
|
||||
};
|
||||
|
||||
struct xp_awk_t
|
||||
{
|
||||
/* options */
|
||||
struct
|
||||
{
|
||||
int parse;
|
||||
int run;
|
||||
} opt;
|
||||
|
||||
/* io functions */
|
||||
xp_awk_io_t src_func;
|
||||
xp_awk_io_t in_func;
|
||||
xp_awk_io_t out_func;
|
||||
|
||||
void* src_arg;
|
||||
void* in_arg;
|
||||
void* out_arg;
|
||||
|
||||
/* parse tree */
|
||||
struct
|
||||
{
|
||||
xp_size_t nglobals;
|
||||
xp_awk_map_t funcs;
|
||||
xp_awk_nde_t* begin;
|
||||
xp_awk_nde_t* end;
|
||||
xp_awk_chain_t* chain;
|
||||
xp_awk_chain_t* chain_tail;
|
||||
} tree;
|
||||
|
||||
/* temporary information that the parser needs */
|
||||
struct
|
||||
{
|
||||
xp_awk_tab_t globals;
|
||||
xp_awk_tab_t locals;
|
||||
xp_awk_tab_t params;
|
||||
xp_size_t nlocals_max;
|
||||
} parse;
|
||||
|
||||
/* run-time data structure */
|
||||
struct
|
||||
{
|
||||
xp_awk_map_t named;
|
||||
|
||||
void** stack;
|
||||
xp_size_t stack_top;
|
||||
xp_size_t stack_base;
|
||||
xp_size_t stack_limit;
|
||||
int exit_level;
|
||||
|
||||
xp_awk_val_int_t* icache[100]; // TODO: ...
|
||||
xp_awk_val_real_t* rcache[100]; // TODO: ...
|
||||
xp_size_t icache_count;
|
||||
xp_size_t rcache_count;
|
||||
} run;
|
||||
|
||||
/* source buffer management */
|
||||
struct
|
||||
{
|
||||
xp_cint_t curc;
|
||||
xp_cint_t ungotc[5];
|
||||
xp_size_t ungotc_count;
|
||||
} lex;
|
||||
|
||||
/* token */
|
||||
struct
|
||||
{
|
||||
int type;
|
||||
xp_str_t name;
|
||||
} token;
|
||||
|
||||
/* housekeeping */
|
||||
int errnum;
|
||||
xp_bool_t __dynamic;
|
||||
};
|
||||
|
||||
struct xp_awk_chain_t
|
||||
{
|
||||
xp_awk_nde_t* pattern;
|
||||
xp_awk_nde_t* action;
|
||||
xp_awk_chain_t* next;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* FUNCTION: xp_awk_open
|
||||
*/
|
||||
xp_awk_t* xp_awk_open (xp_awk_t* awk);
|
||||
|
||||
/*
|
||||
* FUNCTION: xp_awk_close
|
||||
*/
|
||||
xp_awk_t* xp_awk_open (void);
|
||||
int xp_awk_close (xp_awk_t* awk);
|
||||
|
||||
|
||||
int xp_awk_geterrnum (xp_awk_t* awk);
|
||||
const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk);
|
||||
|
||||
/*
|
||||
* FUNCTION: xp_awk_clear
|
||||
*/
|
||||
void xp_awk_clear (xp_awk_t* awk);
|
||||
void xp_awk_setparseopt (xp_awk_t* awk, int opt);
|
||||
|
||||
/*
|
||||
* FUNCTION: xp_awk_attsrc
|
||||
*/
|
||||
int xp_awk_attsrc (xp_awk_t* awk, xp_awk_io_t src, void* arg);
|
||||
|
||||
/*
|
||||
* FUNCTION: xp_awk_detsrc
|
||||
*/
|
||||
int xp_awk_detsrc (xp_awk_t* awk);
|
||||
|
||||
int xp_awk_attin (xp_awk_t* awk, xp_awk_io_t in, void* arg);
|
||||
int xp_awk_detin (xp_awk_t* awk);
|
||||
|
||||
int xp_awk_attout (xp_awk_t* awk, xp_awk_io_t out, void* arg);
|
||||
int xp_awk_detout (xp_awk_t* awk);
|
||||
|
||||
|
106
ase/awk/awk_i.h
Normal file
106
ase/awk/awk_i.h
Normal file
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* $Id: awk_i.h,v 1.1 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_AWKI_H_
|
||||
#define _XP_AWK_AWKI_H_
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/awk/err.h>
|
||||
#include <xp/awk/tree.h>
|
||||
#include <xp/awk/tab.h>
|
||||
#include <xp/awk/map.h>
|
||||
#include <xp/awk/val.h>
|
||||
#include <xp/awk/run.h>
|
||||
|
||||
#ifdef __STAND_ALONE
|
||||
#include <xp/awk/sa.h>
|
||||
#else
|
||||
#include <xp/bas/str.h>
|
||||
#endif
|
||||
|
||||
typedef struct xp_awk_chain_t xp_awk_chain_t;
|
||||
|
||||
struct xp_awk_t
|
||||
{
|
||||
/* options */
|
||||
struct
|
||||
{
|
||||
int parse;
|
||||
int run;
|
||||
} opt;
|
||||
|
||||
/* io functions */
|
||||
xp_awk_io_t src_func;
|
||||
xp_awk_io_t in_func;
|
||||
xp_awk_io_t out_func;
|
||||
|
||||
void* src_arg;
|
||||
void* in_arg;
|
||||
void* out_arg;
|
||||
|
||||
/* parse tree */
|
||||
struct
|
||||
{
|
||||
xp_size_t nglobals;
|
||||
xp_awk_map_t funcs;
|
||||
xp_awk_nde_t* begin;
|
||||
xp_awk_nde_t* end;
|
||||
xp_awk_chain_t* chain;
|
||||
xp_awk_chain_t* chain_tail;
|
||||
} tree;
|
||||
|
||||
/* temporary information that the parser needs */
|
||||
struct
|
||||
{
|
||||
xp_awk_tab_t globals;
|
||||
xp_awk_tab_t locals;
|
||||
xp_awk_tab_t params;
|
||||
xp_size_t nlocals_max;
|
||||
} parse;
|
||||
|
||||
/* run-time data structure */
|
||||
struct
|
||||
{
|
||||
xp_awk_map_t named;
|
||||
|
||||
void** stack;
|
||||
xp_size_t stack_top;
|
||||
xp_size_t stack_base;
|
||||
xp_size_t stack_limit;
|
||||
int exit_level;
|
||||
|
||||
xp_awk_val_int_t* icache[100]; // TODO: ...
|
||||
xp_awk_val_real_t* rcache[100]; // TODO: ...
|
||||
xp_size_t icache_count;
|
||||
xp_size_t rcache_count;
|
||||
} run;
|
||||
|
||||
/* source buffer management */
|
||||
struct
|
||||
{
|
||||
xp_cint_t curc;
|
||||
xp_cint_t ungotc[5];
|
||||
xp_size_t ungotc_count;
|
||||
} lex;
|
||||
|
||||
/* token */
|
||||
struct
|
||||
{
|
||||
int type;
|
||||
xp_str_t name;
|
||||
} token;
|
||||
|
||||
/* housekeeping */
|
||||
int errnum;
|
||||
xp_bool_t __dynamic;
|
||||
};
|
||||
|
||||
struct xp_awk_chain_t
|
||||
{
|
||||
xp_awk_nde_t* pattern;
|
||||
xp_awk_nde_t* action;
|
||||
xp_awk_chain_t* next;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: err.c,v 1.1 2006-03-04 10:08:13 bacon Exp $
|
||||
* $Id: err.c,v 1.2 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
int xp_awk_geterrnum (xp_awk_t* awk)
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: map.c,v 1.8 2006-03-27 14:14:00 bacon Exp $
|
||||
* $Id: map.c,v 1.9 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef __STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: parse.c,v 1.66 2006-03-31 12:04:14 bacon Exp $
|
||||
* $Id: parse.c,v 1.67 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef __STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
@ -137,6 +137,7 @@ static xp_awk_nde_t* __parse_break (xp_awk_t* awk);
|
||||
static xp_awk_nde_t* __parse_continue (xp_awk_t* awk);
|
||||
static xp_awk_nde_t* __parse_return (xp_awk_t* awk);
|
||||
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_next (xp_awk_t* awk);
|
||||
static xp_awk_nde_t* __parse_nextfile (xp_awk_t* awk);
|
||||
|
||||
@ -944,13 +945,11 @@ static xp_awk_nde_t* __parse_statement_nb (xp_awk_t* awk)
|
||||
if (__get_token(awk) == -1) return XP_NULL;
|
||||
nde = __parse_exit(awk);
|
||||
}
|
||||
/* TODO:
|
||||
else if (MATCH(awk,TOKEN_DELETE))
|
||||
{
|
||||
if (__get_token(awk) == -1) return XP_NULL;
|
||||
nde = __parse_delete(awk);
|
||||
}
|
||||
*/
|
||||
else if (MATCH(awk,TOKEN_NEXT))
|
||||
{
|
||||
if (__get_token(awk) == -1) return XP_NULL;
|
||||
@ -1088,8 +1087,40 @@ static xp_awk_nde_t* __parse_binary_expr (
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
// TODO: constant folding -> in other parts of the program also...
|
||||
/* TODO: enhance constant folding. do it in a better way */
|
||||
/* TODO: differentiate different types of numbers ... */
|
||||
if (left->type == XP_AWK_NDE_INT &&
|
||||
right->type == XP_AWK_NDE_INT)
|
||||
{
|
||||
xp_long_t l, r;
|
||||
|
||||
l = ((xp_awk_nde_int_t*)left)->val;
|
||||
r = ((xp_awk_nde_int_t*)right)->val;
|
||||
|
||||
/* TODO: more operators */
|
||||
if (opcode == XP_AWK_BINOP_PLUS) l += r;
|
||||
else if (opcode == XP_AWK_BINOP_MINUS) l -= r;
|
||||
else if (opcode == XP_AWK_BINOP_MUL) l *= r;
|
||||
else if (opcode == XP_AWK_BINOP_DIV) l /= r;
|
||||
else if (opcode == XP_AWK_BINOP_MOD) l %= r;
|
||||
else goto skip_constant_folding;
|
||||
|
||||
xp_awk_clrpt (right);
|
||||
((xp_awk_nde_int_t*)left)->val = l;
|
||||
continue;
|
||||
}
|
||||
/* TODO:
|
||||
else if (left->type == XP_AWK_NDE_REAL &&
|
||||
right->type == XP_AWK_NDE_REAL)
|
||||
{
|
||||
}
|
||||
else if (left->type == XP_AWK_NDE_STR &&
|
||||
right->type == XP_AWK_NDE_STR)
|
||||
{
|
||||
// TODO: string concatenation operator....
|
||||
} */
|
||||
|
||||
skip_constant_folding:
|
||||
nde = (xp_awk_nde_exp_t*)xp_malloc(xp_sizeof(xp_awk_nde_exp_t));
|
||||
if (nde == XP_NULL)
|
||||
{
|
||||
@ -2081,6 +2112,12 @@ static xp_awk_nde_t* __parse_exit (xp_awk_t* awk)
|
||||
return (xp_awk_nde_t*)nde;
|
||||
}
|
||||
|
||||
static xp_awk_nde_t* __parse_delete (xp_awk_t* awk)
|
||||
{
|
||||
// TODO: implement this...
|
||||
return XP_NULL;
|
||||
}
|
||||
|
||||
static xp_awk_nde_t* __parse_next (xp_awk_t* awk)
|
||||
{
|
||||
xp_awk_nde_t* nde;
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: run.c,v 1.27 2006-03-30 16:31:50 bacon Exp $
|
||||
* $Id: run.c,v 1.28 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef __STAND_ALONE
|
||||
#include <xp/bas/assert.h>
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: sa.c,v 1.12 2006-03-31 12:04:14 bacon Exp $
|
||||
* $Id: sa.c,v 1.13 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifdef __STAND_ALONE
|
||||
|
||||
|
92
ase/awk/sa.h
92
ase/awk/sa.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sa.h,v 1.16 2006-03-31 12:04:14 bacon Exp $
|
||||
* $Id: sa.h,v 1.17 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_SA_H_
|
||||
@ -59,59 +59,6 @@
|
||||
#define xp_va_end(pvar) va_end(pvar)
|
||||
#define xp_va_arg(pvar,type) va_arg(pvar,type)
|
||||
|
||||
#define xp_main main
|
||||
|
||||
#define XP_NULL NULL
|
||||
|
||||
#define xp_sizeof(n) (sizeof(n))
|
||||
#define xp_countof(n) (sizeof(n) / sizeof(n[0]))
|
||||
|
||||
#define xp_true (0 == 0)
|
||||
#define xp_false (0 != 0)
|
||||
|
||||
typedef unsigned char xp_byte_t;
|
||||
typedef int xp_bool_t;
|
||||
typedef size_t xp_size_t;
|
||||
|
||||
#ifdef XP_CHAR_IS_MCHAR
|
||||
typedef char xp_char_t;
|
||||
typedef int xp_cint_t;
|
||||
#else
|
||||
typedef wchar_t xp_char_t;
|
||||
typedef wint_t xp_cint_t;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(vms) || defined(__vms)
|
||||
typedef long xp_ssize_t;
|
||||
#else
|
||||
typedef ssize_t xp_ssize_t;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
typedef __int64 xp_long_t;
|
||||
typedef long double xp_real_t;
|
||||
#elif defined(vax) || defined(__vax)
|
||||
typedef long xp_long_t;
|
||||
typedef long double xp_real_t;
|
||||
#else
|
||||
typedef long long xp_long_t;
|
||||
typedef long double xp_real_t;
|
||||
#endif
|
||||
|
||||
#ifdef XP_CHAR_IS_MCHAR
|
||||
#define XP_CHAR(c) c
|
||||
#define XP_TEXT(c) c
|
||||
#define XP_CHAR_EOF EOF
|
||||
#else
|
||||
#define XP_CHAR(c) L##c
|
||||
#define XP_TEXT(c) L##c
|
||||
#ifdef WEOF
|
||||
#define XP_CHAR_EOF WEOF
|
||||
#else
|
||||
#define XP_CHAR_EOF ((xp_char_t)-1)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define XP_STR_LEN(x) ((x)->size)
|
||||
#define XP_STR_SIZE(x) ((x)->size + 1)
|
||||
#define XP_STR_CAPA(x) ((x)->capa)
|
||||
@ -131,29 +78,64 @@ struct xp_str_t
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define xp_strlen xp_awk_strlen
|
||||
xp_size_t xp_strlen (const xp_char_t* str);
|
||||
|
||||
#define xp_strdup xp_awk_strdup
|
||||
xp_char_t* xp_strdup (const xp_char_t* str);
|
||||
|
||||
#define xp_strxdup xp_awk_strxdup
|
||||
xp_char_t* xp_strxdup (const xp_char_t* str, xp_size_t len);
|
||||
|
||||
#define xp_strcpy xp_awk_strcpy
|
||||
xp_size_t xp_strcpy (xp_char_t* buf, const xp_char_t* str);
|
||||
|
||||
#define xp_strxncpy xp_awk_strxncpy
|
||||
xp_size_t xp_strxncpy (
|
||||
xp_char_t* buf, xp_size_t bsz, const xp_char_t* str, xp_size_t len);
|
||||
|
||||
#define xp_strcmp xp_awk_strcmp
|
||||
int xp_strcmp (const xp_char_t* s1, const xp_char_t* s2);
|
||||
|
||||
#define xp_strtolong xp_awk_strtolong
|
||||
xp_long_t xp_strtolong (xp_char_t* str);
|
||||
|
||||
#define xp_strtoreal xp_awk_strtoreal
|
||||
xp_real_t xp_strtoreal (xp_char_t* str);
|
||||
|
||||
#define xp_printf xp_awk_printf
|
||||
int xp_printf (const xp_char_t* fmt, ...);
|
||||
|
||||
#define xp_vprintf xp_awk_vprintf
|
||||
int xp_vprintf (const xp_char_t* fmt, xp_va_list ap);
|
||||
int xp_sprintf (xp_char_t* buf, xp_size_t size, const xp_char_t* fmt, ...);
|
||||
|
||||
#define xp_sprintf xp_awk_sprintf
|
||||
int xp_sprintf (
|
||||
xp_char_t* buf, xp_size_t size, const xp_char_t* fmt, ...);
|
||||
|
||||
#define xp_vsprintf xp_awk_vsprintf
|
||||
int xp_vsprintf (
|
||||
xp_char_t* buf, xp_size_t size, const xp_char_t* fmt, xp_va_list ap);
|
||||
|
||||
#define xp_str_open xp_awk_str_open
|
||||
xp_str_t* xp_str_open (xp_str_t* str, xp_size_t capa);
|
||||
|
||||
#define xp_str_close xp_awk_str_close
|
||||
void xp_str_close (xp_str_t* str);
|
||||
|
||||
#define xp_str_forfeit xp_awk_str_forfeit
|
||||
void xp_str_forfeit (xp_str_t* str);
|
||||
|
||||
#define xp_str_cat xp_awk_str_cat
|
||||
xp_size_t xp_str_cat (xp_str_t* str, const xp_char_t* s);
|
||||
|
||||
#define xp_str_ncat xp_awk_str_ncat
|
||||
xp_size_t xp_str_ncat (xp_str_t* str, const xp_char_t* s, xp_size_t len);
|
||||
|
||||
#define xp_str_ccat xp_awk_str_ccat
|
||||
xp_size_t xp_str_ccat (xp_str_t* str, xp_char_t c);
|
||||
|
||||
#define xp_str_clear xp_awk_str_clear
|
||||
void xp_str_clear (xp_str_t* str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: tab.c,v 1.6 2006-03-07 15:55:14 bacon Exp $
|
||||
* $Id: tab.c,v 1.7 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef __STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: tree.c,v 1.29 2006-03-31 12:04:14 bacon Exp $
|
||||
* $Id: tree.c,v 1.30 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef __STAND_ALONE
|
||||
#include <xp/bas/memory.h>
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* $Id: val.c,v 1.13 2006-03-28 16:33:09 bacon Exp $
|
||||
* $Id: val.c,v 1.14 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/awk/awk_i.h>
|
||||
|
||||
#ifndef __STAND_ALONE
|
||||
#include <xp/bas/string.h>
|
||||
|
@ -1,9 +1,9 @@
|
||||
CC = cl
|
||||
#CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I..\..\..
|
||||
CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I..\..\.. -D__STAND_ALONE -DXP_CHAR_IS_WCHAR
|
||||
CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I..\..\..
|
||||
LDFLAGS = /libpath:..\..\bas /libpath:..\..\awk
|
||||
#LIBS = xpbas.lib xpawk.lib
|
||||
LIBS = xpawk.lib
|
||||
LIBS = xpbas.lib xpawk.lib
|
||||
#LIBS = xpawk.lib
|
||||
|
||||
all: awk
|
||||
|
||||
|
@ -1,4 +1,10 @@
|
||||
/*
|
||||
* $Id: awk.c,v 1.14 2006-03-31 16:35:37 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk.h>
|
||||
#include <xp/bas/stdio.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#ifdef __STAND_ALONE
|
||||
|
||||
@ -62,7 +68,7 @@ int xp_main (int argc, xp_char_t* argv[])
|
||||
int xp_main (int argc, char* argv[])
|
||||
#endif
|
||||
{
|
||||
xp_awk_t awk;
|
||||
xp_awk_t* awk;
|
||||
|
||||
#ifdef __linux
|
||||
mtrace ();
|
||||
@ -75,35 +81,37 @@ int xp_main (int argc, char* argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
if (xp_awk_open(&awk) == XP_NULL) {
|
||||
if ((awk = xp_awk_open()) == XP_NULL) {
|
||||
xp_printf (XP_TEXT("Error: cannot open awk\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xp_awk_attsrc(&awk, process_source, XP_NULL) == -1) {
|
||||
xp_awk_close (&awk);
|
||||
if (xp_awk_attsrc(awk, process_source, XP_NULL) == -1) {
|
||||
xp_awk_close (awk);
|
||||
xp_printf (XP_TEXT("error: cannot attach source\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
awk.opt.parse = XP_AWK_EXPLICIT | XP_AWK_UNIQUE | XP_AWK_SHADING | XP_AWK_IMPLICIT;
|
||||
xp_awk_setparseopt (awk,
|
||||
XP_AWK_EXPLICIT | XP_AWK_UNIQUE |
|
||||
XP_AWK_SHADING | XP_AWK_IMPLICIT);
|
||||
|
||||
if (xp_awk_parse(&awk) == -1) {
|
||||
if (xp_awk_parse(awk) == -1) {
|
||||
xp_printf (
|
||||
XP_TEXT("error: cannot parse program - [%d] %s\n"),
|
||||
xp_awk_geterrnum(&awk), xp_awk_geterrstr(&awk));
|
||||
xp_awk_close (&awk);
|
||||
xp_awk_geterrnum(awk), xp_awk_geterrstr(awk));
|
||||
xp_awk_close (awk);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (xp_awk_run(&awk) == -1) {
|
||||
if (xp_awk_run(awk) == -1) {
|
||||
xp_printf (
|
||||
XP_TEXT("error: cannot run program - [%d] %s\n"),
|
||||
xp_awk_geterrnum(&awk), xp_awk_geterrstr(&awk));
|
||||
xp_awk_close (&awk);
|
||||
xp_awk_geterrnum(awk), xp_awk_geterrstr(awk));
|
||||
xp_awk_close (awk);
|
||||
}
|
||||
|
||||
xp_awk_close (&awk);
|
||||
xp_awk_close (awk);
|
||||
|
||||
#ifdef __linux
|
||||
muntrace ();
|
||||
|
Loading…
Reference in New Issue
Block a user