*** empty log message ***
This commit is contained in:
parent
25b5391b55
commit
2b2520afaf
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: init.c,v 1.1 2005-09-18 10:18:35 bacon Exp $
|
||||
* $Id: init.c,v 1.2 2005-09-18 12:20:43 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/lsp/lsp.h>
|
||||
@ -76,7 +76,7 @@ int xp_lsp_attach_input (xp_lsp_t* lsp, xp_lsp_io_t input)
|
||||
|
||||
xp_assert (lsp->input_func == XP_NULL);
|
||||
|
||||
if (input(XP_LSP_IO_OPEN, lsp, XP_NULL) == -1) {
|
||||
if (input(lsp, XP_LSP_IO_OPEN, XP_NULL) == -1) {
|
||||
/* TODO: set error number */
|
||||
return -1;
|
||||
}
|
||||
@ -87,7 +87,7 @@ int xp_lsp_attach_input (xp_lsp_t* lsp, xp_lsp_io_t input)
|
||||
int xp_lsp_detach_input (xp_lsp_t* lsp)
|
||||
{
|
||||
if (lsp->input_func != XP_NULL) {
|
||||
if (lsp->input_func(XP_LSP_IO_CLOSE, lsp, XP_NULL) == -1) {
|
||||
if (lsp->input_func(lsp, XP_LSP_IO_CLOSE, XP_NULL) == -1) {
|
||||
/* TODO: set error number */
|
||||
return -1;
|
||||
}
|
||||
@ -103,7 +103,7 @@ int xp_lsp_attach_output (xp_lsp_t* lsp, xp_lsp_io_t output)
|
||||
|
||||
xp_assert (lsp->output_func == XP_NULL);
|
||||
|
||||
if (output(XP_LSP_IO_OPEN, lsp, XP_NULL) == -1) {
|
||||
if (output(lsp, XP_LSP_IO_OPEN, XP_NULL) == -1) {
|
||||
/* TODO: set error number */
|
||||
return -1;
|
||||
}
|
||||
@ -114,7 +114,7 @@ int xp_lsp_attach_output (xp_lsp_t* lsp, xp_lsp_io_t output)
|
||||
int xp_lsp_detach_output (xp_lsp_t* lsp)
|
||||
{
|
||||
if (lsp->output_func != XP_NULL) {
|
||||
if (lsp->output_func(XP_LSP_IO_CLOSE, lsp, XP_NULL) == -1) {
|
||||
if (lsp->output_func(lsp, XP_LSP_IO_CLOSE, XP_NULL) == -1) {
|
||||
/* TODO: set error number */
|
||||
return -1;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: lsp.h,v 1.8 2005-09-18 11:54:23 bacon Exp $
|
||||
* $Id: lsp.h,v 1.9 2005-09-18 12:20:43 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_LSP_LSP_H_
|
||||
@ -42,7 +42,13 @@ enum
|
||||
XP_LSP_ERR_BAD_VALUE
|
||||
};
|
||||
|
||||
typedef int (*xp_lsp_io_t) (int cmd, void* owner, void* arg);
|
||||
/*
|
||||
* TYPEDEF: xp_lsp_t
|
||||
* Defines a lisp processor
|
||||
*/
|
||||
typedef struct xp_lsp_t xp_lsp_t;
|
||||
|
||||
typedef int (*xp_lsp_io_t) (xp_lsp_t* lsp, int cmd, void* arg);
|
||||
enum
|
||||
{
|
||||
XP_LSP_IO_OPEN,
|
||||
@ -74,12 +80,6 @@ struct xp_lsp_t
|
||||
xp_bool_t __malloced;
|
||||
};
|
||||
|
||||
/*
|
||||
* TYPEDEF: xp_lsp_t
|
||||
* Defines a lisp processor
|
||||
*/
|
||||
typedef struct xp_lsp_t xp_lsp_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: print.c,v 1.6 2005-09-18 10:18:35 bacon Exp $
|
||||
* $Id: print.c,v 1.7 2005-09-18 12:20:43 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/lsp/lsp.h>
|
||||
@ -60,7 +60,7 @@ void xp_lsp_print_debug (xp_lsp_obj_t* obj)
|
||||
|
||||
#define OUTPUT_STR(lsp,str) \
|
||||
do { \
|
||||
if (lsp->output_func(XP_LSP_IO_STR, (void*)lsp, (void*)str) == -1) { \
|
||||
if (lsp->output_func(lsp, XP_LSP_IO_STR, (void*)str) == -1) { \
|
||||
lsp->errnum = XP_LSP_ERR_OUTPUT; \
|
||||
return -1; \
|
||||
} \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: read.c,v 1.11 2005-09-18 10:18:35 bacon Exp $
|
||||
* $Id: read.c,v 1.12 2005-09-18 12:20:43 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/lsp/lsp.h>
|
||||
@ -47,30 +47,13 @@
|
||||
#define TOKEN_INVALID 50
|
||||
#define TOKEN_UNTERM_STRING 51
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static xp_lsp_obj_t* read_obj (xp_lsp_t* lsp);
|
||||
static xp_lsp_obj_t* read_list (xp_lsp_t* lsp);
|
||||
static xp_lsp_obj_t* read_quote (xp_lsp_t* lsp);
|
||||
|
||||
static int read_token (xp_lsp_t* lsp);
|
||||
static int read_number (xp_lsp_t* lsp, int negative);
|
||||
static int read_ident (xp_lsp_t* lsp);
|
||||
static int read_string (xp_lsp_t* lsp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define NEXT_CHAR(lsp) \
|
||||
do { \
|
||||
if (lsp->input_func == XP_NULL) { \
|
||||
lsp->errnum = XP_LSP_ERR_INPUT_NOT_ATTACHED; \
|
||||
return -1; \
|
||||
} \
|
||||
else if (lsp->input_func(XP_LSP_IO_CHAR, lsp, XP_NULL) == -1) { \
|
||||
else if (lsp->input_func(lsp, XP_LSP_IO_CHAR, XP_NULL) == -1) { \
|
||||
lsp->errnum = XP_LSP_ERR_INPUT; \
|
||||
return -1; \
|
||||
} \
|
||||
@ -81,6 +64,15 @@ static int read_string (xp_lsp_t* lsp);
|
||||
if (read_token(lsp) == -1) return XP_NULL; \
|
||||
} while (0)
|
||||
|
||||
static xp_lsp_obj_t* read_obj (xp_lsp_t* lsp);
|
||||
static xp_lsp_obj_t* read_list (xp_lsp_t* lsp);
|
||||
static xp_lsp_obj_t* read_quote (xp_lsp_t* lsp);
|
||||
|
||||
static int read_token (xp_lsp_t* lsp);
|
||||
static int read_number (xp_lsp_t* lsp, int negative);
|
||||
static int read_ident (xp_lsp_t* lsp);
|
||||
static int read_string (xp_lsp_t* lsp);
|
||||
|
||||
xp_lsp_obj_t* xp_lsp_read (xp_lsp_t* lsp)
|
||||
{
|
||||
/*NEXT_CHAR (lsp);*/
|
||||
@ -88,7 +80,7 @@ xp_lsp_obj_t* xp_lsp_read (xp_lsp_t* lsp)
|
||||
lsp->errnum = XP_LSP_ERR_INPUT_NOT_ATTACHED;
|
||||
return XP_NULL;
|
||||
}
|
||||
else if (lsp->input_func(XP_LSP_IO_CHAR, lsp, XP_NULL) == -1) {
|
||||
else if (lsp->input_func(lsp, XP_LSP_IO_CHAR, XP_NULL) == -1) {
|
||||
lsp->errnum = XP_LSP_ERR_INPUT;
|
||||
return XP_NULL;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <mcheck.h>
|
||||
#endif
|
||||
|
||||
static int get_char (int cmd, void* owner, void* arg)
|
||||
static int get_char (xp_lsp_t* lsp, int cmd, void* arg)
|
||||
{
|
||||
xp_cint_t c;
|
||||
|
||||
@ -32,7 +32,7 @@ static int get_char (int cmd, void* owner, void* arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int put_char (int cmd, void* owner, void* arg)
|
||||
static int put_char (xp_lsp_t* lsp, int cmd, void* arg)
|
||||
{
|
||||
|
||||
switch (cmd) {
|
||||
|
Loading…
Reference in New Issue
Block a user