/[cvs]/stack/stack.h
ViewVC logotype

Contents of /stack/stack.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sat Feb 16 00:51:32 2002 UTC (22 years, 2 months ago) by teddy
Branch: MAIN
File MIME type: text/plain
Separated into header file and C file.

1
2 #define HASHTBLSIZE 2048
3
4 /* First, define some types. */
5
6 /* A value of some type */
7 typedef struct {
8 enum {
9 integer,
10 string,
11 func, /* Function pointer */
12 symb,
13 list
14 } type; /* Type of stack element */
15
16 union {
17 void *ptr; /* Pointer to the content */
18 int val; /* ...or an integer */
19 } content; /* Stores a pointer or an integer */
20
21 int gc_garb;
22
23 } value;
24
25 /* A symbol with a name and possible value */
26 /* (These do not need reference counters, they are kept unique by
27 hashing.) */
28 typedef struct symbol_struct {
29 char *id; /* Symbol name */
30 value *val; /* The value (if any) bound to it */
31 struct symbol_struct *next; /* In case of hashing conflicts, a */
32 } symbol; /* symbol is a kind of stack item. */
33
34 /* A type for a hash table for symbols */
35 typedef symbol *hashtbl[HASHTBLSIZE]; /* Hash table declaration */
36
37 /* An item (value) on a stack */
38 typedef struct stackitem_struct
39 {
40 value *item; /* The value on the stack */
41 /* (This is never NULL) */
42 struct stackitem_struct *next; /* Next item */
43 } stackitem;
44
45 /* An environment; gives access to the stack and a hash table of
46 defined symbols */
47 typedef struct {
48 stackitem *gc_ref;
49 int gc_limit, gc_count;
50
51 stackitem *head; /* Head of the stack */
52 hashtbl symbols; /* Hash table of all variable bindings */
53 int err; /* Error flag */
54 char *in_string; /* Input pending to be read */
55 char *free_string; /* Free this string when all input is
56 read from in_string */
57 FILE *inputstream; /* stdin or a file, most likely */
58 int interactive; /* print prompts, stack, etc */
59 } environment;
60
61 /* A type for pointers to external functions */
62 typedef void (*funcp)(environment *); /* funcp is a pointer to a void
63 function (environment *) */
64
65 void init_env(environment *env);
66 void printerr(const char* in_string);
67 extern void toss(environment *env);
68 symbol **hash(hashtbl in_hashtbl, const char *in_string);
69 value* new_val(environment *env);
70 void gc_mark(value *val);
71 extern void gc_init(environment *env);
72 void push_val(environment *env, value *val);
73 void push_int(environment *env, int in_val);
74 void push_cstring(environment *env, const char *in_string);
75 char *mangle_str(const char *old_string);
76 extern void mangle(environment *env);
77 void push_sym(environment *env, const char *in_string);
78 extern void nl();
79 extern void type(environment *env);
80 void print_h(stackitem *stack_head, int noquote);
81 extern void print_(environment *env);
82 extern void print(environment *env);
83 extern void princ_(environment *env);
84 extern void princ(environment *env);
85 void print_st(stackitem *stack_head, long counter);
86 extern void printstack(environment *env);
87 extern void swap(environment *env);
88 extern void rot(environment *env);
89 extern void rcl(environment *env);
90 extern void eval(environment *env);
91 extern void rev(environment *env);
92 extern void pack(environment *env);
93 extern void expand(environment *env);
94 extern void eq(environment *env);
95 extern void not(environment *env);
96 extern void neq(environment *env);
97 extern void def(environment *env);
98 extern void quit(environment *env);
99 extern void clear(environment *env);
100 extern void words(environment *env);
101 void forget_sym(symbol **hash_entry);
102 extern void forget(environment *env);
103 extern void errn(environment *env);
104 extern void sx_2b(environment *env);
105 extern void sx_2d(environment *env);
106 extern void sx_3e(environment *env);
107 value *copy_val(environment *env, value *old_value);
108 extern void sx_647570(environment *env);
109 extern void sx_6966(environment *env);
110 extern void ifelse(environment *env);
111 extern void sx_7768696c65(environment *env);
112 extern void sx_666f72(environment *env);
113 extern void to(environment *env);
114 extern void readline(environment *env);
115 extern void sx_72656164(environment *env);

root@recompile.se
ViewVC Help
Powered by ViewVC 1.1.26