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