#include "div.h" #include "fn.h" #include "gl.h" #include "im.h" #include "lk.h" #include "pr.h" #include "td.h" #include "ws.h" static const struct seq externals = {(struct step[]){{ID, "externals"}, {0}}, .fn = lk}, types = {(struct step[]){{ID, "types"}, {0}}, .fn = td}, imports = {(struct step[]){{ID, "imports"}, {0}}, .fn = im}, procedure = {(struct step[]){{ID, "procedure"}, {0}}, .fn = pr}; static const struct seq fnseq[] = { externals, types, imports, procedure, {(struct step[]){{ID, "locals"}, {0}}, .fn = ws}, {(struct step[]){{ID, "globals"}, {0}}, .fn = gl}, {0} }; static const struct seq imseq[] = { externals, types, imports, {0} }; static const struct seq pseq[] = { externals, procedure, {0} }; int div_fn(const struct lex *l, struct prv *p) { struct pos init = { .name = __func__, .seq = fnseq, .end = fn_end }; if (push(&init, p)) return -1; p->stk = p->tk; return 0; } int div_im(const struct lex *l, struct prv *p) { struct pos init = { .name = __func__, .seq = imseq, }; if (push(&init, p)) return -1; p->stk = p->tk; return 0; } static int endp(const struct lex *l, struct prv *p) { if (fn_end(l, p)) return -1; p->proto = NULL; return 0; } int div_p(const struct lex *l, struct prv *p) { struct pos init = { .name = __func__, .seq = pseq, .end = endp }; if (push(&init, p)) return -1; p->stk = p->tk; return 0; }