--- stack/stack.h 2002/02/17 04:03:57 1.2 +++ stack/stack.h 2002/03/08 16:09:30 1.5 @@ -1,3 +1,24 @@ +/* + stack - an interactive interpreter for a stack-based language + Copyright (C) 2002 Mats Alritzson and Teddy Hogeborn + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Authors: Mats Alritzson + Teddy Hogeborn +*/ #define HASHTBLSIZE 2048 @@ -7,17 +28,19 @@ typedef struct { enum { integer, + tfloat, string, func, /* Function pointer */ symb, list - } type:3; /* Type of stack element */ + } type:4; /* Type of stack element */ int gc_garb:1; union { void *ptr; /* Pointer to the content */ - int val; /* ...or an integer */ + int i; /* ...or an integer */ + float f; } content; /* Stores a pointer or an integer */ } value; @@ -46,6 +69,7 @@ defined symbols */ typedef struct { stackitem *gc_ref; + stackitem *gc_protect; int gc_limit, gc_count; stackitem *head; /* Head of the stack */ @@ -53,7 +77,7 @@ int err; /* Error flag */ char *in_string; /* Input pending to be read */ char *free_string; /* Free this string when all input is - read from in_string */ + read from in_string */ FILE *inputstream; /* stdin or a file, most likely */ int interactive; /* print prompts, stack, etc */ } environment; @@ -71,6 +95,7 @@ extern void gc_init(environment*); void push_val(environment*, value*); void push_int(environment*, int); +void push_float(environment*, float); void push_cstring(environment*, const char*); char *mangle_str(const char*); extern void mangle(environment*); @@ -114,3 +139,13 @@ extern void readline(environment*); extern void sx_72656164(environment*); extern void foreach(environment*); +void protect(environment*, value*); +void unprotect(environment*); +extern void copying(environment*); +extern void warranty(environment*); +extern void sx_2a(environment*); +extern void sx_2f(environment*); +extern void mod(environment*); +extern void sx_3c(environment*); +extern void sx_3c3d(environment*); +extern void sx_3e3d(environment*);