diff options
| author | krasimir <krasimir@chalmers.se> | 2010-06-16 15:14:34 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2010-06-16 15:14:34 +0000 |
| commit | c760c52223c4737bf2803e2c28699a923c4c12c5 (patch) | |
| tree | 78a93bc98fe5914105cdbdc747f9968c9c50b446 /src/runtime/c/pgf/expr.h | |
| parent | 106d056f54ca8cdc887680d822ac31614ccf383b (diff) | |
grammar loader and unloader in C. Abstract Syntax only!
Diffstat (limited to 'src/runtime/c/pgf/expr.h')
| -rw-r--r-- | src/runtime/c/pgf/expr.h | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/src/runtime/c/pgf/expr.h b/src/runtime/c/pgf/expr.h new file mode 100644 index 000000000..d4d2aaea2 --- /dev/null +++ b/src/runtime/c/pgf/expr.h @@ -0,0 +1,144 @@ +#ifndef PGF_EXPR_H +#define PGF_EXPR_H + +#define LIT_STR 0 +#define LIT_INT 1 +#define LIT_FLOAT 2 + +struct _Literal { + int tag; +}; + +typedef struct _LiteralStr { + struct _Literal _; + String val; +} *LiteralStr; + +typedef struct _LiteralInt { + struct _Literal _; + int val; +} *LiteralInt; + +typedef struct _LiteralFloat { + struct _Literal _; + double val; +} *LiteralFloat; + +#define TAG_ABS 0 +#define TAG_APP 1 +#define TAG_LIT 2 +#define TAG_MET 3 +#define TAG_FUN 4 +#define TAG_VAR 5 +#define TAG_TYP 6 +#define TAG_IMP 7 + +struct _Expr { + int tag; +}; + +typedef struct _ExprAbs { + struct _Expr _; + BindType bt; + CId var; + Expr body; +} *ExprAbs; + +typedef struct _ExprApp { + struct _Expr _; + Expr left, right; +} *ExprApp; + +typedef struct _ExprLit { + struct _Expr _; + Literal lit; +} *ExprLit; + +typedef struct _ExprMeta { + struct _Expr _; + int id; +} *ExprMeta; + +typedef struct _ExprFun { + struct _Expr _; + CId fun; +} *ExprFun; + +typedef struct _ExprVar { + struct _Expr _; + int index; +} *ExprVar; + +typedef struct _ExprTyped { + struct _Expr _; + Expr e; + Type ty; +} *ExprTyped; + +typedef struct _ExprImplArg { + struct _Expr _; + Expr e; +} *ExprImplArg; + +#define TAG_PAPP 0 +#define TAG_PVAR 1 +#define TAG_PAT 2 +#define TAG_PWILD 3 +#define TAG_PLIT 4 +#define TAG_PIMP 5 +#define TAG_PTILDE 6 + +typedef struct _Patt { + int tag; +} *Patt; + +typedef struct _Patts { + int count; + Patt pats[]; +} *Patts; + +typedef struct _PattApp { + struct _Patt _; + CId fun; + struct _Patts args; +} *PattApp; + +typedef struct _PattVar { + struct _Patt _; + CId var; +} *PattVar; + +typedef struct _PattAt { + struct _Patt _; + CId var; + Patt pat; +} *PattAt; + +typedef struct _PattWild { + struct _Patt _; +} *PattWild; + +typedef struct _PattLit { + struct _Patt _; + Literal lit; +} *PattLit; + +typedef struct _PattImplArg { + struct _Patt _; + Patt pat; +} *PattImplArg; + +typedef struct _PattTilde { + struct _Patt _; + Expr e; +} *PattTilde; + +typedef struct _Equations { + int count; + struct _Equation { + Patts lhs; + Expr rhs; + } equs[]; +} *Equations; + +#endif |
