This commit is contained in:
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: env.c 215 2008-06-19 10:27:37Z baconevi $
|
||||
* $Id: env.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
/* TODO: make the frame hash accessible */
|
||||
|
||||
@ -15,7 +15,7 @@ static ase_lsp_assoc_t* __new_assoc (
|
||||
ase_lsp_assoc_t* assoc;
|
||||
|
||||
assoc = (ase_lsp_assoc_t*)
|
||||
ASE_LSP_MALLOC (lsp, sizeof(ase_lsp_assoc_t));
|
||||
ASE_LSP_ALLOC (lsp, sizeof(ase_lsp_assoc_t));
|
||||
if (assoc == ASE_NULL)
|
||||
{
|
||||
ase_lsp_seterror (lsp, ASE_LSP_ENOMEM, ASE_NULL, 0);
|
||||
@ -35,7 +35,7 @@ ase_lsp_frame_t* ase_lsp_newframe (ase_lsp_t* lsp)
|
||||
ase_lsp_frame_t* frame;
|
||||
|
||||
frame = (ase_lsp_frame_t*)
|
||||
ASE_LSP_MALLOC (lsp, sizeof(ase_lsp_frame_t));
|
||||
ASE_LSP_ALLOC (lsp, sizeof(ase_lsp_frame_t));
|
||||
if (frame == ASE_NULL)
|
||||
{
|
||||
ase_lsp_seterror (lsp, ASE_LSP_ENOMEM, ASE_NULL, 0);
|
||||
@ -117,7 +117,7 @@ ase_lsp_tlink_t* ase_lsp_pushtmp (ase_lsp_t* lsp, ase_lsp_obj_t* obj)
|
||||
ase_lsp_tlink_t* tlink;
|
||||
|
||||
tlink = (ase_lsp_tlink_t*)
|
||||
ASE_LSP_MALLOC (lsp, sizeof(ase_lsp_tlink_t));
|
||||
ASE_LSP_ALLOC (lsp, sizeof(ase_lsp_tlink_t));
|
||||
if (tlink == ASE_NULL)
|
||||
{
|
||||
ase_lsp_seterror (lsp, ASE_LSP_ENOMEM, ASE_NULL, 0);
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: err.c 332 2008-08-18 11:21:48Z baconevi $
|
||||
* $Id: err.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
static const ase_char_t* __geterrstr (int errnum)
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: eval.c 215 2008-06-19 10:27:37Z baconevi $
|
||||
* $Id: eval.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
static ase_lsp_obj_t* __eval (ase_lsp_t* lsp, ase_lsp_obj_t* obj);
|
||||
static ase_lsp_obj_t* makefn (
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: lsp.c 332 2008-08-18 11:21:48Z baconevi $
|
||||
* $Id: lsp.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -9,7 +9,7 @@
|
||||
#define Library
|
||||
#endif
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
static int __add_builtin_prims (ase_lsp_t* lsp);
|
||||
|
||||
@ -21,6 +21,7 @@ ase_lsp_t* ase_lsp_open (
|
||||
|
||||
if (prmfns == ASE_NULL) return ASE_NULL;
|
||||
|
||||
/*
|
||||
if (prmfns->mmgr.malloc == ASE_NULL ||
|
||||
prmfns->mmgr.realloc == ASE_NULL ||
|
||||
prmfns->mmgr.free == ASE_NULL) return ASE_NULL;
|
||||
@ -38,6 +39,7 @@ ase_lsp_t* ase_lsp_open (
|
||||
prmfns->ccls.is_punct == ASE_NULL ||
|
||||
prmfns->ccls.to_upper == ASE_NULL ||
|
||||
prmfns->ccls.to_lower == ASE_NULL) return ASE_NULL;
|
||||
*/
|
||||
|
||||
if (prmfns->misc.sprintf == ASE_NULL ||
|
||||
prmfns->misc.dprintf == ASE_NULL) return ASE_NULL;
|
||||
@ -45,7 +47,7 @@ ase_lsp_t* ase_lsp_open (
|
||||
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
|
||||
lsp = (ase_lsp_t*) malloc (ASE_SIZEOF(ase_lsp_t));
|
||||
#else
|
||||
lsp = (ase_lsp_t*) prmfns->mmgr.malloc (
|
||||
lsp = (ase_lsp_t*) prmfns->mmgr.alloc (
|
||||
prmfns->mmgr.data, ASE_SIZEOF(ase_lsp_t));
|
||||
#endif
|
||||
if (lsp == ASE_NULL) return ASE_NULL;
|
||||
|
81
ase/lib/lsp/lsp.h
Normal file
81
ase/lib/lsp/lsp.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* $Id: lsp_i.h 332 2008-08-18 11:21:48Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_LIB_LSP_LSP_H_
|
||||
#define _ASE_LIB_LSP_LSP_H_
|
||||
|
||||
#include "../cmn/mem.h"
|
||||
#include "../cmn/chr.h"
|
||||
#include <ase/cmn/str.h>
|
||||
|
||||
#include <ase/lsp/lsp.h>
|
||||
#include "env.h"
|
||||
#include "obj.h"
|
||||
#include "mem.h"
|
||||
#include "misc.h"
|
||||
#include "prim.h"
|
||||
#include "name.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable: 4996)
|
||||
#endif
|
||||
|
||||
#define ASE_LSP_ALLOC(lsp,size) ASE_MMGR_ALLOC(&(lsp)->prmfns.mmgr,size)
|
||||
#define ASE_LSP_REALLOC(lsp,ptr,size) ASE_MMGR_REALLOC(&(lsp)->prmfns.mmgr,ptr,size)
|
||||
#define ASE_LSP_FREE(lsp,ptr) ASE_MMGR_FREE(&(lsp)->prmfns.mmgr,ptr)
|
||||
|
||||
#define ASE_LSP_ISUPPER(lsp,c) ASE_CCLS_ISUPPER(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISLOWER(lsp,c) ASE_CCLS_ISLOWER(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISALPHA(lsp,c) ASE_CCLS_ISALPHA(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISDIGIT(lsp,c) ASE_CCLS_ISDIGIT(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISXDIGIT(lsp,c) ASE_CCLS_ISXDIGIT(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISALNUM(lsp,c) ASE_CCLS_ISALNUM(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISSPACE(lsp,c) ASE_CCLS_ISSPACE(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISPRINT(lsp,c) ASE_CCLS_ISPRINT(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISGRAPH(lsp,c) ASE_CCLS_ISGRAPH(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISCNTRL(lsp,c) ASE_CCLS_ISCNTRL(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISPUNCT(lsp,c) ASE_CCLS_ISPUNCT(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_TOUPPER(lsp,c) ASE_CCLS_TOUPPER(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_TOLOWER(lsp,c) ASE_CCLS_TOLOWER(&(lsp)->prmfns.ccls,c)
|
||||
|
||||
struct ase_lsp_t
|
||||
{
|
||||
ase_lsp_prmfns_t prmfns;
|
||||
/* user-specified data */
|
||||
void* assoc_data;
|
||||
|
||||
/* error */
|
||||
int errnum;
|
||||
ase_char_t errmsg[256];
|
||||
|
||||
/* options */
|
||||
int opt_undef_symbol;
|
||||
|
||||
/* for read */
|
||||
ase_cint_t curc;
|
||||
struct
|
||||
{
|
||||
int type;
|
||||
ase_long_t ival;
|
||||
ase_real_t rval;
|
||||
ase_lsp_name_t name;
|
||||
} token;
|
||||
|
||||
/* io functions */
|
||||
ase_lsp_io_t input_func;
|
||||
ase_lsp_io_t output_func;
|
||||
void* input_arg;
|
||||
void* output_arg;
|
||||
|
||||
/* security options */
|
||||
ase_size_t max_eval_depth;
|
||||
ase_size_t cur_eval_depth;
|
||||
|
||||
/* memory manager */
|
||||
ase_lsp_mem_t* mem;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* $Id: lsp_i.h 332 2008-08-18 11:21:48Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#ifndef _ASE_LSP_LSPI_H_
|
||||
#define _ASE_LSP_LSPI_H_
|
||||
|
||||
#include "../cmn/mem.h"
|
||||
#include <ase/cmn/str.h>
|
||||
|
||||
#include <ase/lsp/lsp.h>
|
||||
#include "env.h"
|
||||
#include "obj.h"
|
||||
#include "mem.h"
|
||||
#include "misc.h"
|
||||
#include "prim.h"
|
||||
#include "name.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable: 4996)
|
||||
#endif
|
||||
|
||||
#define ASE_LSP_MALLOC(lsp,size) ASE_MALLOC(&(lsp)->prmfns.mmgr,size)
|
||||
#define ASE_LSP_REALLOC(lsp,ptr,size) ASE_REALLOC(&(lsp)->prmfns.mmgr,ptr,size)
|
||||
#define ASE_LSP_FREE(lsp,ptr) ASE_FREE(&(lsp)->prmfns.mmgr,ptr)
|
||||
|
||||
#define ASE_LSP_ISUPPER(lsp,c) ASE_ISUPPER(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISLOWER(lsp,c) ASE_ISLOWER(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISALPHA(lsp,c) ASE_ISALPHA(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISDIGIT(lsp,c) ASE_ISDIGIT(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISXDIGIT(lsp,c) ASE_ISXDIGIT(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISALNUM(lsp,c) ASE_ISALNUM(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISSPACE(lsp,c) ASE_ISSPACE(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISPRINT(lsp,c) ASE_ISPRINT(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISGRAPH(lsp,c) ASE_ISGRAPH(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISCNTRL(lsp,c) ASE_ISCNTRL(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_ISPUNCT(lsp,c) ASE_ISPUNCT(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_TOUPPER(lsp,c) ASE_TOUPPER(&(lsp)->prmfns.ccls,c)
|
||||
#define ASE_LSP_TOLOWER(lsp,c) ASE_TOLOWER(&(lsp)->prmfns.ccls,c)
|
||||
|
||||
struct ase_lsp_t
|
||||
{
|
||||
ase_lsp_prmfns_t prmfns;
|
||||
/* user-specified data */
|
||||
void* assoc_data;
|
||||
|
||||
/* error */
|
||||
int errnum;
|
||||
ase_char_t errmsg[256];
|
||||
|
||||
/* options */
|
||||
int opt_undef_symbol;
|
||||
|
||||
/* for read */
|
||||
ase_cint_t curc;
|
||||
struct
|
||||
{
|
||||
int type;
|
||||
ase_long_t ival;
|
||||
ase_real_t rval;
|
||||
ase_lsp_name_t name;
|
||||
} token;
|
||||
|
||||
/* io functions */
|
||||
ase_lsp_io_t input_func;
|
||||
ase_lsp_io_t output_func;
|
||||
void* input_arg;
|
||||
void* output_arg;
|
||||
|
||||
/* security options */
|
||||
ase_size_t max_eval_depth;
|
||||
ase_size_t cur_eval_depth;
|
||||
|
||||
/* memory manager */
|
||||
ase_lsp_mem_t* mem;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: mem.c 332 2008-08-18 11:21:48Z baconevi $
|
||||
* $Id: mem.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
ase_lsp_mem_t* ase_lsp_openmem (
|
||||
ase_lsp_t* lsp, ase_size_t ubound, ase_size_t ubound_inc)
|
||||
@ -13,7 +13,7 @@ ase_lsp_mem_t* ase_lsp_openmem (
|
||||
ase_size_t i;
|
||||
|
||||
/* allocate memory */
|
||||
mem = (ase_lsp_mem_t*) ASE_LSP_MALLOC (lsp, ASE_SIZEOF(ase_lsp_mem_t));
|
||||
mem = (ase_lsp_mem_t*) ASE_LSP_ALLOC (lsp, ASE_SIZEOF(ase_lsp_mem_t));
|
||||
if (mem == ASE_NULL) return ASE_NULL;
|
||||
|
||||
ASE_MEMSET (mem, 0, ASE_SIZEOF(ase_lsp_mem_t));
|
||||
@ -104,12 +104,12 @@ ase_lsp_gc (mem);
|
||||
if (mem->count >= mem->ubound) return ASE_NULL;
|
||||
}
|
||||
|
||||
obj = (ase_lsp_obj_t*) ASE_LSP_MALLOC (mem->lsp, size);
|
||||
obj = (ase_lsp_obj_t*) ASE_LSP_ALLOC (mem->lsp, size);
|
||||
if (obj == ASE_NULL)
|
||||
{
|
||||
ase_lsp_gc (mem);
|
||||
|
||||
obj = (ase_lsp_obj_t*) ASE_LSP_MALLOC (mem->lsp, size);
|
||||
obj = (ase_lsp_obj_t*) ASE_LSP_ALLOC (mem->lsp, size);
|
||||
if (obj == ASE_NULL)
|
||||
{
|
||||
ase_lsp_seterror (mem->lsp, ASE_LSP_ENOMEM, ASE_NULL, 0);
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: misc.c 215 2008-06-19 10:27:37Z baconevi $
|
||||
* $Id: misc.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
ase_long_t ase_lsp_strxtolong (
|
||||
ase_lsp_t* lsp, const ase_char_t* str, ase_size_t len,
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: name.c 332 2008-08-18 11:21:48Z baconevi $
|
||||
* $Id: name.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
ase_lsp_name_t* ase_lsp_name_open (
|
||||
ase_lsp_name_t* name, ase_size_t capa, ase_lsp_t* lsp)
|
||||
@ -14,7 +14,7 @@ ase_lsp_name_t* ase_lsp_name_open (
|
||||
if (name == ASE_NULL)
|
||||
{
|
||||
name = (ase_lsp_name_t*)
|
||||
ASE_LSP_MALLOC (lsp, ASE_SIZEOF(ase_lsp_name_t));
|
||||
ASE_LSP_ALLOC (lsp, ASE_SIZEOF(ase_lsp_name_t));
|
||||
if (name == ASE_NULL) return ASE_NULL;
|
||||
name->__dynamic = ASE_TRUE;
|
||||
}
|
||||
@ -27,7 +27,7 @@ ase_lsp_name_t* ase_lsp_name_open (
|
||||
else
|
||||
{
|
||||
name->buf = (ase_char_t*)
|
||||
ASE_LSP_MALLOC (lsp, (capa+1)*ASE_SIZEOF(ase_char_t));
|
||||
ASE_LSP_ALLOC (lsp, (capa+1)*ASE_SIZEOF(ase_char_t));
|
||||
if (name->buf == ASE_NULL)
|
||||
{
|
||||
if (name->__dynamic) ASE_LSP_FREE (lsp, name);
|
||||
@ -66,7 +66,7 @@ int ase_lsp_name_addc (ase_lsp_name_t* name, ase_cint_t c)
|
||||
|
||||
if (name->capa < ASE_COUNTOF(name->static_buf))
|
||||
{
|
||||
space = (ase_char_t*) ASE_LSP_MALLOC (
|
||||
space = (ase_char_t*) ASE_LSP_ALLOC (
|
||||
name->lsp, (new_capa+1)*ASE_SIZEOF(ase_char_t));
|
||||
if (space == ASE_NULL) return -1;
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: prim.c 215 2008-06-19 10:27:37Z baconevi $
|
||||
* $Id: prim.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
static int __add_prim (ase_lsp_mem_t* mem,
|
||||
const ase_char_t* name, ase_size_t len,
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: prim_compar.c 215 2008-06-19 10:27:37Z baconevi $
|
||||
* $Id: prim_compar.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
#define PRIM_COMPAR(lsp,args,op) \
|
||||
{ \
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: prim_let.c 215 2008-06-19 10:27:37Z baconevi $
|
||||
* $Id: prim_let.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
/*
|
||||
* (let ((variable value)
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: prim_math.c 215 2008-06-19 10:27:37Z baconevi $
|
||||
* $Id: prim_math.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
ase_lsp_obj_t* ase_lsp_prim_plus (ase_lsp_t* lsp, ase_lsp_obj_t* args)
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: prim_prog.c 215 2008-06-19 10:27:37Z baconevi $
|
||||
* $Id: prim_prog.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
ase_lsp_obj_t* ase_lsp_prim_prog1 (ase_lsp_t* lsp, ase_lsp_obj_t* args)
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: print.c 332 2008-08-18 11:21:48Z baconevi $
|
||||
* $Id: print.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
#define OUTPUT_STR(lsp,str) \
|
||||
do { \
|
||||
|
@ -1,10 +1,10 @@
|
||||
/*
|
||||
* $Id: read.c 215 2008-06-19 10:27:37Z baconevi $
|
||||
* $Id: read.c 337 2008-08-20 09:17:25Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
|
||||
#include "lsp_i.h"
|
||||
#include "lsp.h"
|
||||
|
||||
#define IS_IDENT(c) \
|
||||
((c) == ASE_T('+') || (c) == ASE_T('-') || \
|
||||
|
Reference in New Issue
Block a user