Recovered from cvs revision 2007-05-29 15:08:00
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.38 2007/05/25 11:49:42 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.40 2007/05/28 13:53:31 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/Awk.hpp>
|
||||
@ -364,7 +364,7 @@ namespace ASE
|
||||
{
|
||||
}
|
||||
|
||||
int Awk::Run::stop ()
|
||||
int Awk::Run::stop () const
|
||||
{
|
||||
ASE_ASSERT (this->run != ASE_NULL);
|
||||
return ase_awk_stop (this->run);
|
||||
@ -566,7 +566,7 @@ namespace ASE
|
||||
ase_awk_setmaxdepth (awk, ids, depth);
|
||||
}
|
||||
|
||||
int Awk::getMaxDepth (int id)
|
||||
int Awk::getMaxDepth (int id) const
|
||||
{
|
||||
ASE_ASSERT (awk != ASE_NULL);
|
||||
return ase_awk_getmaxdepth (awk, id);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.hpp,v 1.36 2007/05/25 11:49:42 bacon Exp $
|
||||
* $Id: Awk.hpp,v 1.38 2007/05/28 13:53:31 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _ASE_AWK_AWK_HPP_
|
||||
@ -363,7 +363,7 @@ namespace ASE
|
||||
Run (Awk* awk);
|
||||
|
||||
public:
|
||||
int stop ();
|
||||
int stop () const;
|
||||
|
||||
ErrorCode getErrorCode () const;
|
||||
size_t getErrorLine () const;
|
||||
@ -407,7 +407,7 @@ namespace ASE
|
||||
};
|
||||
|
||||
virtual void setMaxDepth (int ids, size_t depth);
|
||||
virtual int getMaxDepth (int id);
|
||||
virtual int getMaxDepth (int id) const;
|
||||
|
||||
virtual int parse ();
|
||||
virtual int run (const char_t* main = ASE_NULL,
|
||||
|
@ -1,23 +1,23 @@
|
||||
/*
|
||||
* $Id: func.c,v 1.4 2007/05/05 16:32:46 bacon Exp $
|
||||
* $Id: func.c,v 1.5 2007/05/28 13:54:47 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include <ase/awk/awk_i.h>
|
||||
|
||||
static int __bfn_close (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int __bfn_fflush (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int __bfn_index (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int __bfn_length (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int __bfn_substr (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int __bfn_split (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int __bfn_tolower (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int __bfn_toupper (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int __bfn_gsub (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int __bfn_sub (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int __bfn_match (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int __bfn_sprintf (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_close (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_fflush (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_index (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_length (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_substr (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_split (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_tolower (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_toupper (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_gsub (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_sub (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_match (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static int bfn_sprintf (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
|
||||
#undef MAX
|
||||
#define MAX ASE_TYPE_UNSIGNED_MAX(ase_size_t)
|
||||
@ -25,20 +25,20 @@ static int __bfn_sprintf (ase_awk_run_t*, const ase_char_t*, ase_size_t);
|
||||
static ase_awk_bfn_t __sys_bfn[] =
|
||||
{
|
||||
/* io functions */
|
||||
{ {ASE_T("close"), 5}, ASE_AWK_EXTIO, {1, 1, ASE_NULL}, __bfn_close},
|
||||
{ {ASE_T("fflush"), 6}, ASE_AWK_EXTIO, {0, 1, ASE_NULL}, __bfn_fflush},
|
||||
{ {ASE_T("close"), 5}, ASE_AWK_EXTIO, {1, 1, ASE_NULL}, bfn_close},
|
||||
{ {ASE_T("fflush"), 6}, ASE_AWK_EXTIO, {0, 1, ASE_NULL}, bfn_fflush},
|
||||
|
||||
/* string functions */
|
||||
{ {ASE_T("index"), 5}, 0, {2, 2, ASE_NULL}, __bfn_index},
|
||||
{ {ASE_T("substr"), 6}, 0, {2, 3, ASE_NULL}, __bfn_substr},
|
||||
{ {ASE_T("length"), 6}, 0, {1, 1, ASE_NULL}, __bfn_length},
|
||||
{ {ASE_T("split"), 5}, 0, {2, 3, ASE_T("vrv")}, __bfn_split},
|
||||
{ {ASE_T("tolower"), 7}, 0, {1, 1, ASE_NULL}, __bfn_tolower},
|
||||
{ {ASE_T("toupper"), 7}, 0, {1, 1, ASE_NULL}, __bfn_toupper},
|
||||
{ {ASE_T("gsub"), 4}, 0, {2, 3, ASE_T("xvr")}, __bfn_gsub},
|
||||
{ {ASE_T("sub"), 3}, 0, {2, 3, ASE_T("xvr")}, __bfn_sub},
|
||||
{ {ASE_T("match"), 5}, 0, {2, 2, ASE_T("vx")}, __bfn_match},
|
||||
{ {ASE_T("sprintf"), 7}, 0, {1, MAX, ASE_NULL}, __bfn_sprintf},
|
||||
{ {ASE_T("index"), 5}, 0, {2, 2, ASE_NULL}, bfn_index},
|
||||
{ {ASE_T("substr"), 6}, 0, {2, 3, ASE_NULL}, bfn_substr},
|
||||
{ {ASE_T("length"), 6}, 0, {1, 1, ASE_NULL}, bfn_length},
|
||||
{ {ASE_T("split"), 5}, 0, {2, 3, ASE_T("vrv")}, bfn_split},
|
||||
{ {ASE_T("tolower"), 7}, 0, {1, 1, ASE_NULL}, bfn_tolower},
|
||||
{ {ASE_T("toupper"), 7}, 0, {1, 1, ASE_NULL}, bfn_toupper},
|
||||
{ {ASE_T("gsub"), 4}, 0, {2, 3, ASE_T("xvr")}, bfn_gsub},
|
||||
{ {ASE_T("sub"), 3}, 0, {2, 3, ASE_T("xvr")}, bfn_sub},
|
||||
{ {ASE_T("match"), 5}, 0, {2, 2, ASE_T("vx")}, bfn_match},
|
||||
{ {ASE_T("sprintf"), 7}, 0, {1, MAX, ASE_NULL}, bfn_sprintf},
|
||||
|
||||
{ {ASE_NULL, 0}, 0, {0, 0, ASE_NULL}, ASE_NULL}
|
||||
};
|
||||
@ -178,7 +178,7 @@ ase_awk_bfn_t* ase_awk_getbfn (
|
||||
return ASE_NULL;
|
||||
}
|
||||
|
||||
static int __bfn_close (
|
||||
static int bfn_close (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
ase_size_t nargs;
|
||||
@ -289,7 +289,7 @@ static int __flush_extio (
|
||||
return n;
|
||||
}
|
||||
|
||||
static int __bfn_fflush (
|
||||
static int bfn_fflush (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
ase_size_t nargs;
|
||||
@ -376,7 +376,7 @@ skip_flush:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __bfn_index (
|
||||
static int bfn_index (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
ase_size_t nargs;
|
||||
@ -439,7 +439,7 @@ static int __bfn_index (
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __bfn_length (
|
||||
static int bfn_length (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
ase_size_t nargs;
|
||||
@ -474,7 +474,7 @@ static int __bfn_length (
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __bfn_substr (
|
||||
static int bfn_substr (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
ase_size_t nargs;
|
||||
@ -545,7 +545,7 @@ static int __bfn_substr (
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __bfn_split (
|
||||
static int bfn_split (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
ase_size_t nargs;
|
||||
@ -797,7 +797,7 @@ static int __bfn_split (
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __bfn_tolower (
|
||||
static int bfn_tolower (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
ase_size_t nargs;
|
||||
@ -837,7 +837,7 @@ static int __bfn_tolower (
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __bfn_toupper (
|
||||
static int bfn_toupper (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
ase_size_t nargs;
|
||||
@ -1167,19 +1167,19 @@ static int __substitute (ase_awk_run_t* run, ase_long_t max_count)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __bfn_gsub (
|
||||
static int bfn_gsub (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
return __substitute (run, 0);
|
||||
}
|
||||
|
||||
static int __bfn_sub (
|
||||
static int bfn_sub (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
return __substitute (run, 1);
|
||||
}
|
||||
|
||||
static int __bfn_match (
|
||||
static int bfn_match (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
ase_size_t nargs;
|
||||
@ -1298,7 +1298,7 @@ static int __bfn_match (
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __bfn_sprintf (
|
||||
static int bfn_sprintf (
|
||||
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
|
||||
{
|
||||
ase_size_t nargs;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.c,v 1.7 2007/05/19 16:45:27 bacon Exp $
|
||||
* $Id: run.c,v 1.8 2007/05/28 13:53:31 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -1719,12 +1719,17 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
|
||||
return n;
|
||||
}
|
||||
|
||||
#define ON_STATEMENT(run,nde) \
|
||||
if ((run)->cbs != ASE_NULL && \
|
||||
(run)->cbs->on_statement != ASE_NULL) \
|
||||
{ \
|
||||
(run)->cbs->on_statement ( \
|
||||
run, (nde)->line, (run)->custom_data); \
|
||||
}
|
||||
|
||||
static int __run_statement (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
||||
{
|
||||
if (run->cbs != ASE_NULL && run->cbs->on_statement != ASE_NULL)
|
||||
{
|
||||
run->cbs->on_statement (run, nde->line, run->custom_data);
|
||||
}
|
||||
ON_STATEMENT (run, nde);
|
||||
|
||||
switch (nde->type)
|
||||
{
|
||||
@ -1889,6 +1894,8 @@ static int __run_while (ase_awk_run_t* run, ase_awk_nde_while_t* nde)
|
||||
|
||||
while (1)
|
||||
{
|
||||
ON_STATEMENT (run, nde->test);
|
||||
|
||||
test = __eval_expression (run, nde->test);
|
||||
if (test == ASE_NULL) return -1;
|
||||
|
||||
@ -1920,6 +1927,7 @@ static int __run_while (ase_awk_run_t* run, ase_awk_nde_while_t* nde)
|
||||
run->exit_level = EXIT_NONE;
|
||||
}
|
||||
else if (run->exit_level != EXIT_NONE) break;
|
||||
|
||||
}
|
||||
}
|
||||
else if (nde->type == ASE_AWK_NDE_DOWHILE)
|
||||
@ -1943,6 +1951,8 @@ static int __run_while (ase_awk_run_t* run, ase_awk_nde_while_t* nde)
|
||||
}
|
||||
else if (run->exit_level != EXIT_NONE) break;
|
||||
|
||||
ON_STATEMENT (run, nde->test);
|
||||
|
||||
test = __eval_expression (run, nde->test);
|
||||
if (test == ASE_NULL) return -1;
|
||||
|
||||
@ -1969,6 +1979,8 @@ static int __run_for (ase_awk_run_t* run, ase_awk_nde_for_t* nde)
|
||||
if (nde->init != ASE_NULL)
|
||||
{
|
||||
ASE_ASSERT (nde->init->next == ASE_NULL);
|
||||
|
||||
ON_STATEMENT (run, nde->init);
|
||||
val = __eval_expression(run,nde->init);
|
||||
if (val == ASE_NULL) return -1;
|
||||
|
||||
@ -1986,6 +1998,7 @@ static int __run_for (ase_awk_run_t* run, ase_awk_nde_for_t* nde)
|
||||
* the for statement are allowed */
|
||||
ASE_ASSERT (nde->test->next == ASE_NULL);
|
||||
|
||||
ON_STATEMENT (run, nde->test);
|
||||
test = __eval_expression (run, nde->test);
|
||||
if (test == ASE_NULL) return -1;
|
||||
|
||||
@ -2025,7 +2038,9 @@ static int __run_for (ase_awk_run_t* run, ase_awk_nde_for_t* nde)
|
||||
if (nde->incr != ASE_NULL)
|
||||
{
|
||||
ASE_ASSERT (nde->incr->next == ASE_NULL);
|
||||
val = __eval_expression(run,nde->incr);
|
||||
|
||||
ON_STATEMENT (run, nde->incr);
|
||||
val = __eval_expression (run, nde->incr);
|
||||
if (val == ASE_NULL) return -1;
|
||||
|
||||
ase_awk_refupval (run, val);
|
||||
|
Reference in New Issue
Block a user