*** empty log message ***
This commit is contained in:
parent
616e04112e
commit
ed79190a0c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.c,v 1.110 2007-02-24 14:31:43 bacon Exp $
|
* $Id: awk.c,v 1.111 2007-03-02 10:06:17 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -151,8 +151,10 @@ ase_awk_t* ase_awk_open (
|
|||||||
ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_REX_BUILD, 0);
|
ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_REX_BUILD, 0);
|
||||||
ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_REX_MATCH, 0);
|
ase_awk_setmaxdepth (awk, ASE_AWK_DEPTH_REX_MATCH, 0);
|
||||||
|
|
||||||
|
/*
|
||||||
awk->run.count = 0;
|
awk->run.count = 0;
|
||||||
awk->run.ptr = ASE_NULL;
|
awk->run.ptr = ASE_NULL;
|
||||||
|
*/
|
||||||
|
|
||||||
awk->custom_data = custom_data;
|
awk->custom_data = custom_data;
|
||||||
return awk;
|
return awk;
|
||||||
@ -174,7 +176,9 @@ int ase_awk_close (ase_awk_t* awk)
|
|||||||
if (ase_awk_clear (awk) == -1) return -1;
|
if (ase_awk_clear (awk) == -1) return -1;
|
||||||
ase_awk_clrbfn (awk);
|
ase_awk_clrbfn (awk);
|
||||||
|
|
||||||
|
/*
|
||||||
ASE_AWK_ASSERT (awk, awk->run.count == 0 && awk->run.ptr == ASE_NULL);
|
ASE_AWK_ASSERT (awk, awk->run.count == 0 && awk->run.ptr == ASE_NULL);
|
||||||
|
*/
|
||||||
|
|
||||||
ase_awk_map_close (&awk->tree.afns);
|
ase_awk_map_close (&awk->tree.afns);
|
||||||
ase_awk_tab_close (&awk->parse.globals);
|
ase_awk_tab_close (&awk->parse.globals);
|
||||||
@ -191,11 +195,13 @@ int ase_awk_close (ase_awk_t* awk)
|
|||||||
int ase_awk_clear (ase_awk_t* awk)
|
int ase_awk_clear (ase_awk_t* awk)
|
||||||
{
|
{
|
||||||
/* you should stop all running instances beforehand */
|
/* you should stop all running instances beforehand */
|
||||||
|
/*
|
||||||
if (awk->run.ptr != ASE_NULL)
|
if (awk->run.ptr != ASE_NULL)
|
||||||
{
|
{
|
||||||
awk->errnum = ASE_AWK_ERUNNING;
|
awk->errnum = ASE_AWK_ERUNNING;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
ase_memset (&awk->src.ios, 0, ASE_SIZEOF(awk->src.ios));
|
ase_memset (&awk->src.ios, 0, ASE_SIZEOF(awk->src.ios));
|
||||||
awk->src.lex.curc = ASE_CHAR_EOF;
|
awk->src.lex.curc = ASE_CHAR_EOF;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.h,v 1.192 2007-02-24 14:31:43 bacon Exp $
|
* $Id: awk.h,v 1.193 2007-03-02 10:06:17 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -435,7 +435,6 @@ int ase_awk_run (
|
|||||||
ase_awk_runarg_t* runarg, void* custom_data);
|
ase_awk_runarg_t* runarg, void* custom_data);
|
||||||
|
|
||||||
int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run);
|
int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run);
|
||||||
void ase_awk_stopall (ase_awk_t* awk);
|
|
||||||
|
|
||||||
/* functions to access internal stack structure */
|
/* functions to access internal stack structure */
|
||||||
ase_size_t ase_awk_getnargs (ase_awk_run_t* run);
|
ase_size_t ase_awk_getnargs (ase_awk_run_t* run);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk_i.h,v 1.103 2007-02-23 15:18:36 bacon Exp $
|
* $Id: awk_i.h,v 1.104 2007-03-02 10:06:17 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -189,8 +189,10 @@ struct ase_awk_t
|
|||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
ase_size_t count;
|
ase_size_t count;
|
||||||
ase_awk_run_t* ptr;
|
ase_awk_run_t* ptr;
|
||||||
|
*/
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: run.c,v 1.331 2007-02-28 11:00:33 bacon Exp $
|
* $Id: run.c,v 1.332 2007-03-02 10:06:17 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -55,8 +55,10 @@ static int __set_global (
|
|||||||
ase_awk_run_t* run, ase_size_t idx,
|
ase_awk_run_t* run, ase_size_t idx,
|
||||||
ase_awk_nde_var_t* var, ase_awk_val_t* val);
|
ase_awk_nde_var_t* var, ase_awk_val_t* val);
|
||||||
|
|
||||||
|
/*
|
||||||
static void __add_run (ase_awk_t* awk, ase_awk_run_t* run);
|
static void __add_run (ase_awk_t* awk, ase_awk_run_t* run);
|
||||||
static void __del_run (ase_awk_t* awk, ase_awk_run_t* run);
|
static void __del_run (ase_awk_t* awk, ase_awk_run_t* run);
|
||||||
|
*/
|
||||||
|
|
||||||
static int __init_run (
|
static int __init_run (
|
||||||
ase_awk_run_t* run, ase_awk_t* awk,
|
ase_awk_run_t* run, ase_awk_t* awk,
|
||||||
@ -663,7 +665,7 @@ int ase_awk_run (ase_awk_t* awk,
|
|||||||
ase_memset (run, 0, ASE_SIZEOF(ase_awk_run_t));
|
ase_memset (run, 0, ASE_SIZEOF(ase_awk_run_t));
|
||||||
|
|
||||||
/* add the run object to the awk object */
|
/* add the run object to the awk object */
|
||||||
__add_run (awk, run);
|
/*__add_run (awk, run);*/
|
||||||
|
|
||||||
/* initialize the run object */
|
/* initialize the run object */
|
||||||
if (__init_run (run, awk, runios, custom_data, &errnum) == -1)
|
if (__init_run (run, awk, runios, custom_data, &errnum) == -1)
|
||||||
@ -672,7 +674,7 @@ int ase_awk_run (ase_awk_t* awk,
|
|||||||
* the awk object */
|
* the awk object */
|
||||||
ase_awk_seterror (awk, errnum, 0, ASE_NULL);
|
ase_awk_seterror (awk, errnum, 0, ASE_NULL);
|
||||||
|
|
||||||
__del_run (awk, run);
|
/*__del_run (awk, run);*/
|
||||||
ASE_AWK_FREE (awk, run);
|
ASE_AWK_FREE (awk, run);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -722,7 +724,7 @@ int ase_awk_run (ase_awk_t* awk,
|
|||||||
__deinit_run (run);
|
__deinit_run (run);
|
||||||
|
|
||||||
/* unregister the run object */
|
/* unregister the run object */
|
||||||
__del_run (awk, run);
|
/*__del_run (awk, run);*/
|
||||||
|
|
||||||
ASE_AWK_FREE (awk, run);
|
ASE_AWK_FREE (awk, run);
|
||||||
return n;
|
return n;
|
||||||
@ -730,8 +732,10 @@ int ase_awk_run (ase_awk_t* awk,
|
|||||||
|
|
||||||
int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run)
|
int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
ase_awk_run_t* r;
|
ase_awk_run_t* r;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
*/
|
||||||
|
|
||||||
if (ase_awk_getrunawk(run) != awk)
|
if (ase_awk_getrunawk(run) != awk)
|
||||||
{
|
{
|
||||||
@ -739,6 +743,11 @@ int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
run->exit_level = EXIT_ABORT;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#if 0
|
||||||
ASE_AWK_LOCK (awk);
|
ASE_AWK_LOCK (awk);
|
||||||
|
|
||||||
/* check if the run handle given is valid */
|
/* check if the run handle given is valid */
|
||||||
@ -763,20 +772,7 @@ int ase_awk_stop (ase_awk_t* awk, ase_awk_run_t* run)
|
|||||||
ASE_AWK_UNLOCK (awk);
|
ASE_AWK_UNLOCK (awk);
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
#endif
|
||||||
|
|
||||||
void ase_awk_stopall (ase_awk_t* awk)
|
|
||||||
{
|
|
||||||
ase_awk_run_t* r;
|
|
||||||
|
|
||||||
ASE_AWK_LOCK (awk);
|
|
||||||
|
|
||||||
for (r = awk->run.ptr; r != ASE_NULL; r = r->next)
|
|
||||||
{
|
|
||||||
r->exit_level = EXIT_ABORT;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASE_AWK_UNLOCK (awk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __free_namedval (void* run, void* val)
|
static void __free_namedval (void* run, void* val)
|
||||||
@ -784,6 +780,7 @@ static void __free_namedval (void* run, void* val)
|
|||||||
ase_awk_refdownval ((ase_awk_run_t*)run, val);
|
ase_awk_refdownval ((ase_awk_run_t*)run, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
static void __add_run (ase_awk_t* awk, ase_awk_run_t* run)
|
static void __add_run (ase_awk_t* awk, ase_awk_run_t* run)
|
||||||
{
|
{
|
||||||
ASE_AWK_LOCK (awk);
|
ASE_AWK_LOCK (awk);
|
||||||
@ -820,6 +817,7 @@ static void __del_run (ase_awk_t* awk, ase_awk_run_t* run)
|
|||||||
|
|
||||||
ASE_AWK_UNLOCK (awk);
|
ASE_AWK_UNLOCK (awk);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
static int __init_run (
|
static int __init_run (
|
||||||
ase_awk_run_t* run, ase_awk_t* awk,
|
ase_awk_run_t* run, ase_awk_t* awk,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
OUT = asecmn
|
OUT = asecmn
|
||||||
|
|
||||||
C_SRCS = mem.c str.c rex.c
|
C_SRCS = mem.c str.c
|
||||||
C_OBJS = $(C_SRCS:.c=.obj)
|
C_OBJS = $(C_SRCS:.c=.obj)
|
||||||
|
|
||||||
CC = bcc32
|
CC = bcc32
|
||||||
|
23
ase/cmn/makefile.msw.cl
Normal file
23
ase/cmn/makefile.msw.cl
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
OUT = asecmn
|
||||||
|
|
||||||
|
C_SRCS = mem.c str.c
|
||||||
|
C_OBJS = $(C_SRCS:.c=.obj)
|
||||||
|
|
||||||
|
CC = cl
|
||||||
|
LD = link
|
||||||
|
|
||||||
|
CFLAGS = /nologo /O2 /MT /W3 /GR- /Za -I../.. -DNDEBUG
|
||||||
|
|
||||||
|
all: lib
|
||||||
|
|
||||||
|
lib: $(C_OBJS)
|
||||||
|
$(LD) /lib @<<
|
||||||
|
/nologo /out:$(OUT).lib $(C_OBJS)
|
||||||
|
<<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
del $(OBJS) $(OUT).lib *.obj
|
||||||
|
|
||||||
|
.SUFFIXES: .c .obj
|
||||||
|
.c.obj:
|
||||||
|
$(CC) $(CFLAGS) /c $<
|
@ -3,16 +3,7 @@
|
|||||||
== ASEAWK ==
|
== ASEAWK ==
|
||||||
ASE provides an embeddable processor of a dialect of the AWK programming language. The language implemented is slightly different from {the version developed by Brian W. Kernighan, http://cm.bell-labs.com/cm/cs/awkbook/index.html} and has been adjusted to the author's preference.
|
ASE provides an embeddable processor of a dialect of the AWK programming language. The language implemented is slightly different from {the version developed by Brian W. Kernighan, http://cm.bell-labs.com/cm/cs/awkbook/index.html} and has been adjusted to the author's preference.
|
||||||
|
|
||||||
Embedding a processor requires the following basic steps.
|
The following code fragment illustrates the basic steps of embedding the processor.
|
||||||
|
|
||||||
[[[
|
|
||||||
* Create a processor instance
|
|
||||||
* Parse an AWK script
|
|
||||||
* Run the script parsed
|
|
||||||
* Destroy the instance
|
|
||||||
]]]
|
|
||||||
|
|
||||||
The following code fragment illustrates the basic steps.
|
|
||||||
|
|
||||||
{{{
|
{{{
|
||||||
1) #include <ase/awk/awk.h>
|
1) #include <ase/awk/awk.h>
|
||||||
@ -42,9 +33,59 @@ The following code fragment illustrates the basic steps.
|
|||||||
* ase_awk_close destroys the processor instance.
|
* ase_awk_close destroys the processor instance.
|
||||||
)))
|
)))
|
||||||
|
|
||||||
=== Primitive Functions ===
|
A set of primitive functions should be provided by the caller to create an instance of the processor as the library aims to be system indepenent.
|
||||||
|
|
||||||
ase_awk_open requires that a set of primitive functions be provided by its caller. This set include pointers to the system primitive functions for system dependent operation such as memory allocation, string formatting, etc.
|
{{{
|
||||||
|
typedef void* (*ase_malloc_t) (void* custom, ase_size_t n);
|
||||||
|
typedef void* (*ase_realloc_t) (void* custom, void* ptr, ase_size_t n);
|
||||||
|
typedef void (*ase_free_t) (void* custom, void* ptr);
|
||||||
|
|
||||||
|
typedef ase_bool_t (*ase_isccls_t) (void* custom, ase_cint_t c);
|
||||||
|
typedef ase_cint_t (*ase_toccls_t) (void* custom, ase_cint_t c);
|
||||||
|
|
||||||
|
struct ase_mmgr_t
|
||||||
|
{
|
||||||
|
ase_malloc_t malloc;
|
||||||
|
ase_realloc_t realloc;
|
||||||
|
ase_free_t free;
|
||||||
|
void* custom_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ase_ccls_t
|
||||||
|
{
|
||||||
|
ase_isccls_t is_upper;
|
||||||
|
ase_isccls_t is_lower;
|
||||||
|
ase_isccls_t is_alpha;
|
||||||
|
ase_isccls_t is_digit;
|
||||||
|
ase_isccls_t is_xdigit;
|
||||||
|
ase_isccls_t is_alnum;
|
||||||
|
ase_isccls_t is_space;
|
||||||
|
ase_isccls_t is_print;
|
||||||
|
ase_isccls_t is_graph;
|
||||||
|
ase_isccls_t is_cntrl;
|
||||||
|
ase_isccls_t is_punct;
|
||||||
|
ase_toccls_t to_upper;
|
||||||
|
ase_toccls_t to_lower;
|
||||||
|
void* custom_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ase_awk_prmfns_t
|
||||||
|
{
|
||||||
|
ase_mmgr_t mmgr;
|
||||||
|
ase_ccls_t ccls;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ase_awk_pow_t pow;
|
||||||
|
ase_awk_sprintf_t sprintf;
|
||||||
|
ase_awk_aprintf_t aprintf;
|
||||||
|
ase_awk_dprintf_t dprintf;
|
||||||
|
ase_awk_abort_t abort;
|
||||||
|
void* custom_data;
|
||||||
|
} misc;
|
||||||
|
};
|
||||||
|
|
||||||
|
The primitive functions handle memory allocation, charater classes, and
|
||||||
|
|
||||||
=== Source IO Handler ===
|
=== Source IO Handler ===
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user