-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.h
127 lines (114 loc) · 2.58 KB
/
globals.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
module : globals.h
version : 1.1.1.1
date : 09/13/23
*/
/* FILE : globals.h */
#define SHELLESCAPE '$'
#define INPSTACKMAX 10
#define INPLINEMAX 80
#define ALEN 20
#define HASHSIZE 9
#define SYMTABMAX 2000
#define MEMORYMAX 100000
#define INIECHOFLAG 0
#define INIAUTOPUT 1
#define INITRACEGC 1
/* installation dependent */
#define SETSIZE 32
#define MAXINT 2147483647
/* symbols from getsym */
#define ILLEGAL_ 0
#define COPIED_ 1
#define USR_ 2
#define ANON_FUNCT_ 3
#define BOOLEAN_ 4
#define CHAR_ 5
#define INTEGER_ 6
#define SET_ 7
#define STRING_ 8
#define LIST_ 9
#define LBRACK 900
#define LBRACE 901
#define LPAREN 902
#define ATOM 999 /* last legal factor begin */
#define RBRACK 1001
#define RPAREN 1003
#define RBRACE 1005
#define PERIOD 1006
#define SEMICOL 1007
#define LIBRA 1100
#define EQDEF 1101
#define HIDE 1102
#define IN 1103
#define END 1104
#ifdef DEBUG
# define D(x) x
#else
# define D(x)
#endif
#define PRIVATE static
#define PUBLIC
/* types */
typedef int Symbol;
typedef short Operator;
typedef struct Node
{ Operator op;
union
{ long num;
long set;
char *str;
struct Node *lis;
struct Entry *ent;
void (*proc)(); } u;
struct Node *next; } Node;
typedef struct Entry
{ char *name;
union
{ Node *body;
void (*proc) (); } u;
struct Entry *next; } Entry;
#ifdef ALLOC
# define CLASS
#else
# define CLASS extern
#endif
CLASS int echoflag;
CLASS int autoput;
CLASS int tracegc;
CLASS int startclock,gc_clock; /* main */
CLASS char ch; /* scanner */
CLASS Symbol sym;
CLASS long num;
CLASS char id[ALEN];
CLASS int hashvalue;
CLASS Entry /* symbol table */
symtab[SYMTABMAX],
*hashentry[HASHSIZE],
*localentry,
*symtabindex,
*firstlibra, /* inioptable */
*location; /* getsym */
#define LOC2INT(e) (((long)e - (long)symtab) / sizeof(Entry))
#define INT2LOC(x) ((Entry*) ((x + (long)symtab)) * sizeof(Entry))
CLASS Node /* dynamic memory */
/*
memory[MEMORYMAX],
*memoryindex,
*/
*prog, *stk, *conts,
*dump, *dump1, *dump2, *dump3, *dump4, *dump5;
#define MEM2INT(n) (((long)n - (long)memory) / (long)sizeof(Node))
#define INT2MEM(x) ((Node *) ((x + (long)&memory) * (long)sizeof(Node)))
/* GOOD REFS:
005.133l H4732 A LISP interpreter in C
Manna p139 recursive Ackermann SCHEMA
OTHER DATA TYPES
WORD = "ABCD" - up to four chars
LIST of SETs of char [S0 S1 S2 S3]
LISTS - binary tree [left right]
" with info [info left right]
STRING of 32 chars = 32 * 8 bits = 256 bits = bigset
CHAR = 2 HEX
32 SET = 2 * 16SET
*/