summaryrefslogtreecommitdiff
path: root/parse.h
diff options
context:
space:
mode:
Diffstat (limited to 'parse.h')
-rw-r--r--parse.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/parse.h b/parse.h
new file mode 100644
index 0000000..89bb0c4
--- /dev/null
+++ b/parse.h
@@ -0,0 +1,104 @@
+#ifndef PARSE_H
+#define PARSE_H
+
+#include "lex.h"
+
+struct u
+{
+ struct storage *storage;
+};
+
+struct s
+{
+ struct storage *storage;
+};
+
+union c
+{
+ unsigned long long uv;
+ long long v;
+};
+
+struct p
+{
+ int dummy;
+};
+
+struct t
+{
+ int dummy;
+};
+
+struct builtin
+{
+ const char *name;
+};
+
+struct type
+{
+ enum {U, S, C, P, T, BUILTIN} type;
+ const struct tk *tk;
+ size_t sz;
+ int sign;
+
+ union
+ {
+ struct u u;
+ struct s s;
+ union c c;
+ struct p p;
+ struct t t;
+ struct builtin b;
+ } u;
+};
+
+struct param
+{
+ const struct tk *tk;
+ const struct stentry *entry;
+};
+
+struct pr
+{
+ const struct tk *tk;
+ struct param *params, *ret;
+ size_t nparams;
+};
+
+struct td
+{
+ const struct tk *tk;
+ struct type *types;
+ size_t ntypes;
+};
+
+struct fn
+{
+ const struct tk *tk;
+ enum linkage {EXTERNAL, STATIC} linkage;
+ struct storage *lk, *ws, *gl;
+ struct stmt *stmts;
+ struct pr *pr;
+ struct td *td;
+ size_t nstmts;
+};
+
+struct lit
+{
+ char *name;
+ const struct tk *tk;
+ const struct fn *fn;
+ struct lit *next;
+};
+
+struct ast
+{
+ struct fn *fns;
+ struct lit *lits, *lastlit;
+ size_t nfns, litcnt;
+};
+
+int parse(const struct lex *l, struct ast *ast);
+void ast_free(struct ast *ast);
+
+#endif