fix decl_type
[m6w6/ext-psi] / src / parser.h
1 #ifndef _PSI_PARSER_H
2 #define _PSI_PARSER_H
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <stdarg.h>
7 #include <string.h>
8
9 #include <Zend/zend_types.h>
10
11 #include "parser_proc.h"
12
13 #define BSIZE 256
14
15 typedef int token_t;
16
17 typedef struct PSI_Token {
18 token_t type;
19 unsigned line;
20 size_t size;
21 char text[1];
22 } PSI_Token;
23
24 typedef struct decl_type {
25 char *name;
26 token_t type;
27 struct decl_type *real;
28 struct decl_struct *strct;
29 } decl_type;
30
31 static inline decl_type *init_decl_type(token_t type, char *name) {
32 decl_type *t = calloc(1, sizeof(*t));
33 t->type = type;
34 t->name = strdup(name);
35 return t;
36 }
37
38 static inline decl_type *real_decl_type(decl_type *type) {
39 while (type->real) {
40 type = type->real;
41 }
42 return type;
43 }
44
45 static inline void free_decl_type(decl_type *type) {
46 free(type->name);
47 free(type);
48 }
49
50 typedef struct decl_typedef {
51 char *alias;
52 decl_type *type;
53 } decl_typedef;
54
55 static inline decl_typedef *init_decl_typedef(char *name, decl_type *type) {
56 decl_typedef *t = malloc(sizeof(*t));
57 t->alias = strdup(name);
58 t->type = type;
59 return t;
60 }
61
62 static inline void free_decl_typedef(decl_typedef *t) {
63 free(t->alias);
64 free_decl_type(t->type);
65 free(t);
66 }
67
68 typedef struct decl_typedefs {
69 size_t count;
70 decl_typedef **list;
71 } decl_typedefs;
72
73 static inline decl_typedefs *add_decl_typedef(decl_typedefs *defs, decl_typedef *def) {
74 if (!defs) {
75 defs = calloc(1, sizeof(*defs));
76 }
77 defs->list = realloc(defs->list, ++defs->count * sizeof(*defs->list));
78 defs->list[defs->count-1] = def;
79 return defs;
80 }
81
82 static void free_decl_typedefs(decl_typedefs *defs) {
83 size_t i;
84
85 for (i = 0; i < defs->count; ++i) {
86 free_decl_typedef(defs->list[i]);
87 }
88 free(defs->list);
89 free(defs);
90 }
91
92 typedef struct decl_var {
93 char *name;
94 unsigned pointer_level;
95 unsigned array_size;
96 struct decl_arg *arg;
97 } decl_var;
98
99 static inline decl_var *init_decl_var(char *name, unsigned pl, unsigned as) {
100 decl_var *v = malloc(sizeof(*v));
101 v->name = (char *) strdup((const char *) name);
102 v->pointer_level = pl;
103 v->array_size = as;
104 return v;
105 }
106
107 static inline void free_decl_var(decl_var *var) {
108 free(var->name);
109 free(var);
110 }
111
112 typedef struct decl_arg {
113 decl_type *type;
114 decl_var *var;
115 struct let_stmt *let;
116 } decl_arg;
117
118 static inline decl_arg *init_decl_arg(decl_type *type, decl_var *var) {
119 decl_arg *arg = malloc(sizeof(*arg));
120 arg->type = type;
121 arg->var = var;
122 arg->let = NULL;
123 return arg;
124 }
125
126 static inline void free_decl_arg(decl_arg *arg) {
127 free_decl_type(arg->type);
128 free_decl_var(arg->var);
129 free(arg);
130 }
131
132 typedef struct decl_vars {
133 decl_var **vars;
134 size_t count;
135 } decl_vars;
136
137 static inline decl_vars *init_decl_vars(decl_var *var) {
138 decl_vars *vars = malloc(sizeof(*vars));
139 vars->count = 1;
140 vars->vars = malloc(sizeof(*vars->vars));
141 vars->vars[0] = var;
142 return vars;
143 }
144
145 static inline decl_vars *add_decl_var(decl_vars *vars, decl_var *var) {
146 vars->vars = realloc(vars->vars, ++vars->count * sizeof(*vars->vars));
147 vars->vars[vars->count-1] = var;
148 return vars;
149 }
150
151 static inline void free_decl_vars(decl_vars *vars) {
152 size_t i;
153
154 for (i = 0; i < vars->count; ++i) {
155 free_decl_var(vars->vars[i]);
156 }
157 free(vars->vars);
158 free(vars);
159 }
160
161 typedef struct decl_args {
162 decl_arg **args;
163 size_t count;
164 } decl_args;
165
166 static inline decl_args *init_decl_args(decl_arg *arg) {
167 decl_args *args = malloc(sizeof(*args));
168 args->count = 1;
169 args->args = malloc(sizeof(*args->args));
170 args->args[0] = arg;
171 return args;
172 }
173
174 static inline decl_args *add_decl_arg(decl_args *args, decl_arg *arg) {
175 args->args = realloc(args->args, ++args->count * sizeof(*args->args));
176 args->args[args->count-1] = arg;
177 return args;
178 }
179
180 static inline void free_decl_args(decl_args *args) {
181 size_t i;
182
183 for (i = 0; i < args->count; ++i) {
184 free_decl_arg(args->args[i]);
185 }
186 free(args->args);
187 free(args);
188 }
189
190 typedef struct decl_abi {
191 char *convention;
192 } decl_abi;
193
194 static inline decl_abi *init_decl_abi(char *convention) {
195 decl_abi *abi = malloc(sizeof(*abi));
196 abi->convention = strdup(convention);
197 return abi;
198 }
199
200 static inline void free_decl_abi(decl_abi *abi) {
201 free(abi->convention);
202 free(abi);
203 }
204
205 typedef struct decl {
206 decl_abi *abi;
207 decl_arg *func;
208 decl_args *args;
209 void *dlptr;
210 } decl;
211
212 static inline decl* init_decl(decl_abi *abi, decl_arg *func, decl_args *args) {
213 decl *d = malloc(sizeof(*d));
214 d->abi = abi;
215 d->func = func;
216 d->args = args;
217 return d;
218 }
219
220 static inline void free_decl(decl *d) {
221 free_decl_abi(d->abi);
222 free_decl_arg(d->func);
223 if (d->args) {
224 free_decl_args(d->args);
225 }
226 free(d);
227 }
228
229 typedef struct decls {
230 size_t count;
231 decl **list;
232 } decls;
233
234 static inline decls *add_decl(decls *decls, decl *decl) {
235 if (!decls) {
236 decls = calloc(1, sizeof(*decls));
237 }
238 decls->list = realloc(decls->list, ++decls->count * sizeof(*decls->list));
239 decls->list[decls->count-1] = decl;
240 return decls;
241 }
242
243 static inline void free_decls(decls *decls) {
244 size_t i;
245
246 for (i = 0; i < decls->count; ++i) {
247 free_decl(decls->list[i]);
248 }
249 free(decls->list);
250 free(decls);
251 }
252
253 typedef struct decl_struct_layout {
254 size_t pos;
255 size_t len;
256 } decl_struct_layout;
257
258 typedef struct decl_struct {
259 char *name;
260 decl_args *args;
261 decl_struct_layout *layout;
262 } decl_struct;
263
264 static inline decl_struct *init_decl_struct(char *name, decl_args *args) {
265 decl_struct *s = calloc(1, sizeof(*s));
266 s->name = strdup(name);
267 s->args = args;
268 return s;
269 }
270
271 static inline void free_decl_struct(decl_struct *s) {
272 if (s->args) {
273 free_decl_args(s->args);
274 }
275 free(s->name);
276 free(s);
277 }
278
279 typedef struct decl_structs {
280 size_t count;
281 decl_struct **list;
282 } decl_structs;
283
284 static inline decl_structs *add_decl_struct(decl_structs *ss, decl_struct *s) {
285 if (!ss) {
286 ss = calloc(1, sizeof(*ss));
287 }
288 ss->list = realloc(ss->list, ++ss->count * sizeof(*ss->list));
289 ss->list[ss->count-1] = s;
290 return ss;
291 }
292
293 static inline void free_decl_structs(decl_structs *ss) {
294 size_t i;
295
296 for (i = 0; i < ss->count; ++i) {
297 free_decl_struct(ss->list[i]);
298 }
299 free(ss->list);
300 free(ss);
301 }
302
303 typedef union impl_val {
304 unsigned char bval;
305 char cval;
306 short sval;
307 int ival;
308 double dval;
309 zend_long lval;
310 zend_string *str;
311 void *ptr;
312 } impl_val;
313
314 static inline impl_val *deref_impl_val(unsigned level, impl_val *ret_val, decl_arg *darg) {
315 unsigned i;
316
317 for (i = level; i < darg->var->pointer_level && ret_val->ptr; ++i) {
318 ret_val = *(void **)ret_val;
319 }
320 return ret_val;
321 }
322
323 typedef struct impl_type {
324 char *name;
325 token_t type;
326 } impl_type;
327
328 static inline impl_type *init_impl_type(token_t type, char *name) {
329 impl_type *t = malloc(sizeof(*t));
330
331 t->type = type;
332 t->name = (char *) strdup((const char *) name);
333 return t;
334 }
335
336 static inline void free_impl_type(impl_type *type) {
337 free(type->name);
338 free(type);
339 }
340
341 typedef struct impl_var {
342 char *name;
343 unsigned reference:1;
344 } impl_var;
345
346 static inline impl_var *init_impl_var(char *name, int is_reference) {
347 impl_var *var = malloc(sizeof(*var));
348 var->name = (char *) strdup((const char *) name);
349 var->reference = is_reference;
350 return var;
351 }
352
353 static inline void free_impl_var(impl_var *var) {
354 free(var->name);
355 free(var);
356 }
357
358 typedef struct impl_def_val {
359 token_t type;
360 char *text;
361 } impl_def_val;
362
363 static inline impl_def_val *init_impl_def_val(PSI_Token *T) {
364 impl_def_val *def = malloc(sizeof(*def));
365 def->type = T->type;
366 def->text = strdup(T->text);
367 return def;
368 }
369
370 static inline void free_impl_def_val(impl_def_val *def) {
371 free(def->text);
372 free(def);
373 }
374
375 typedef struct impl_arg {
376 impl_type *type;
377 impl_var *var;
378 impl_def_val *def;
379 impl_val val;
380 zval *_zv;
381 } impl_arg;
382
383 static inline impl_arg *init_impl_arg(impl_type *type, impl_var *var, impl_def_val *def) {
384 impl_arg *arg = malloc(sizeof(*arg));
385 arg->type = type;
386 arg->var = var;
387 arg->def = def;
388 return arg;
389 }
390
391 static inline void free_impl_arg(impl_arg *arg) {
392 free_impl_type(arg->type);
393 free_impl_var(arg->var);
394 if (arg->def) {
395 free_impl_def_val(arg->def);
396 }
397 free(arg);
398 }
399
400 typedef struct impl_args {
401 impl_arg **args;
402 size_t count;
403 } impl_args;
404
405 static inline impl_args *init_impl_args(impl_arg *arg) {
406 impl_args *args = malloc(sizeof(*args));
407 args->args = malloc(sizeof(*args->args));
408 if (arg) {
409 args->count = 1;
410 args->args[0] = arg;
411 } else {
412 args->count = 0;
413 args->args = NULL;
414 }
415 return args;
416 }
417
418 static inline impl_args *add_impl_arg(impl_args *args, impl_arg *arg) {
419 args->args = realloc(args->args, ++args->count * sizeof(*args->args));
420 args->args[args->count-1] = arg;
421 return args;
422 }
423
424 static inline void free_impl_args(impl_args *args) {
425 size_t i;
426
427 for (i = 0; i < args->count; ++i) {
428 free_impl_arg(args->args[i]);
429 }
430 free(args->args);
431 free(args);
432 }
433
434 typedef struct impl_func {
435 char *name;
436 impl_args *args;
437 impl_type *return_type;
438 unsigned return_reference:1;
439 } impl_func;
440
441 static inline impl_func *init_impl_func(char *name, impl_args *args, impl_type *type, int ret_reference) {
442 impl_func *func = malloc(sizeof(*func));
443 func->name = strdup(name);
444 func->args = args ? args : init_impl_args(NULL);
445 func->return_type = type;
446 func->return_reference = ret_reference;
447 return func;
448 }
449
450 static inline void free_impl_func(impl_func *f) {
451 free_impl_type(f->return_type);
452 free_impl_args(f->args);
453 free(f->name);
454 free(f);
455 }
456
457 typedef struct let_func {
458 token_t type;
459 char *name;
460 size_t size;
461 } let_func;
462
463 static inline let_func *init_let_func(token_t type, char *name, size_t size) {
464 let_func *func = malloc(sizeof(*func));
465 func->type = type;
466 func->name = strdup(name);
467 func->size = size;
468 return func;
469 }
470
471 static inline void free_let_func(let_func *func) {
472 free(func->name);
473 free(func);
474 }
475
476 typedef struct let_value {
477 let_func *func;
478 impl_var *var;
479 unsigned is_reference:1;
480 } let_value;
481
482 static inline let_value *init_let_value(let_func *func, impl_var *var, int is_reference) {
483 let_value *val = malloc(sizeof(*val));
484 val->is_reference = is_reference;
485 val->func = func;
486 val->var = var;
487 return val;
488 }
489
490 static inline void free_let_value(let_value *val) {
491 if (val->func) {
492 free_let_func(val->func);
493 }
494 if (val->var) {
495 free_impl_var(val->var);
496 }
497 free(val);
498 }
499
500 typedef struct let_stmt {
501 decl_var *var;
502 let_value *val;
503 impl_arg *arg;
504 impl_val out;
505 void *ptr;
506 void *mem;
507 } let_stmt;
508
509 static inline let_stmt *init_let_stmt(decl_var *var, let_value *val) {
510 let_stmt *let = calloc(1, sizeof(*let));
511 let->var = var;
512 let->val = val;
513 return let;
514 }
515
516 static inline void free_let_stmt(let_stmt *stmt) {
517 free_decl_var(stmt->var);
518 if (stmt->val) {
519 free_let_value(stmt->val);
520 }
521 free(stmt);
522 }
523
524 typedef struct set_func {
525 token_t type;
526 char *name;
527 } set_func;
528
529 static inline set_func *init_set_func(token_t type, char *name) {
530 set_func *func = malloc(sizeof(*func));
531 func->type = type;
532 func->name = (char *) strdup((const char *) name);
533 return func;
534 }
535
536 static inline void free_set_func(set_func *func) {
537 free(func->name);
538 free(func);
539 }
540
541 typedef struct set_value {
542 set_func *func;
543 decl_vars *vars;
544 } set_value;
545
546 static inline set_value *init_set_value(set_func *func, decl_vars *vars) {
547 set_value *val = malloc(sizeof(*val));
548 val->func = func;
549 val->vars = vars;
550 return val;
551 }
552
553 static inline void free_set_value(set_value *val) {
554 free_set_func(val->func);
555 free_decl_vars(val->vars);
556 free(val);
557 }
558
559 typedef struct set_stmt {
560 impl_var *var;
561 set_value *val;
562 impl_arg *arg;
563 } set_stmt;
564
565 static inline set_stmt *init_set_stmt(impl_var *var, set_value *val) {
566 set_stmt *set = malloc(sizeof(*set));
567 set->var = var;
568 set->val = val;
569 return set;
570 }
571
572 static inline void free_set_stmt(set_stmt *set) {
573 free_impl_var(set->var);
574 free_set_value(set->val);
575 free(set);
576 }
577
578 typedef struct return_stmt {
579 set_func *func;
580 decl_var *decl;
581 } return_stmt;
582
583 static inline return_stmt *init_return_stmt(set_func *func, decl_var *decl) {
584 return_stmt *ret = malloc(sizeof(*ret));
585 ret->func = func;
586 ret->decl = decl;
587 return ret;
588 }
589
590 static inline void free_return_stmt(return_stmt *ret) {
591 free_set_func(ret->func);
592 free_decl_var(ret->decl);
593 free(ret);
594 }
595
596 typedef struct free_stmt {
597 decl_vars *vars;
598 } free_stmt;
599
600 static inline free_stmt *init_free_stmt(decl_vars *vars) {
601 free_stmt *free_ = malloc(sizeof(*free_));
602 free_->vars = vars;
603 return free_;
604 }
605
606 static inline void free_free_stmt(free_stmt *free_) {
607 free_decl_vars(free_->vars);
608 free(free_);
609 }
610
611 typedef struct impl_stmt {
612 token_t type;
613 union {
614 let_stmt *let;
615 set_stmt *set;
616 return_stmt *ret;
617 free_stmt *fre;
618 void *ptr;
619 } s;
620 } impl_stmt;
621
622 static inline impl_stmt *init_impl_stmt(token_t type, void *ptr) {
623 impl_stmt *stmt = malloc(sizeof(*stmt));
624 stmt->type = type;
625 stmt->s.ptr = ptr;
626 return stmt;
627 }
628
629 static inline void free_impl_stmt(impl_stmt *stmt) {
630 switch (stmt->type) {
631 case PSI_T_LET:
632 free_let_stmt(stmt->s.let);
633 break;
634 case PSI_T_SET:
635 free_set_stmt(stmt->s.set);
636 break;
637 case PSI_T_RETURN:
638 free_return_stmt(stmt->s.ret);
639 break;
640 case PSI_T_FREE:
641 free_free_stmt(stmt->s.fre);
642 break;
643 }
644 free(stmt);
645 }
646
647 typedef struct impl_stmts {
648 struct {
649 return_stmt **list;
650 size_t count;
651 } ret;
652 struct {
653 let_stmt **list;
654 size_t count;
655 } let;
656 struct {
657 set_stmt **list;
658 size_t count;
659 } set;
660 struct {
661 free_stmt **list;
662 size_t count;
663 } fre;
664 } impl_stmts;
665
666 static inline void *add_impl_stmt_ex(void *list, size_t count, void *stmt) {
667 list = realloc(list, count * sizeof(list));
668 ((void **)list)[count-1] = stmt;
669 return list;
670 }
671
672 static inline impl_stmts *add_impl_stmt(impl_stmts *stmts, impl_stmt *stmt) {
673 switch (stmt->type) {
674 case PSI_T_RETURN:
675 stmts->ret.list = add_impl_stmt_ex(stmts->ret.list, ++stmts->ret.count, stmt->s.ret);
676 break;
677 case PSI_T_LET:
678 stmts->let.list = add_impl_stmt_ex(stmts->let.list, ++stmts->let.count, stmt->s.let);
679 break;
680 case PSI_T_SET:
681 stmts->set.list = add_impl_stmt_ex(stmts->set.list, ++stmts->set.count, stmt->s.set);
682 break;
683 case PSI_T_FREE:
684 stmts->fre.list = add_impl_stmt_ex(stmts->fre.list, ++stmts->fre.count, stmt->s.fre);
685 break;
686 }
687 free(stmt);
688 return stmts;
689 }
690
691 static inline impl_stmts *init_impl_stmts(impl_stmt *stmt) {
692 impl_stmts *stmts = calloc(1, sizeof(*stmts));
693 return add_impl_stmt(stmts, stmt);
694 }
695
696 static inline void free_impl_stmts(impl_stmts *stmts) {
697 size_t i;
698
699 for (i = 0; i < stmts->let.count; ++i) {
700 free_let_stmt(stmts->let.list[i]);
701 }
702 free(stmts->let.list);
703 for (i = 0; i < stmts->ret.count; ++i) {
704 free_return_stmt(stmts->ret.list[i]);
705 }
706 free(stmts->ret.list);
707 for (i = 0; i < stmts->set.count; ++i) {
708 free_set_stmt(stmts->set.list[i]);
709 }
710 free(stmts->set.list);
711 for (i = 0; i < stmts->fre.count; ++i) {
712 free_free_stmt(stmts->fre.list[i]);
713 }
714 free(stmts->fre.list);
715 free(stmts);
716 }
717
718 typedef struct impl {
719 impl_func *func;
720 impl_stmts *stmts;
721 decl *decl;
722 } impl;
723
724 static inline impl *init_impl(impl_func *func, impl_stmts *stmts) {
725 impl *i = malloc(sizeof(*i));
726 i->func = func;
727 i->stmts = stmts;
728 return i;
729 }
730
731 static inline void free_impl(impl *impl) {
732 free_impl_func(impl->func);
733 free_impl_stmts(impl->stmts);
734 free(impl);
735 }
736
737 typedef struct impls {
738 size_t count;
739 impl **list;
740 } impls;
741
742 static inline impls *add_impl(impls *impls, impl *impl) {
743 if (!impls) {
744 impls = calloc(1, sizeof(*impls));
745 }
746 impls->list = realloc(impls->list, ++impls->count * sizeof(*impls->list));
747 impls->list[impls->count-1] = impl;
748 return impls;
749 }
750
751 static void free_impls(impls *impls) {
752 size_t i;
753
754 for (i = 0; i < impls->count; ++i) {
755 free_impl(impls->list[i]);
756 }
757 free(impls->list);
758 free(impls);
759 }
760
761 typedef struct const_type {
762 token_t type;
763 char *name;
764 } const_type;
765
766 static inline const_type *init_const_type(token_t type, const char *name) {
767 const_type *ct = malloc(sizeof(*ct));
768 ct->type = type;
769 ct->name = strdup(name);
770 return ct;
771 }
772
773 static inline void free_const_type(const_type *type) {
774 free(type->name);
775 free(type);
776 }
777
778 typedef struct constant {
779 const_type *type;
780 char *name;
781 impl_def_val *val;
782 } constant;
783
784 static inline constant *init_constant(const_type *type, char *name, impl_def_val *val) {
785 constant *c = malloc(sizeof(*c));
786 c->type = type;
787 c->name = strdup(name);
788 c->val = val;
789 return c;
790 }
791
792 static inline void free_constant(constant *constant) {
793 free_const_type(constant->type);
794 free(constant->name);
795 free_impl_def_val(constant->val);
796 free(constant);
797 }
798
799 typedef struct constants {
800 size_t count;
801 constant **list;
802 } constants;
803
804 static inline constants *add_constant(constants *constants, constant *constant) {
805 if (!constants) {
806 constants = calloc(1, sizeof(*constants));
807 }
808 constants->list = realloc(constants->list, ++constants->count * sizeof(*constants->list));
809 constants->list[constants->count-1] = constant;
810 return constants;
811 }
812
813 static inline void free_constants(constants *c) {
814 size_t i;
815
816 for (i = 0; i < c->count; ++i) {
817 free_constant(c->list[i]);
818 }
819 free(c->list);
820 free(c);
821 }
822
823 #define PSI_ERROR 16
824 #define PSI_WARNING 32
825 typedef void (*psi_error_cb)(int type, const char *msg, ...);
826
827 #define PSI_DATA_MEMBERS \
828 constants *consts; \
829 decl_typedefs *defs; \
830 decl_structs *structs; \
831 decls *decls; \
832 impls *impls; \
833 char *lib; \
834 char *fn; \
835 psi_error_cb error
836 typedef struct PSI_Data {
837 PSI_DATA_MEMBERS;
838 } PSI_Data;
839
840 static inline void PSI_DataExchange(PSI_Data *dest, PSI_Data *src) {
841 memcpy(dest, src, sizeof(*dest));
842 memset(src, 0, sizeof(*src));
843 }
844
845 static inline void PSI_DataDtor(PSI_Data *data) {
846 if (data->consts) {
847 free_constants(data->consts);
848 }
849 if (data->defs) {
850 free_decl_typedefs(data->defs);
851 }
852 if (data->structs) {
853 free_decl_structs(data->structs);
854 }
855 if (data->decls) {
856 free_decls(data->decls);
857 }
858 if (data->impls) {
859 free_impls(data->impls);
860 }
861 if (data->lib) {
862 free(data->lib);
863 }
864 if (data->fn) {
865 free(data->fn);
866 }
867 }
868
869 typedef struct PSI_Parser {
870 PSI_DATA_MEMBERS;
871 FILE *fp;
872 unsigned flags;
873 unsigned errors;
874 void *proc;
875 size_t line;
876 token_t num;
877 char *cur, *tok, *lim, *eof, *ctx, *mrk, buf[BSIZE];
878 } PSI_Parser;
879
880 static inline PSI_Token *PSI_TokenAlloc(PSI_Parser *P) {
881 PSI_Token *T;
882 size_t token_len;
883
884 if (P->cur <= P->tok) {
885 return NULL;
886 }
887
888 token_len = P->cur - P->tok;
889
890 T = malloc(sizeof(*T) + token_len);
891 T->type = P->num;
892 T->line = P->line;
893 T->size = token_len;
894 T->text[token_len] = 0;
895 memcpy(T->text, P->tok, token_len);
896
897 return T;
898 }
899
900 #define PSI_PARSER_DEBUG 0x1
901
902 PSI_Parser *PSI_ParserInit(PSI_Parser *P, const char *filename, psi_error_cb error, unsigned flags);
903 void PSI_ParserSyntaxError(PSI_Parser *P, const char *fn, size_t ln, const char *msg, ...);
904 size_t PSI_ParserFill(PSI_Parser *P, size_t n);
905 token_t PSI_ParserScan(PSI_Parser *P);
906 void PSI_ParserParse(PSI_Parser *P, PSI_Token *T);
907 void PSI_ParserDtor(PSI_Parser *P);
908 void PSI_ParserFree(PSI_Parser **P);
909
910 #endif