added qse_awk_getxtnstd() and enhanced qse_awk_openstd()

This commit is contained in:
2009-02-27 04:56:12 +00:00
parent 58a47ba425
commit 651f6d2dfa
12 changed files with 136 additions and 74 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c 75 2009-02-22 14:10:34Z hyunghwan.chung $
* $Id: awk.c 85 2009-02-26 10:56:12Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -78,10 +78,20 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtn, qse_awk_prm_t* prm)
awk->mmgr = mmgr;
/* progagate the primitive functions */
QSE_ASSERT (prm != QSE_NULL);
QSE_ASSERT (prm->pow != QSE_NULL);
QSE_ASSERT (prm->sprintf != QSE_NULL);
QSE_ASSERT (prm->isccls != QSE_NULL);
QSE_ASSERT (prm->toccls != QSE_NULL);
if (prm == QSE_NULL ||
prm->pow == QSE_NULL ||
prm->sprintf == QSE_NULL ||
prm->isccls == QSE_NULL ||
prm->toccls == QSE_NULL)
{
QSE_AWK_FREE (awk, awk);
return QSE_NULL;
}
awk->prm = *prm;
/* build a character classifier from the primitive functions */

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c 75 2009-02-22 14:10:34Z hyunghwan.chung $
* $Id: parse.c 85 2009-02-26 10:56:12Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -469,9 +469,16 @@ int qse_awk_parse (qse_awk_t* awk, qse_awk_sio_t* sio)
{
int n;
QSE_ASSERTX (
sio != QSE_NULL && sio->in != QSE_NULL,
QSE_ASSERTX (sio != QSE_NULL ,
"the source code istream must be provided");
QSE_ASSERTX (sio->in != QSE_NULL,
"the source code input stream must be provided at least");
if (sio == QSE_NULL || sio->in == QSE_NULL)
{
SETERR (awk, QSE_AWK_EINVAL);
return -1;
}
QSE_ASSERT (awk->parse.depth.cur.loop == 0);
QSE_ASSERT (awk->parse.depth.cur.expr == 0);

View File

@ -1,5 +1,5 @@
/*
* $Id: std.c 84 2009-02-25 10:35:22Z hyunghwan.chung $
* $Id: std.c 85 2009-02-26 10:56:12Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -138,7 +138,7 @@ static qse_cint_t custom_awk_toccls (
static int add_functions (qse_awk_t* awk);
qse_awk_t* qse_awk_openstd (void)
qse_awk_t* qse_awk_openstd (qse_size_t xtnsize)
{
qse_awk_t* awk;
qse_awk_prm_t prm;
@ -150,7 +150,8 @@ qse_awk_t* qse_awk_openstd (void)
prm.toccls = custom_awk_toccls;
/* create an object */
awk = qse_awk_open (QSE_MMGR_GETDFL(), QSE_SIZEOF(xtn_t), &prm);
awk = qse_awk_open (
QSE_MMGR_GETDFL(), QSE_SIZEOF(xtn_t) + xtnsize, &prm);
if (awk == QSE_NULL) return QSE_NULL;
/* initialize extension */
@ -167,6 +168,11 @@ qse_awk_t* qse_awk_openstd (void)
return awk;
}
void* qse_awk_getxtnstd (qse_awk_t* awk)
{
return (void*)((xtn_t*)QSE_XTN(awk) + 1);
}
/*** PARSESTD ***/
static qse_ssize_t sf_in (

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c 78 2009-02-23 14:03:28Z hyunghwan.chung $
* $Id: val.c 85 2009-02-26 10:56:12Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -22,33 +22,7 @@
#include <qse/utl/stdio.h>
#endif
#define CHUNKSIZE 100
typedef struct qse_awk_val_ichunk_t qse_awk_val_ichunk_t;
typedef struct qse_awk_val_rchunk_t qse_awk_val_rchunk_t;
struct qse_awk_val_chunk_t
{
qse_awk_val_chunk_t* next;
};
struct qse_awk_val_ichunk_t
{
qse_awk_val_chunk_t* next;
/* make sure that it has the same fields as
qse_awk_val_chunk_t up to this point */
qse_awk_val_int_t slot[CHUNKSIZE];
};
struct qse_awk_val_rchunk_t
{
qse_awk_val_chunk_t* next;
/* make sure that it has the same fields as
qse_awk_val_chunk_t up to this point */
qse_awk_val_real_t slot[CHUNKSIZE];
};
#define CHUNKSIZE QSE_AWK_VAL_CHUNK_SIZE
static qse_char_t* str_to_str (
qse_awk_rtx_t* run, const qse_char_t* str, qse_size_t str_len,

View File

@ -1,5 +1,5 @@
/*
* $Id: val.h 75 2009-02-22 14:10:34Z hyunghwan.chung $
* $Id: val.h 85 2009-02-26 10:56:12Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -19,6 +19,35 @@
#ifndef _QSE_LIB_AWK_VAL_H_
#define _QSE_LIB_AWK_VAL_H_
#define QSE_AWK_VAL_CHUNK_SIZE 100
typedef struct qse_awk_val_chunk_t qse_awk_val_chunk_t;
typedef struct qse_awk_val_ichunk_t qse_awk_val_ichunk_t;
typedef struct qse_awk_val_rchunk_t qse_awk_val_rchunk_t;
struct qse_awk_val_chunk_t
{
qse_awk_val_chunk_t* next;
};
struct qse_awk_val_ichunk_t
{
qse_awk_val_chunk_t* next;
/* make sure that it has the same fields as
qse_awk_val_chunk_t up to this point */
qse_awk_val_int_t slot[QSE_AWK_VAL_CHUNK_SIZE];
};
struct qse_awk_val_rchunk_t
{
qse_awk_val_chunk_t* next;
/* make sure that it has the same fields as
qse_awk_val_chunk_t up to this point */
qse_awk_val_real_t slot[QSE_AWK_VAL_CHUNK_SIZE];
};
#ifdef __cplusplus
extern "C" {
#endif