Recovered from cvs revision 2007-11-11 06:10:00
This commit is contained in:
parent
035bc48265
commit
8109e37e29
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.java,v 1.31 2007/11/07 15:32:41 bacon Exp $
|
||||
* $Id: Awk.java,v 1.32 2007/11/10 15:30:07 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -11,6 +11,9 @@ import java.util.HashMap;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* Represents the AWK interpreter engine
|
||||
*/
|
||||
public abstract class Awk
|
||||
{
|
||||
private HashMap functionTable;
|
||||
@ -75,31 +78,49 @@ public abstract class Awk
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a source program
|
||||
*/
|
||||
public void parse () throws Exception
|
||||
{
|
||||
parse (this.awkid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a parsed program
|
||||
*/
|
||||
public void run (String main, String[] args) throws Exception
|
||||
{
|
||||
run (this.awkid, main, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a parsed program
|
||||
*/
|
||||
public void run (String main) throws Exception
|
||||
{
|
||||
run (this.awkid, main, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a parsed program
|
||||
*/
|
||||
public void run (String[] args) throws Exception
|
||||
{
|
||||
run (this.awkid, null, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a parsed program
|
||||
*/
|
||||
public void run () throws Exception
|
||||
{
|
||||
run (this.awkid, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a request to stop a running program
|
||||
*/
|
||||
public void stop () throws Exception
|
||||
{
|
||||
stop (this.awkid);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: StdAwk.java,v 1.20 2007/10/24 03:46:51 bacon Exp $
|
||||
* $Id: StdAwk.java,v 1.21 2007/11/10 15:30:07 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -8,6 +8,10 @@ package ase.awk;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Extends the core interpreter engine to implement the language closer to
|
||||
* the standard.
|
||||
*/
|
||||
public abstract class StdAwk extends Awk
|
||||
{
|
||||
private long seed;
|
||||
|
123
ase/awk/awk.c
123
ase/awk/awk.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.c,v 1.14 2007/11/05 14:20:47 bacon Exp $
|
||||
* $Id: awk.c,v 1.15 2007/11/10 15:00:51 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -15,6 +15,15 @@ static void free_word (void* awk, void* ptr);
|
||||
static void free_afn (void* awk, void* afn);
|
||||
static void free_bfn (void* awk, void* afn);
|
||||
|
||||
#define SETERR(awk,code) ase_awk_seterrnum(awk,code)
|
||||
#define SETERRARG(awk,code,line,arg,leng) \
|
||||
do { \
|
||||
ase_cstr_t errarg; \
|
||||
errarg.len = (leng); \
|
||||
errarg.ptr = (arg); \
|
||||
ase_awk_seterror ((awk), (code), (line), &errarg, 1); \
|
||||
} while (0)
|
||||
|
||||
ase_awk_t* ase_awk_open (const ase_awk_prmfns_t* prmfns, void* custom_data)
|
||||
{
|
||||
ase_awk_t* awk;
|
||||
@ -335,3 +344,115 @@ void ase_awk_stopall (ase_awk_t* awk)
|
||||
{
|
||||
awk->stopall = ase_true;
|
||||
}
|
||||
|
||||
int ase_awk_getword (ase_awk_t* awk,
|
||||
const ase_char_t* okw, ase_size_t olen,
|
||||
const ase_char_t** nkw, ase_size_t* nlen)
|
||||
{
|
||||
ase_awk_pair_t* p;
|
||||
|
||||
p = ase_awk_map_get (awk->wtab, okw, olen);
|
||||
if (p == ASE_NULL) return -1;
|
||||
|
||||
*nkw = ((ase_cstr_t*)p->val)->ptr;
|
||||
*nlen = ((ase_cstr_t*)p->val)->len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ase_awk_setword (ase_awk_t* awk,
|
||||
const ase_char_t* okw, ase_size_t olen,
|
||||
const ase_char_t* nkw, ase_size_t nlen)
|
||||
{
|
||||
ase_cstr_t* vn, * vo;
|
||||
|
||||
if (nkw == ASE_NULL || nlen == 0)
|
||||
{
|
||||
ase_awk_pair_t* p;
|
||||
|
||||
if (okw == ASE_NULL || olen == 0)
|
||||
{
|
||||
/* clear the entire table */
|
||||
ase_awk_map_clear (awk->wtab);
|
||||
ase_awk_map_clear (awk->rwtab);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* delete the word */
|
||||
p = ase_awk_map_get (awk->wtab, okw, olen);
|
||||
if (p != ASE_NULL)
|
||||
{
|
||||
ase_cstr_t* s = (ase_cstr_t*)p->val;
|
||||
ase_awk_map_remove (awk->rwtab, s->ptr, s->len);
|
||||
ase_awk_map_remove (awk->wtab, okw, olen);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SETERRARG (awk, ASE_AWK_ENOENT, 0, okw, olen);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if (okw == ASE_NULL || olen == 0)
|
||||
{
|
||||
SETERR (awk, ASE_AWK_EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* set the word */
|
||||
vn = (ase_cstr_t*) ASE_AWK_MALLOC (
|
||||
awk, ASE_SIZEOF(ase_cstr_t)+((nlen+1)*ASE_SIZEOF(*nkw)));
|
||||
if (vn == ASE_NULL)
|
||||
{
|
||||
SETERR (awk, ASE_AWK_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
vn->len = nlen;
|
||||
vn->ptr = (const ase_char_t*)(vn + 1);
|
||||
ase_strncpy ((ase_char_t*)vn->ptr, nkw, nlen);
|
||||
|
||||
vo = (ase_cstr_t*)ASE_AWK_MALLOC (
|
||||
awk, ASE_SIZEOF(ase_cstr_t)+((olen+1)*ASE_SIZEOF(*okw)));
|
||||
if (vo == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (awk, vn);
|
||||
SETERR (awk, ASE_AWK_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
vo->len = olen;
|
||||
vo->ptr = (const ase_char_t*)(vo + 1);
|
||||
ase_strncpy ((ase_char_t*)vo->ptr, okw, olen);
|
||||
|
||||
if (ase_awk_map_put (awk->wtab, okw, olen, vn) == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (awk, vo);
|
||||
ASE_AWK_FREE (awk, vn);
|
||||
SETERR (awk, ASE_AWK_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ase_awk_map_put (awk->rwtab, nkw, nlen, vo) == ASE_NULL)
|
||||
{
|
||||
ase_awk_map_remove (awk->wtab, okw, olen);
|
||||
ASE_AWK_FREE (awk, vo);
|
||||
SETERR (awk, ASE_AWK_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ase_awk_setrexfns (ase_awk_t* awk, ase_awk_rexfns_t* rexfns)
|
||||
{
|
||||
if (rexfns->build == ASE_NULL ||
|
||||
rexfns->match == ASE_NULL ||
|
||||
rexfns->free == ASE_NULL ||
|
||||
rexfns->isempty == ASE_NULL)
|
||||
{
|
||||
SETERR (awk, ASE_AWK_EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
awk->rexfns = rexfns;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h,v 1.24 2007/11/07 15:32:41 bacon Exp $
|
||||
* $Id: awk.h,v 1.26 2007/11/10 15:21:40 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -7,8 +7,13 @@
|
||||
#ifndef _ASE_AWK_AWK_H_
|
||||
#define _ASE_AWK_AWK_H_
|
||||
|
||||
// TODO: REMOVE THIS. MOVE IT SOMEWHRE ELSE OR CHANGE THE SCHEME
|
||||
//#define PROHIBIT_MAP_ASSIGNMENT_TO_VARIABLE
|
||||
/**
|
||||
* @file awk.h
|
||||
* @brief Primary header file for the engine
|
||||
*
|
||||
* This file defines most of the data types and functions required to embed
|
||||
* the interpreter engine.
|
||||
*/
|
||||
|
||||
#include <ase/cmn/types.h>
|
||||
#include <ase/cmn/macros.h>
|
||||
@ -24,6 +29,7 @@ typedef struct ase_awk_srcios_t ase_awk_srcios_t;
|
||||
typedef struct ase_awk_runios_t ase_awk_runios_t;
|
||||
typedef struct ase_awk_runcbs_t ase_awk_runcbs_t;
|
||||
typedef struct ase_awk_runarg_t ase_awk_runarg_t;
|
||||
typedef struct ase_awk_rexfns_t ase_awk_rexfns_t;
|
||||
|
||||
typedef ase_real_t (*ase_awk_pow_t) (void* custom, ase_real_t x, ase_real_t y);
|
||||
typedef int (*ase_awk_sprintf_t) (
|
||||
@ -119,6 +125,23 @@ struct ase_awk_runarg_t
|
||||
ase_size_t len;
|
||||
};
|
||||
|
||||
struct ase_awk_rexfns_t
|
||||
{
|
||||
void* (*build) (
|
||||
ase_awk_t* awk, const ase_char_t* ptn,
|
||||
ase_size_t len, int* errnum);
|
||||
|
||||
int (*match) (
|
||||
ase_awk_t* awk, void* code, int option,
|
||||
const ase_char_t* str, ase_size_t len,
|
||||
const ase_char_t** mptr, ase_size_t* mlen,
|
||||
int* errnum);
|
||||
|
||||
void (*free) (ase_awk_t* awk, void* code);
|
||||
|
||||
ase_bool_t (*isempty) (ase_awk_t* awk, void* code);
|
||||
};
|
||||
|
||||
/* io function commands */
|
||||
enum ase_awk_iocmd_t
|
||||
{
|
||||
@ -468,19 +491,34 @@ void ase_awk_setmaxdepth (ase_awk_t* awk, int types, ase_size_t depth);
|
||||
int ase_awk_getword (ase_awk_t* awk,
|
||||
const ase_char_t* okw, ase_size_t olen,
|
||||
const ase_char_t** nkw, ase_size_t* nlen);
|
||||
/*
|
||||
/**
|
||||
* Enables replacement of a name of a keyword, intrinsic global variables,
|
||||
* and intrinsic functions.
|
||||
*
|
||||
* If nkw is ASE_NULL or nlen is zero and okw is ASE_NULL or olen is zero,
|
||||
* it unsets all word replacements. If nkw is ASE_NULL or nlen is zero,
|
||||
* it unsets the replacement for okw and olen. If all of them are valid,
|
||||
* it sets the word replace for okw and olen to nkw and nlen.
|
||||
*
|
||||
* @return
|
||||
* On success, 0 is returned.
|
||||
* On failure, -1 is returned.
|
||||
*/
|
||||
int ase_awk_setword (ase_awk_t* awk,
|
||||
const ase_char_t* okw, ase_size_t olen,
|
||||
const ase_char_t* nkw, ase_size_t nlen);
|
||||
|
||||
int ase_awk_parse (ase_awk_t* awk, ase_awk_srcios_t* srcios);
|
||||
/**
|
||||
* Sets the customized regular processing routine.
|
||||
*
|
||||
* @return
|
||||
* On success, 0 is returned.
|
||||
* On failure, -1 is returned.
|
||||
*/
|
||||
int ase_awk_setrexfns (ase_awk_t* awk, ase_awk_rexfns_t* rexfns);
|
||||
|
||||
/*
|
||||
* Adds an intrinsic global variable. It should be called in
|
||||
* add_globals_callback.
|
||||
/**
|
||||
* Adds an intrinsic global variable.
|
||||
*
|
||||
* @return
|
||||
* On success, the ID of the global variable added is returned.
|
||||
@ -488,7 +526,7 @@ int ase_awk_parse (ase_awk_t* awk, ase_awk_srcios_t* srcios);
|
||||
*/
|
||||
int ase_awk_addglobal (ase_awk_t* awk, const ase_char_t* name, ase_size_t len);
|
||||
|
||||
/*
|
||||
/**
|
||||
* Deletes a instrinsic global variable.
|
||||
*
|
||||
* @return
|
||||
@ -497,8 +535,19 @@ int ase_awk_addglobal (ase_awk_t* awk, const ase_char_t* name, ase_size_t len);
|
||||
*/
|
||||
int ase_awk_delglobal (ase_awk_t* awk, const ase_char_t* name, ase_size_t len);
|
||||
|
||||
/*
|
||||
* ase_awk_run return 0 on success and -1 on failure, generally speaking.
|
||||
/**
|
||||
* Parses the source code
|
||||
*
|
||||
* @return
|
||||
* On success, 0 is returned.
|
||||
* On failure, -1 is returned.
|
||||
*/
|
||||
int ase_awk_parse (ase_awk_t* awk, ase_awk_srcios_t* srcios);
|
||||
|
||||
/**
|
||||
* Executes a parsed program.
|
||||
*
|
||||
* ase_awk_run returns 0 on success and -1 on failure, generally speaking.
|
||||
* A runtime context is required for it to start running the program.
|
||||
* Once the runtime context is created, the program starts to run.
|
||||
* The context creation failure is reported by the return value -1 of
|
||||
@ -522,8 +571,14 @@ void ase_awk_stopall (ase_awk_t* awk);
|
||||
ase_bool_t ase_awk_isstop (ase_awk_run_t* run);
|
||||
|
||||
|
||||
/* functions to access internal stack structure */
|
||||
/**
|
||||
* Gets the number of arguments passed to ase_awk_run
|
||||
*/
|
||||
ase_size_t ase_awk_getnargs (ase_awk_run_t* run);
|
||||
|
||||
/**
|
||||
* Gets an argument passed to ase_awk_run
|
||||
*/
|
||||
ase_awk_val_t* ase_awk_getarg (ase_awk_run_t* run, ase_size_t idx);
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk_i.h,v 1.11 2007/11/05 14:20:47 bacon Exp $
|
||||
* $Id: awk_i.h,v 1.12 2007/11/10 15:00:51 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -79,6 +79,9 @@ struct ase_awk_t
|
||||
/* reverse word table */
|
||||
ase_awk_map_t* rwtab;
|
||||
|
||||
/* regular expression processing routines */
|
||||
ase_awk_rexfns_t* rexfns;
|
||||
|
||||
/* parse tree */
|
||||
ase_awk_tree_t tree;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: map.c,v 1.10 2007/09/30 15:12:20 bacon Exp $
|
||||
* $Id: map.c,v 1.11 2007/11/10 15:21:40 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -156,8 +156,7 @@ int ase_awk_map_putx (
|
||||
if (pair == ASE_NULL) return -1; /* error */
|
||||
|
||||
/* duplicate the key if it is new */
|
||||
ASE_AWK_PAIR_KEYPTR(pair) = ase_strxdup (
|
||||
keyptr, keylen, &map->awk->prmfns.mmgr);
|
||||
ASE_AWK_PAIR_KEYPTR(pair) = ase_awk_strxdup (map->awk, keyptr, keylen);
|
||||
if (ASE_AWK_PAIR_KEYPTR(pair) == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (map->awk, pair);
|
||||
|
147
ase/awk/parse.c
147
ase/awk/parse.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: parse.c,v 1.31 2007/11/09 15:08:41 bacon Exp $
|
||||
* $Id: parse.c,v 1.34 2007/11/10 15:21:40 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -243,7 +243,6 @@ static kwent_t kwtab[] =
|
||||
{ ASE_T("BEGIN"), 5, TOKEN_BEGIN, ASE_AWK_PABLOCK },
|
||||
{ ASE_T("END"), 3, TOKEN_END, ASE_AWK_PABLOCK },
|
||||
{ ASE_T("function"), 8, TOKEN_FUNCTION, 0 },
|
||||
{ ASE_T("func"), 4, TOKEN_FUNCTION, 0 },
|
||||
|
||||
/* keywords for variable declaration */
|
||||
{ ASE_T("local"), 5, TOKEN_LOCAL, ASE_AWK_EXPLICIT },
|
||||
@ -436,102 +435,12 @@ const ase_char_t* ase_awk_getglobalname (
|
||||
return awk->parse.globals.buf[idx].name.ptr;
|
||||
}
|
||||
|
||||
int ase_awk_getword (ase_awk_t* awk,
|
||||
const ase_char_t* okw, ase_size_t olen,
|
||||
const ase_char_t** nkw, ase_size_t* nlen)
|
||||
{
|
||||
ase_awk_pair_t* p;
|
||||
|
||||
p = ase_awk_map_get (awk->wtab, okw, olen);
|
||||
if (p == ASE_NULL) return -1;
|
||||
|
||||
*nkw = ((ase_cstr_t*)p->val)->ptr;
|
||||
*nlen = ((ase_cstr_t*)p->val)->len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ase_awk_setword (ase_awk_t* awk,
|
||||
const ase_char_t* okw, ase_size_t olen,
|
||||
const ase_char_t* nkw, ase_size_t nlen)
|
||||
{
|
||||
ase_cstr_t* vn, * vo;
|
||||
|
||||
if (nkw == ASE_NULL || nlen == 0)
|
||||
{
|
||||
ase_awk_pair_t* p;
|
||||
|
||||
if (okw == ASE_NULL || olen == 0)
|
||||
{
|
||||
/* clear the entire table */
|
||||
ase_awk_map_clear (awk->wtab);
|
||||
ase_awk_map_clear (awk->rwtab);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* delete the word */
|
||||
p = ase_awk_map_get (awk->wtab, okw, olen);
|
||||
if (p != ASE_NULL)
|
||||
{
|
||||
ase_cstr_t* s = (ase_cstr_t*)p->val;
|
||||
ase_awk_map_remove (awk->rwtab, s->ptr, s->len);
|
||||
ase_awk_map_remove (awk->wtab, okw, olen);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SETERRARG (awk, ASE_AWK_ENOENT, 0, okw, olen);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* set the word */
|
||||
vn = (ase_cstr_t*) ASE_AWK_MALLOC (
|
||||
awk, ASE_SIZEOF(ase_cstr_t)+((nlen+1)*ASE_SIZEOF(*nkw)));
|
||||
if (vn == ASE_NULL)
|
||||
{
|
||||
SETERR (awk, ASE_AWK_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
vn->len = nlen;
|
||||
vn->ptr = (const ase_char_t*)(vn + 1);
|
||||
ase_strncpy ((ase_char_t*)vn->ptr, nkw, nlen);
|
||||
|
||||
vo = (ase_cstr_t*)ASE_AWK_MALLOC (
|
||||
awk, ASE_SIZEOF(ase_cstr_t)+((olen+1)*ASE_SIZEOF(*okw)));
|
||||
if (vo == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (awk, vn);
|
||||
SETERR (awk, ASE_AWK_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
vo->len = olen;
|
||||
vo->ptr = (const ase_char_t*)(vo + 1);
|
||||
ase_strncpy ((ase_char_t*)vo->ptr, okw, olen);
|
||||
|
||||
if (ase_awk_map_put (awk->wtab, okw, olen, vn) == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (awk, vo);
|
||||
ASE_AWK_FREE (awk, vn);
|
||||
SETERR (awk, ASE_AWK_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ase_awk_map_put (awk->rwtab, nkw, nlen, vo) == ASE_NULL)
|
||||
{
|
||||
ase_awk_map_remove (awk->wtab, okw, olen);
|
||||
ASE_AWK_FREE (awk, vo);
|
||||
SETERR (awk, ASE_AWK_ENOMEM);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const ase_char_t* ase_awk_getkw (ase_awk_t* awk, const ase_char_t* kw)
|
||||
{
|
||||
ase_awk_pair_t* p;
|
||||
|
||||
ASE_ASSERT (kw != ASE_NULL);
|
||||
|
||||
p = ase_awk_map_get (awk->wtab, kw, ase_strlen(kw));
|
||||
if (p != ASE_NULL) return ((ase_cstr_t*)p->val)->ptr;
|
||||
|
||||
@ -916,7 +825,7 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk)
|
||||
}
|
||||
|
||||
/* clone the function name before it is overwritten */
|
||||
name_dup = ase_strxdup (name, name_len, &awk->prmfns.mmgr);
|
||||
name_dup = ase_awk_strxdup (awk, name, name_len);
|
||||
if (name_dup == ASE_NULL)
|
||||
{
|
||||
SETERRLIN (awk, ASE_AWK_ENOMEM, awk->token.line);
|
||||
@ -2703,10 +2612,9 @@ static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line)
|
||||
nde->val = ase_awk_strxtolong (awk,
|
||||
ASE_STR_BUF(&awk->token.name),
|
||||
ASE_STR_LEN(&awk->token.name), 0, ASE_NULL);
|
||||
nde->str = ase_strxdup (
|
||||
nde->str = ase_awk_strxdup (awk,
|
||||
ASE_STR_BUF(&awk->token.name),
|
||||
ASE_STR_LEN(&awk->token.name),
|
||||
&awk->prmfns.mmgr);
|
||||
ASE_STR_LEN(&awk->token.name));
|
||||
if (nde->str == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (awk, nde);
|
||||
@ -2745,10 +2653,9 @@ static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line)
|
||||
nde->val = ase_awk_strxtoreal (awk,
|
||||
ASE_STR_BUF(&awk->token.name),
|
||||
ASE_STR_LEN(&awk->token.name), ASE_NULL);
|
||||
nde->str = ase_strxdup (
|
||||
nde->str = ase_awk_strxdup (awk,
|
||||
ASE_STR_BUF(&awk->token.name),
|
||||
ASE_STR_LEN(&awk->token.name),
|
||||
&awk->prmfns.mmgr);
|
||||
ASE_STR_LEN(&awk->token.name));
|
||||
if (nde->str == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (awk, nde);
|
||||
@ -2785,10 +2692,8 @@ static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line)
|
||||
nde->line = line;
|
||||
nde->next = ASE_NULL;
|
||||
nde->len = ASE_STR_LEN(&awk->token.name);
|
||||
nde->buf = ase_strxdup (
|
||||
ASE_STR_BUF(&awk->token.name),
|
||||
nde->len,
|
||||
&awk->prmfns.mmgr);
|
||||
nde->buf = ase_awk_strxdup (awk,
|
||||
ASE_STR_BUF(&awk->token.name), nde->len);
|
||||
if (nde->buf == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (awk, nde);
|
||||
@ -2831,10 +2736,9 @@ static ase_awk_nde_t* parse_primary (ase_awk_t* awk, ase_size_t line)
|
||||
nde->next = ASE_NULL;
|
||||
|
||||
nde->len = ASE_STR_LEN(&awk->token.name);
|
||||
nde->buf = ase_strxdup (
|
||||
nde->buf = ase_awk_strxdup (awk,
|
||||
ASE_STR_BUF(&awk->token.name),
|
||||
ASE_STR_LEN(&awk->token.name),
|
||||
&awk->prmfns.mmgr);
|
||||
ASE_STR_LEN(&awk->token.name));
|
||||
if (nde->buf == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (awk, nde);
|
||||
@ -3055,10 +2959,9 @@ static ase_awk_nde_t* parse_primary_ident (ase_awk_t* awk, ase_size_t line)
|
||||
|
||||
ASE_ASSERT (MATCH(awk,TOKEN_IDENT));
|
||||
|
||||
name_dup = ase_strxdup (
|
||||
name_dup = ase_awk_strxdup (awk,
|
||||
ASE_STR_BUF(&awk->token.name),
|
||||
ASE_STR_LEN(&awk->token.name),
|
||||
&awk->prmfns.mmgr);
|
||||
ASE_STR_LEN(&awk->token.name));
|
||||
if (name_dup == ASE_NULL)
|
||||
{
|
||||
SETERRLIN (awk, ASE_AWK_ENOMEM, line);
|
||||
@ -3174,26 +3077,6 @@ static ase_awk_nde_t* parse_primary_ident (ase_awk_t* awk, ase_size_t line)
|
||||
return (ase_awk_nde_t*)nde;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// TODO:...
|
||||
{
|
||||
/* check if it is a function name */
|
||||
ase_awk_pair_t* pair;
|
||||
pair = ase_awk_map_get (awk->tree.afns, name_dup, name_len);
|
||||
|
||||
afn = (ase_awk_afn_t*)pair->val;
|
||||
nde->type = ASE_AWK_NDE_VARAFN;
|
||||
nde->line = line;
|
||||
nde->next = ASE_NULL;
|
||||
/*nde->id.name = ASE_NULL;*/
|
||||
nde->id.name = name_dup;
|
||||
nde->id.name_len = name_len;
|
||||
nde->id.idxa = idxa; /* pointer... */
|
||||
nde->idx = ASE_NULL;
|
||||
}
|
||||
// END TODO:...
|
||||
#endif
|
||||
|
||||
if (awk->option & ASE_AWK_IMPLICIT)
|
||||
{
|
||||
if (awk->option & ASE_AWK_UNIQUEFN)
|
||||
@ -5502,7 +5385,7 @@ static int deparse_func (ase_awk_pair_t* pair, void* arg)
|
||||
|
||||
ASE_ASSERT (ase_strxncmp (ASE_AWK_PAIR_KEYPTR(pair), ASE_AWK_PAIR_KEYLEN(pair), afn->name, afn->name_len) == 0);
|
||||
|
||||
if (ase_awk_putsrcstr(df->awk,ase_awk_getkw(df->awk,ASE_T("func"))) == -1)
|
||||
if (ase_awk_putsrcstr(df->awk,ase_awk_getkw(df->awk,ASE_T("function"))) == -1) return -1;
|
||||
if (ase_awk_putsrcstr (df->awk, ASE_T(" ")) == -1) return -1;
|
||||
if (ase_awk_putsrcstr (df->awk, afn->name) == -1) return -1;
|
||||
if (ase_awk_putsrcstr (df->awk, ASE_T(" (")) == -1) return -1;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.c,v 1.23 2007/11/09 07:43:42 bacon Exp $
|
||||
* $Id: run.c,v 1.25 2007/11/10 15:21:40 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -1275,9 +1275,8 @@ static int run_main (
|
||||
}
|
||||
|
||||
tmp->type = ASE_AWK_NDE_STR;
|
||||
tmp->buf = ase_strxdup (
|
||||
runarg[i].ptr, runarg[i].len,
|
||||
&run->awk->prmfns.mmgr);
|
||||
tmp->buf = ase_awk_strxdup (run->awk,
|
||||
runarg[i].ptr, runarg[i].len);
|
||||
if (tmp->buf == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (run->awk, tmp);
|
||||
@ -4716,10 +4715,8 @@ static ase_awk_val_t* eval_incpre (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
||||
ase_awk_val_t* left, * res;
|
||||
ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde;
|
||||
|
||||
ASE_ASSERT (
|
||||
exp->type == ASE_AWK_NDE_EXP_INCPRE);
|
||||
ASE_ASSERT (
|
||||
exp->left != ASE_NULL && exp->right == ASE_NULL);
|
||||
ASE_ASSERT (exp->type == ASE_AWK_NDE_EXP_INCPRE);
|
||||
ASE_ASSERT (exp->left != ASE_NULL && exp->right == ASE_NULL);
|
||||
|
||||
/* this way of checking if the l-value is assignable is
|
||||
* ugly as it is dependent of the values defined in tree.h.
|
||||
@ -4892,10 +4889,8 @@ static ase_awk_val_t* eval_incpst (ase_awk_run_t* run, ase_awk_nde_t* nde)
|
||||
ase_awk_val_t* left, * res, * res2;
|
||||
ase_awk_nde_exp_t* exp = (ase_awk_nde_exp_t*)nde;
|
||||
|
||||
ASE_ASSERT (
|
||||
exp->type == ASE_AWK_NDE_EXP_INCPST);
|
||||
ASE_ASSERT (
|
||||
exp->left != ASE_NULL && exp->right == ASE_NULL);
|
||||
ASE_ASSERT (exp->type == ASE_AWK_NDE_EXP_INCPST);
|
||||
ASE_ASSERT (exp->left != ASE_NULL && exp->right == ASE_NULL);
|
||||
|
||||
/* this way of checking if the l-value is assignable is
|
||||
* ugly as it is dependent of the values defined in tree.h.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: tab.c,v 1.5 2007/11/06 09:47:12 bacon Exp $
|
||||
* $Id: tab.c,v 1.6 2007/11/10 15:21:40 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -116,7 +116,7 @@ ase_size_t ase_awk_tab_insert (
|
||||
ase_size_t i;
|
||||
ase_char_t* dup;
|
||||
|
||||
dup = ase_strxdup (str, len, &tab->awk->prmfns.mmgr);
|
||||
dup = ase_awk_strxdup (tab->awk, str, len);
|
||||
if (dup == ASE_NULL) return (ase_size_t)-1;
|
||||
|
||||
if (index >= tab->capa)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: tree.h,v 1.7 2007/11/07 14:40:37 bacon Exp $
|
||||
* $Id: tree.h,v 1.8 2007/11/10 12:49:10 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -52,7 +52,7 @@ enum ase_awk_nde_type_t
|
||||
ASE_AWK_NDE_REX,
|
||||
|
||||
/* keep this order for the following items otherwise, you may have
|
||||
* to change __eval_incpre and __eval_incpst in run.c as well as
|
||||
* to change eval_incpre and eval_incpst in run.c as well as
|
||||
* ASE_AWK_VAL_REF_XXX in val.h */
|
||||
ASE_AWK_NDE_NAMED,
|
||||
ASE_AWK_NDE_GLOBAL,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: val.c,v 1.13 2007/11/09 15:20:02 bacon Exp $
|
||||
* $Id: val.c,v 1.14 2007/11/10 15:21:40 bacon Exp $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -222,7 +222,7 @@ ase_awk_val_t* ase_awk_makerexval (
|
||||
val->type = ASE_AWK_VAL_REX;
|
||||
val->ref = 0;
|
||||
val->len = len;
|
||||
val->buf = ase_strxdup (buf, len, &run->awk->prmfns.mmgr);
|
||||
val->buf = ase_awk_strxdup (run->awk, buf, len);
|
||||
if (val->buf == ASE_NULL)
|
||||
{
|
||||
ASE_AWK_FREE (run->awk, val);
|
||||
@ -523,7 +523,7 @@ static ase_char_t* str_to_str (
|
||||
if (buf == ASE_NULL)
|
||||
{
|
||||
ase_char_t* tmp;
|
||||
tmp = ase_strxdup (str, str_len, &run->awk->prmfns.mmgr);
|
||||
tmp = ase_awk_strxdup (run->awk, str, str_len);
|
||||
if (tmp == ASE_NULL)
|
||||
{
|
||||
ase_awk_setrunerror (
|
||||
|
@ -83,17 +83,20 @@ WARN_LOGFILE =
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ../../ase
|
||||
FILE_PATTERNS = *.cc \
|
||||
FILE_PATTERNS = *.h \
|
||||
*.cc \
|
||||
*.cxx \
|
||||
*.cpp \
|
||||
*.c++ \
|
||||
*.hxx \
|
||||
*.hpp \
|
||||
*.h++
|
||||
*.h++ \
|
||||
*.java
|
||||
RECURSIVE = YES
|
||||
EXCLUDE = ../net \
|
||||
../com \
|
||||
../stx \
|
||||
../test/awk \
|
||||
../test/net \
|
||||
../test/com \
|
||||
../test/stx
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: AseAwkPanel.java,v 1.26 2007/11/07 15:32:41 bacon Exp $
|
||||
* $Id: AseAwkPanel.java,v 1.27 2007/11/10 12:56:49 bacon Exp $
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
@ -655,8 +655,8 @@ System.out.println ("Original: " + getWord(name));
|
||||
else
|
||||
msg = "An exception occurred - [" + code + "] " + e.getMessage() + " at line " + line;
|
||||
|
||||
statusLabel.setText (msg);
|
||||
showMessage (msg);
|
||||
statusLabel.setText (msg);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
|
Loading…
Reference in New Issue
Block a user