]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/acid/acid.h
merge
[plan9front.git] / sys / src / cmd / acid / acid.h
1 /* acid.h */
2 enum
3 {
4         Eof             = -1,
5         Strsize         = 4096,
6         Hashsize        = 128,
7         Maxarg          = 512,
8         NFD             = 100,
9         Maxproc         = 50,
10         Maxval          = 10,
11         Mempergc        = 1024*1024,
12 };
13
14 #pragma varargck type "L"       void
15
16 typedef struct Node     Node;
17 typedef struct String   String;
18 typedef struct Lsym     Lsym;
19 typedef struct List     List;
20 typedef struct Store    Store;
21 typedef struct Gc       Gc;
22 typedef struct Strc     Strc;
23 typedef struct Rplace   Rplace;
24 typedef struct Ptab     Ptab;
25 typedef struct Value    Value;
26 typedef struct Type     Type;
27 typedef struct Frtype   Frtype;
28
29 Extern int      kernel;
30 Extern int      text;
31 Extern int      silent;
32 Extern Fhdr     fhdr;
33 Extern int      line;
34 Extern Biobuf*  bout;
35 Extern Biobuf*  io[32];
36 Extern int      iop;
37 Extern char     symbol[Strsize];
38 Extern int      interactive;
39 Extern int      na;
40 Extern int      wtflag;
41 Extern Map*     cormap;
42 Extern Map*     symmap;
43 Extern Lsym*    hash[Hashsize];
44 Extern long     dogc;
45 Extern Rplace*  ret;
46 Extern char*    aout;
47 Extern int      gotint;
48 Extern Gc*      gcl;
49 Extern int      stacked;
50 Extern jmp_buf  err;
51 Extern Node*    prnt;
52 Extern List*    tracelist;
53 Extern int      initialising;
54 Extern int      quiet;
55
56 extern void     (*expop[])(Node*, Node*);
57 #define expr(n, r) (r)->comt=0; (*expop[(n)->op])(n, r);
58 extern int      fmtsize(Value *v) ;
59
60 enum
61 {
62         TINT,
63         TFLOAT,
64         TSTRING,
65         TLIST,
66         TCODE,
67 };
68
69 struct Type
70 {
71         Type*   next;
72         int     offset;
73         char    fmt;
74         char    depth;
75         Lsym*   type;
76         Lsym*   tag;
77         Lsym*   base;
78 };
79
80 struct Frtype
81 {
82         Lsym*   var;
83         Type*   type;
84         Frtype* next;
85 };
86
87 struct Ptab
88 {
89         int     pid;
90         int     ctl;
91 };
92 Extern Ptab     ptab[Maxproc];
93
94 struct Rplace
95 {
96         jmp_buf rlab;
97         Node*   stak;
98         Node*   val;
99         Lsym*   local;
100         Lsym**  tail;
101 };
102
103 struct Gc
104 {
105         char    gcmark;
106         Gc*     gclink;
107 };
108
109 struct Store
110 {
111         char    fmt;
112         Type*   comt;
113         union {
114                 vlong   ival;
115                 double  fval;
116                 String* string;
117                 List*   l;
118                 Node*   cc;
119         };
120 };
121
122 struct List
123 {
124         Gc;
125         List*   next;
126         char    type;
127         Store;
128 };
129
130 struct Value
131 {
132         char    set;
133         char    type;
134         Store;
135         Value*  pop;
136         Lsym*   scope;
137         Rplace* ret;
138 };
139
140 struct Lsym
141 {
142         char*   name;
143         int     lexval;
144         Lsym*   hash;
145         Value*  v;
146         Type*   lt;
147         Node*   proc;
148         Frtype* local;
149         void    (*builtin)(Node*, Node*);
150 };
151
152 struct Node
153 {
154         Gc;
155         char    op;
156         char    type;
157         Node*   left;
158         Node*   right;
159         Lsym*   sym;
160         int     builtin;
161         Store;
162 };
163 #define ZN      (Node*)0
164
165 struct String
166 {
167         Gc;
168         char    *string;
169         int     len;
170 };
171
172 List*   addlist(List*, List*);
173 List*   al(int);
174 Node*   an(int, Node*, Node*);
175 void    append(Node*, Node*, Node*);
176 int     bool(Node*);
177 void    build(Node*);
178 void    call(char*, Node*, Node*, Node*, Node*);
179 void    catcher(void*, char*);
180 void    checkqid(int, int);
181 void    cmd(void);
182 Node*   con(vlong);
183 List*   construct(Node*);
184 void    ctrace(int);
185 void    decl(Node*);
186 void    defcomplex(Node*, Node*);
187 void    deinstall(int);
188 void    delete(List*, int n, Node*);
189 void    dostop(int);
190 Lsym*   enter(char*, int);
191 void    error(char*, ...);
192 void    execute(Node*);
193 void    fatal(char*, ...);
194 void    flatten(Node**, Node*);
195 void    gc(void);
196 char*   getstatus(int);
197 void*   gmalloc(long);
198 void    indir(Map*, uvlong, char, Node*);
199 void    installbuiltin(void);
200 void    kinit(void);
201 int     Lfmt(Fmt*);
202 int     listcmp(List*, List*);
203 int     listlen(List*);
204 List*   listvar(char*, vlong);
205 void    loadmodule(char*);
206 void    loadvars(void);
207 Lsym*   look(char*);
208 void    ltag(char*);
209 void    marklist(List*);
210 Lsym*   mkvar(char*);
211 void    msg(int, char*);
212 void    notes(int);
213 int     nproc(char**);
214 void    nthelem(List*, int, Node*);
215 int     numsym(char);
216 void    odot(Node*, Node*);
217 void    pcode(Node*, int);
218 void    pexpr(Node*);
219 int     popio(void);
220 void    pstr(String*);
221 void    pushfile(char*);
222 void    pushstr(Node*);
223 void    readtext(char*);
224 void    restartio(void);
225 uvlong  rget(Map*, char*);
226 String  *runenode(Rune*);
227 int     scmp(String*, String*);
228 void    sproc(int);
229 String* stradd(String*, String*);
230 String* straddrune(String*, Rune);
231 String* strnode(char*);
232 String* strnodlen(char*, int);
233 char*   system(void);
234 void    trlist(Map*, uvlong, uvlong, Symbol*);
235 void    unwind(void);
236 void    userinit(void);
237 void    varreg(void);
238 void    varsym(void);
239 Waitmsg*        waitfor(int);
240 void    whatis(Lsym*);
241 void    windir(Map*, Node*, Node*, Node*);
242 void    yyerror(char*, ...);
243 int     yylex(void);
244 int     yyparse(void);
245
246 enum
247 {
248         ONAME,
249         OCONST,
250         OMUL,
251         ODIV,
252         OMOD,
253         OADD,
254         OSUB,
255         ORSH,
256         OLSH,
257         OLT,
258         OGT,
259         OLEQ,
260         OGEQ,
261         OEQ,
262         ONEQ,
263         OLAND,
264         OXOR,
265         OLOR,
266         OCAND,
267         OCOR,
268         OASGN,
269         OINDM,
270         OEDEC,
271         OEINC,
272         OPINC,
273         OPDEC,
274         ONOT,
275         OIF,
276         ODO,
277         OLIST,
278         OCALL,
279         OCTRUCT,
280         OWHILE,
281         OELSE,
282         OHEAD,
283         OTAIL,
284         OAPPEND,
285         ORET,
286         OINDEX,
287         OINDC,
288         ODOT,
289         OLOCAL,
290         OFRAME,
291         OCOMPLEX,
292         ODELETE,
293         OCAST,
294         OFMT,
295         OEVAL,
296         OWHAT,
297 };