added more code to xli

This commit is contained in:
2013-02-06 14:31:32 +00:00
parent ee2d918538
commit 60255caf39
23 changed files with 1523 additions and 179 deletions

View File

@ -151,15 +151,14 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, qse_awk_prm_t* pr
if (init_token (mmgr, &awk->tok) == -1) goto oops;
if (init_token (mmgr, &awk->ntok) == -1) goto oops;
awk->sio.names = qse_htb_open (
awk->sio_names = qse_htb_open (
mmgr, QSE_SIZEOF(awk), 128, 70, QSE_SIZEOF(qse_char_t), 1
);
if (awk->sio.names == QSE_NULL) goto oops;
*(qse_awk_t**)QSE_XTN(awk->sio.names) = awk;
qse_htb_setmancbs (awk->sio.names,
if (awk->sio_names == QSE_NULL) goto oops;
*(qse_awk_t**)QSE_XTN(awk->sio_names) = awk;
qse_htb_setmancbs (awk->sio_names,
qse_gethtbmancbs(QSE_HTB_MANCBS_INLINE_KEY_COPIER)
);
awk->sio.inp = &awk->sio.arg;
/* TODO: initial map size?? */
awk->tree.funs = qse_htb_open (
@ -257,7 +256,7 @@ oops:
if (awk->parse.named) qse_htb_close (awk->parse.named);
if (awk->parse.funs) qse_htb_close (awk->parse.funs);
if (awk->tree.funs) qse_htb_close (awk->tree.funs);
if (awk->sio.names) qse_htb_close (awk->sio.names);
if (awk->sio_names) qse_htb_close (awk->sio_names);
fini_token (&awk->ntok);
fini_token (&awk->tok);
fini_token (&awk->ptok);
@ -287,7 +286,7 @@ int qse_awk_close (qse_awk_t* awk)
qse_htb_close (awk->parse.funs);
qse_htb_close (awk->tree.funs);
qse_htb_close (awk->sio.names);
qse_htb_close (awk->sio_names);
fini_token (&awk->ntok);
fini_token (&awk->tok);
@ -391,26 +390,11 @@ int qse_awk_clear (qse_awk_t* awk)
awk->tree.chain_tail = QSE_NULL;
awk->tree.chain_size = 0;
QSE_ASSERT (awk->sio.inp == &awk->sio.arg);
/* this table must not be cleared here as there can be a reference
* to an entry of this table from errinf.fil when qse_awk_parse()
* failed. this table is cleared in qse_awk_parse().
* qse_htb_clear (awk->sio.names);
* qse_htb_clear (awk->sio_names);
*/
awk->sio.last.c = QSE_CHAR_EOF;
awk->sio.last.line = 0;
awk->sio.last.colm = 0;
awk->sio.last.file = QSE_NULL;
awk->sio.nungots = 0;
awk->sio.arg.flags = 0;
awk->sio.arg.name = QSE_NULL;
awk->sio.arg.line = 1;
awk->sio.arg.colm = 1;
awk->sio.arg.b.pos = 0;
awk->sio.arg.b.len = 0;
return 0;
}

View File

@ -201,9 +201,9 @@ struct qse_awk_t
qse_awk_sio_lxc_t ungot[5];
qse_awk_sio_arg_t arg; /* for the top level source */
qse_awk_sio_arg_t* inp; /* current input */
qse_htb_t* names;
qse_awk_sio_arg_t* inp; /* current input argument. */
} sio;
qse_htb_t* sio_names;
/* previous token */
qse_awk_tok_t ptok;

View File

@ -101,7 +101,7 @@ const qse_char_t* qse_awk_dflerrstr (const qse_awk_t* awk, qse_awk_errnum_t errn
QSE_T("'nextfile' illegal in the END block"),
QSE_T("both prefix and postfix increment/decrement operator present"),
QSE_T("illegal operand for increment/decrement operator"),
QSE_T("'include' not followed by a string"),
QSE_T("'@include' not followed by a string"),
QSE_T("include level too deep"),
QSE_T("@word '${0}' not recognized"),
QSE_T("@ not followed by a valid word"),

View File

@ -601,7 +601,7 @@ oops:
if (ret <= -1)
{
/* an error occurred and control has reached here
* probably, some included files might not have beed
* probably, some included files might not have been
* closed. close them */
while (awk->sio.inp != &awk->sio.arg)
{
@ -667,9 +667,15 @@ int qse_awk_parse (qse_awk_t* awk, qse_awk_sio_t* sio)
QSE_ASSERT (awk->parse.depth.expr == 0);
qse_awk_clear (awk);
qse_htb_clear (awk->sio.names);
qse_htb_clear (awk->sio_names);
QSE_MEMSET (&awk->sio, 0, QSE_SIZEOF(awk->sio));
awk->sio.inf = sio->in;
awk->sio.outf = sio->out;
awk->sio.last.c = QSE_CHAR_EOF;
awk->sio.arg.line = 1;
awk->sio.arg.colm = 1;
awk->sio.inp = &awk->sio.arg;
n = parse (awk);
if (n == 0 && awk->sio.outf != QSE_NULL) n = deparse (awk);
@ -740,9 +746,9 @@ static int begin_include (qse_awk_t* awk)
return -1;
}
/* store the file name to awk->sio.names */
/* store the file name to awk->sio_names */
pair = qse_htb_ensert (
awk->sio.names,
awk->sio_names,
QSE_STR_PTR(awk->tok.name),
QSE_STR_LEN(awk->tok.name) + 1, /* to include '\0' */
QSE_NULL, 0
@ -771,6 +777,8 @@ static int begin_include (qse_awk_t* awk)
arg->flags = QSE_AWK_SIO_INCLUDED;
arg->name = QSE_HTB_KPTR(pair);
arg->line = 1;
arg->colm = 1;
CLRERR (awk);
op = awk->sio.inf (awk, QSE_AWK_SIO_OPEN, arg, QSE_NULL, 0);
@ -785,9 +793,6 @@ static int begin_include (qse_awk_t* awk)
awk->sio.inp = arg;
awk->parse.depth.incl++;
awk->sio.inp->line = 1;
awk->sio.inp->colm = 1;
/* read in the first character in the included file.
* so the next call to get_token() sees the character read
* from this file. */
@ -851,8 +856,7 @@ static int parse_progunit (qse_awk_t* awk)
if (!MATCH(awk,TOK_STR))
{
SETERR_LOC (
awk, QSE_AWK_EINCLSTR, &awk->ptok.loc);
SETERR_LOC (awk, QSE_AWK_EINCLSTR, &awk->ptok.loc);
return -1;
}
@ -6081,7 +6085,6 @@ retry:
ADD_TOKEN_CHAR (awk, tok, c);
}
return 0;
}
else
{
@ -6249,10 +6252,7 @@ static int deparse (qse_awk_t* awk)
QSE_ASSERT (awk->sio.outf != QSE_NULL);
awk->sio.arg.name = QSE_NULL;
awk->sio.arg.handle = QSE_NULL;
awk->sio.arg.b.len = 0;
awk->sio.arg.b.pos = 0;
QSE_MEMSET (&awk->sio.arg, 0, QSE_SIZEOF(awk->sio.arg));
CLRERR (awk);
op = awk->sio.outf (

View File

@ -749,8 +749,6 @@ static qse_ssize_t sf_in_open (
awk->sio.arg.name = xtn->s.in.x[0].u.file.path;
else
awk->sio.arg.name = QSE_NULL;
awk->sio.arg.line = 1;
awk->sio.arg.colm = 1;
}
return x;
@ -902,8 +900,6 @@ static qse_ssize_t sf_in_read (
awk->sio.arg.name = xtn->s.in.x[next].u.file.path;
else
awk->sio.arg.name = QSE_NULL;
awk->sio.arg.line = 1;
awk->sio.arg.colm = 1;
goto again;
}