#ifndef CERC_PARSE_H #define CERC_PARSE_H #include "lex.h" #include "type.h" struct ast_externfunc { const char *name; struct type ret; struct type params[]; }; struct ast_param { const char *name; struct type type; }; struct ast_cmd { /* TODO */ }; struct ast_block { struct ast_cmd *cmds; }; struct ast_func { bool pub, exported; const char *name; struct ast_block block; struct type ret; struct ast_param params[]; }; enum const_global { CST_TYPE, CST_BOOL, CST_NUMBER, CST_STRING, }; struct ast_const_global { bool pub; const char *name; enum const_global kind; union { struct type *type; bool b; struct number num; const char *str; } value; }; struct ast_path { const char **segments; }; struct ast_import { struct ast_path path; const char *name; }; enum toplevel { TOP_EXTERNFUNC, TOP_FUNC, TOP_CONST, }; struct ast_toplevel { enum toplevel kind; union { struct ast_externfunc *extfn; struct ast_func *function; struct ast_const_global *constant; } decl; }; struct ast_subunit { struct ast_import *imports; struct ast_toplevel tops[]; }; struct ast_unit { struct ast_subunit *root; struct ast_subunit imports[]; }; void parse(struct lexer *lexer, struct ast_unit *ast); #endif