summaryrefslogtreecommitdiff
path: root/src/runtime/c/pgf/expr.h
blob: d4d2aaea2af62e2c511ec0bedbc96564dd7aff56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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