aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front/ast.rs
blob: e115087e17b9700e1a71a1502bf38b1632f99fa6 (plain) (blame)
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
import util.common.option;
import std.map.hashmap;
import util.common.span;
import util.common.option;
import util.common.some;
import util.common.none;

type ident = str;

type name = rec(ident ident, vec[ty] types);
type path = vec[name];

type crate_id = int;
type slot_id = int;
type item_id = int;

tag referent {
    ref_slot(crate_id, slot_id);
    ref_item(crate_id, item_id);
}


type crate = rec(_mod module);

type block = vec[@stmt];

tag binop {
    add;
    sub;
    mul;
    div;
    rem;
    and;
    or;
    bitxor;
    bitand;
    bitor;
    lsl;
    lsr;
    asr;
    eq;
    lt;
    le;
    ne;
    ge;
    gt;
}

tag unop {
    box;
    deref;
    bitnot;
    not;
    neg;
}

tag stmt {
    stmt_decl(@decl);
    stmt_ret(option[@expr]);
    stmt_log(@expr);
    stmt_expr(@expr);
}

tag decl {
    decl_local(ident, option[ty]);
    decl_item(ident, @item);
}

tag expr {
    expr_vec(vec[@expr]);
    expr_tup(vec[@expr]);
    expr_rec(vec[tup(ident,@expr)]);
    expr_call(@expr, vec[@expr]);
    expr_binary(binop, @expr, @expr);
    expr_unary(unop, @expr);
    expr_lit(@lit);
    expr_name(name, option[referent]);
    expr_field(@expr, ident);
    expr_index(@expr, @expr);
    expr_cast(@expr, ty);
    expr_if(@expr, block, option[block]);
    expr_block(block);
}

tag lit {
    lit_str(str);
    lit_char(char);
    lit_int(int);
    lit_uint(uint);
    lit_nil;
    lit_bool(bool);
}

tag ty {
    ty_nil;
    ty_bool;
    ty_int;
    ty_uint;
    ty_machine(util.common.ty_mach);
    ty_char;
    ty_str;
    ty_box(@ty);
    ty_path(path, option[referent]);
}

tag mode {
    val;
    alias;
}

type slot = rec(ty ty, mode mode);

type _fn = rec(vec[rec(slot slot, ident ident)] inputs,
               slot output,
               block body);

type _mod = hashmap[ident,item];

tag item {
    item_fn(@_fn);
    item_mod(@_mod);
    item_ty(@ty);
}


//
// Local Variables:
// mode: rust
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// compile-command: "make -k -C ../.. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
// End:
//