G:/ScriptBasic/source/lsp.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "lsp.h"

Go to the source code of this file.

Defines

#define ALLOC(X)   (pLSP->memory_allocating_function((X),pLSP->pMemorySegment))
#define FREE(X)   (pLSP->memory_releasing_function((X),pLSP->pMemorySegment))
#define BUFFER   (pLSP->buffer)
#define TABPOS   (pLSP->tabpos)
#define SCRSIZE   (pLSP->scrsize)
#define getnode()   (LVAL)malloc(sizeof(struct NODE))
#define SRC_WIDTH   80
#define WSPACE   "\t \f\r\n"
#define CONST1   "!$%&*-+./0123456789:<=>?@[]^_{}~"
#define CONST2   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
#define NUMSET   "0123456789"
#define NUMSET1   "0123456789-+"
#define numeral1(x)   (isinset((x),NUMSET1))
#define space_p(x)   isinset((x),WSPACE)
#define const_p(x)   (isinset((x),CONST1)||isinset((x),CONST2))
#define const_p1(x)   ((const_p(x))&&(!numeral1(x)))
#define numeral(x)   (isinset((x),NUMSET))
#define spaceat(x, f)   while(space_p(((x)=getC(pLSP,(f)))))
#define StrDup(x)   c_StrDup(pLSP,(x))
#define GETC(x)   __GETC((int (*)(void *))getc,(x),pLSP->UngetBuffer,&(pLSP->UngetCounter))
#define UNGETC(x)   __UNGETC(pLSP->UngetBuffer,&(pLSP->UngetCounter),x)
#define SYMBOLLENGTH   (pLSP->SymbolLength)
#define CASEFLAG   (pLSP->CaseFlag)
#define _pprint(x)   __pprint(pLSP,(x),1)

Functions

static isinset (int ch, char *string)
static char * c_StrDup (tpLspObject pLSP, char *s)
static double pow10 (double a)
static void cnumeric (char *string, int *whatis, double *dres, long *lres)
static int __GETC (int(*pfGetCharacter)(void *), void *pvInput, int *UngetBuffer, int *UngetCounter)
static void __UNGETC (int *UngetBuffer, int *UngetCounter, int ch)
static int getC (tpLspObject pLSP, FILE *f)
static void * _mya (size_t x, void *y)
static void _myf (void *x, void *y)
LVAL lsp_init (tpLspObject pLSP, int SymLen, int CaseFlg, void *(*memory_allocating_function)(size_t, void *), void(*memory_releasing_function)(void *, void *), void *pMemorySegment)
LVAL c_cons (tpLspObject pLSP)
LVAL c_newnode (tpLspObject pLSP, unsigned char type)
LVAL c_symcmp (tpLspObject pLSP, LVAL p, char *s)
LVAL c_nthsassoc (tpLspObject pLSP, LVAL p, char *s, int n)
LVAL c_freelist (tpLspObject pLSP, LVAL p)
int c_flatc (tpLspObject pLSP, LVAL p)
static LVAL __pprint (tpLspObject pLSP, LVAL p, int k)
LVAL c_pprint (tpLspObject pLSP, LVAL p, FILE *file)
static LVAL readcons (tpLspObject pLSP, FILE *f)
static int storech (tpLspObject pLSP, int i, int ch)
static LVAL _readexpr (tpLspObject pLSP, FILE *f)
LVAL c_readlist (tpLspObject pLSP, FILE *f)
LVAL c_readexpr (tpLspObject pLSP, FILE *f)
LVAL c_skipexpr (tpLspObject pLSP, FILE *f)
int c_llength (tpLspObject pLSP, LVAL p)
LVAL c_nth (tpLspObject pLSP, int n, LVAL p)
LVAL c_nthcdr (tpLspObject pLSP, int n, LVAL p)
LVAL c_char_code (tpLspObject pLSP, LVAL p)
LVAL c_code_char (tpLspObject pLSP, LVAL p)
LVAL c_char_downcase (tpLspObject pLSP, LVAL p)
LVAL c_char_upcase (tpLspObject pLSP, LVAL p)
int c_equal (tpLspObject pLSP, LVAL p, LVAL q)
LVAL c_car (tpLspObject pLSP, LVAL x)
LVAL c_cdr (tpLspObject pLSP, LVAL x)
int c_consp (tpLspObject pLSP, LVAL x)
int c_floatp (tpLspObject pLSP, LVAL x)
int c_integerp (tpLspObject pLSP, LVAL x)
int c_stringp (tpLspObject pLSP, LVAL x)
int c_symbolp (tpLspObject pLSP, LVAL x)
int c_characterp (tpLspObject pLSP, LVAL x)
int c_atom (tpLspObject pLSP, LVAL x)

Variables

static char escapers [] = "t\tn\nr\r"


Define Documentation

#define _pprint  )     __pprint(pLSP,(x),1)
 

Referenced by c_pprint().

#define ALLOC  )     (pLSP->memory_allocating_function((X),pLSP->pMemorySegment))
 

Definition at line 163 of file lsp.c.

#define BUFFER   (pLSP->buffer)
 

Definition at line 165 of file lsp.c.

Referenced by _readexpr(), and c_flatc().

#define CASEFLAG   (pLSP->CaseFlag)
 

Definition at line 316 of file lsp.c.

Referenced by c_symcmp(), and lsp_init().

#define CONST1   "!$%&*-+./0123456789:<=>?@[]^_{}~"
 

Definition at line 183 of file lsp.c.

#define CONST2   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
 

Definition at line 184 of file lsp.c.

#define const_p  )     (isinset((x),CONST1)||isinset((x),CONST2))
 

Definition at line 189 of file lsp.c.

Referenced by _readexpr().

#define const_p1  )     ((const_p(x))&&(!numeral1(x)))
 

Definition at line 190 of file lsp.c.

Referenced by _readexpr().

#define FREE  )     (pLSP->memory_releasing_function((X),pLSP->pMemorySegment))
 

Definition at line 164 of file lsp.c.

#define GETC  )     __GETC((int (*)(void *))getc,(x),pLSP->UngetBuffer,&(pLSP->UngetCounter))
 

Definition at line 295 of file lsp.c.

 
#define getnode  )     (LVAL)malloc(sizeof(struct NODE))
 

Definition at line 180 of file lsp.c.

Referenced by c_cons(), and c_newnode().

#define numeral  )     (isinset((x),NUMSET))
 

Definition at line 191 of file lsp.c.

Referenced by cnumeric().

#define numeral1  )     (isinset((x),NUMSET1))
 

Definition at line 187 of file lsp.c.

#define NUMSET   "0123456789"
 

Definition at line 185 of file lsp.c.

#define NUMSET1   "0123456789-+"
 

Definition at line 186 of file lsp.c.

#define SCRSIZE   (pLSP->scrsize)
 

Definition at line 167 of file lsp.c.

Referenced by __pprint(), and c_pprint().

#define space_p  )     isinset((x),WSPACE)
 

Definition at line 188 of file lsp.c.

#define spaceat x,
 )     while(space_p(((x)=getC(pLSP,(f)))))
 

Definition at line 192 of file lsp.c.

Referenced by _readexpr(), c_readexpr(), c_readlist(), and readcons().

#define SRC_WIDTH   80
 

Definition at line 181 of file lsp.c.

#define StrDup  )     c_StrDup(pLSP,(x))
 

Definition at line 197 of file lsp.c.

Referenced by _readexpr().

#define SYMBOLLENGTH   (pLSP->SymbolLength)
 

Definition at line 315 of file lsp.c.

Referenced by c_symcmp(), and lsp_init().

#define TABPOS   (pLSP->tabpos)
 

Definition at line 166 of file lsp.c.

Referenced by __pprint(), and c_pprint().

#define UNGETC  )     __UNGETC(pLSP->UngetBuffer,&(pLSP->UngetCounter),x)
 

Definition at line 296 of file lsp.c.

#define WSPACE   "\t \f\r\n"
 

Definition at line 182 of file lsp.c.


Function Documentation

static int __GETC int(*)(void *)  pfGetCharacter,
void *  pvInput,
int *  UngetBuffer,
int *  UngetCounter
[static]
 

Definition at line 276 of file lsp.c.

static LVAL __pprint tpLspObject  pLSP,
LVAL  p,
int  k
[static]
 

Definition at line 581 of file lsp.c.

References fp, j, s, SCRSIZE, and TABPOS.

static void __UNGETC int *  UngetBuffer,
int *  UngetCounter,
int  ch
[static]
 

Definition at line 288 of file lsp.c.

static void* _mya size_t  x,
void *  y
[static]
 

Definition at line 318 of file lsp.c.

static void _myf void *  x,
void *  y
[static]
 

Definition at line 321 of file lsp.c.

References free().

static LVAL _readexpr tpLspObject  pLSP,
FILE *  f
[static]
 

Definition at line 785 of file lsp.c.

References BUFFER, ch, const_p, const_p1, getC(), i, NULL, readcons(), spaceat, storech(), StrDup, and UNGETC.

Referenced by c_readexpr(), and c_readlist().

int c_atom tpLspObject  pLSP,
LVAL  x
 

Definition at line 1347 of file lsp.c.

LVAL c_car tpLspObject  pLSP,
LVAL  x
 

Definition at line 1203 of file lsp.c.

LVAL c_cdr tpLspObject  pLSP,
LVAL  x
 

Definition at line 1221 of file lsp.c.

LVAL c_char_code tpLspObject  pLSP,
LVAL  p
 

Definition at line 1077 of file lsp.c.

References q.

LVAL c_char_downcase tpLspObject  pLSP,
LVAL  p
 

Definition at line 1119 of file lsp.c.

References q.

LVAL c_char_upcase tpLspObject  pLSP,
LVAL  p
 

Definition at line 1141 of file lsp.c.

References q.

int c_characterp tpLspObject  pLSP,
LVAL  x
 

Definition at line 1329 of file lsp.c.

LVAL c_code_char tpLspObject  pLSP,
LVAL  p
 

Definition at line 1098 of file lsp.c.

References q.

LVAL c_cons tpLspObject  pLSP  ) 
 

Definition at line 361 of file lsp.c.

References getnode, and p.

int c_consp tpLspObject  pLSP,
LVAL  x
 

Definition at line 1239 of file lsp.c.

int c_equal tpLspObject  pLSP,
LVAL  p,
LVAL  q
 

Definition at line 1165 of file lsp.c.

int c_flatc tpLspObject  pLSP,
LVAL  p
 

Definition at line 529 of file lsp.c.

References BUFFER, fp, j, and sprintf().

int c_floatp tpLspObject  pLSP,
LVAL  x
 

Definition at line 1257 of file lsp.c.

LVAL c_freelist tpLspObject  pLSP,
LVAL  p
 

Definition at line 500 of file lsp.c.

References FREE.

int c_integerp tpLspObject  pLSP,
LVAL  x
 

Definition at line 1275 of file lsp.c.

int c_llength tpLspObject  pLSP,
LVAL  p
 

Definition at line 1015 of file lsp.c.

LVAL c_newnode tpLspObject  pLSP,
unsigned char  type
 

Definition at line 388 of file lsp.c.

References getnode, NULL, and p.

LVAL c_nth tpLspObject  pLSP,
int  n,
LVAL  p
 

Definition at line 1035 of file lsp.c.

References q.

LVAL c_nthcdr tpLspObject  pLSP,
int  n,
LVAL  p
 

Definition at line 1056 of file lsp.c.

References q.

LVAL c_nthsassoc tpLspObject  pLSP,
LVAL  p,
char *  s,
int  n
 

Definition at line 473 of file lsp.c.

References fp.

LVAL c_pprint tpLspObject  pLSP,
LVAL  p,
FILE *  file
 

Definition at line 733 of file lsp.c.

References _pprint, SCRSIZE, and TABPOS.

LVAL c_readexpr tpLspObject  pLSP,
FILE *  f
 

Definition at line 974 of file lsp.c.

References _readexpr(), ch, spaceat, and UNGETC.

LVAL c_readlist tpLspObject  pLSP,
FILE *  f
 

Definition at line 943 of file lsp.c.

References _readexpr(), ch, q, spaceat, and UNGETC.

LVAL c_skipexpr tpLspObject  pLSP,
FILE *  f
 

Definition at line 995 of file lsp.c.

static char* c_StrDup tpLspObject  pLSP,
char *  s
[static]
 

Definition at line 198 of file lsp.c.

References ALLOC, NULL, p, and strcpy().

int c_stringp tpLspObject  pLSP,
LVAL  x
 

Definition at line 1293 of file lsp.c.

int c_symbolp tpLspObject  pLSP,
LVAL  x
 

Definition at line 1311 of file lsp.c.

LVAL c_symcmp tpLspObject  pLSP,
LVAL  p,
char *  s
 

Definition at line 439 of file lsp.c.

References CASEFLAG, i, SYMBOLLENGTH, and w.

static void cnumeric char *  string,
int *  whatis,
double *  dres,
long *  lres
[static]
 

Definition at line 234 of file lsp.c.

References i, and numeral.

static int getC tpLspObject  pLSP,
FILE *  f
[static]
 

Definition at line 305 of file lsp.c.

References ch, and GETC.

Referenced by _readexpr().

static isinset int  ch,
char *  string
[static]
 

Definition at line 171 of file lsp.c.

LVAL lsp_init tpLspObject  pLSP,
int  SymLen,
int  CaseFlg,
void *(*)(size_t, void *)  memory_allocating_function,
void(*)(void *, void *)  memory_releasing_function,
void *  pMemorySegment
 

Definition at line 329 of file lsp.c.

References _mya(), _myf(), CASEFLAG, NULL, and SYMBOLLENGTH.

Referenced by cft_ReadTextConfig().

static double pow10 double  a  )  [static]
 

Definition at line 209 of file lsp.c.

References i, and j.

static LVAL readcons tpLspObject  pLSP,
FILE *  f
[static]
 

Definition at line 752 of file lsp.c.

References ch, spaceat, and UNGETC.

Referenced by _readexpr().

static int storech tpLspObject  pLSP,
int  i,
int  ch
[static]
 

Definition at line 765 of file lsp.c.

References ALLOC, FREE, memcpy(), and NULL.

Referenced by _readexpr().


Variable Documentation

char escapers[] = "t\tn\nr\r" [static]
 

Definition at line 161 of file lsp.c.


Generated on Sun Mar 12 23:56:37 2006 for ScriptBasic by  doxygen 1.4.6-NO