Section: Interp SDK (3)
Updated: 2007-07-17
interp - implements a simple, stack-based, integer, RPN interpreter
#include itypes.h
#include interp.h
typedef enum base_E base_T;
typedef struct Interp_S *Interp_T;
enum base_E { decimal, octal, hex };
typedef ibyte * FT[CMD_ENTRIES];
typedef FT *UFT;
struct Interp_S {
Stack_T sp; /* data stack */
Stack_T lcsp; /* loop control stack */
Stack_T frsp; /* function return stack */
base_T obase; /* current output number base */
UFT gfp; /* global function table pointer */
UFT lfp; /* local function table pointer */
iword *vp; /* global variable pool pointer */
iword *lp; /* local variable pool pointer */
iword *kp; /* system constants table pointer */
uword *vt; /* command vector table pointer, one cmd per token */
ibyte *ibuf; /* input message buffer pointer */
ibyte *ebuf; /* output message buffer pointer */
ibyte *bop; /* points to location where an error occurred */
iword err; /* the nature of the error (error code) */
};
Interp_T interp_new( void );
void interp_reset( Interp_T cp );
int interp( Interp_T cp, ibyte *str );
Simply put, this API allows you to instantiate an interpreter, reset its state after an error, and execute zero-terminated sequences of tokens.