2010-08-18 09:00:10 -07:00
|
|
|
|
|
|
|
import std.util.option;
|
|
|
|
import std.map.hashmap;
|
2010-09-01 13:24:14 -07:00
|
|
|
import util.common.span;
|
2010-08-18 09:00:10 -07:00
|
|
|
|
|
|
|
type ident = str;
|
|
|
|
|
2010-09-21 16:22:32 -07:00
|
|
|
type crate = rec(_mod module);
|
2010-08-18 09:00:10 -07:00
|
|
|
|
2010-09-01 13:24:14 -07:00
|
|
|
type block = vec[@stmt];
|
2010-08-18 09:00:10 -07:00
|
|
|
|
2010-09-27 18:25:02 -07:00
|
|
|
tag binop {
|
|
|
|
plus;
|
|
|
|
minus;
|
|
|
|
star;
|
|
|
|
slash;
|
|
|
|
percent;
|
|
|
|
caret;
|
|
|
|
bitand;
|
|
|
|
bitor;
|
|
|
|
lsl;
|
|
|
|
lsr;
|
|
|
|
asr;
|
|
|
|
eq;
|
|
|
|
lt;
|
|
|
|
le;
|
|
|
|
ne;
|
|
|
|
ge;
|
|
|
|
gt;
|
|
|
|
}
|
|
|
|
|
|
|
|
tag unop {
|
|
|
|
bitnot;
|
|
|
|
not;
|
|
|
|
neg;
|
|
|
|
deref;
|
|
|
|
cast(@ty);
|
|
|
|
}
|
|
|
|
|
2010-09-09 15:59:29 -07:00
|
|
|
tag stmt {
|
|
|
|
stmt_block(block);
|
|
|
|
stmt_decl(@decl);
|
2010-09-27 18:25:02 -07:00
|
|
|
stmt_ret(option[@expr]);
|
|
|
|
stmt_log(@expr);
|
2010-09-09 15:59:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
tag decl {
|
|
|
|
decl_local(ident, option[ty]);
|
|
|
|
decl_item(ident, @item);
|
|
|
|
}
|
|
|
|
|
|
|
|
tag lval {
|
|
|
|
lval_ident(ident);
|
|
|
|
lval_ext(@lval, ident);
|
2010-09-27 18:25:02 -07:00
|
|
|
lval_idx(@lval, @expr);
|
2010-09-09 15:59:29 -07:00
|
|
|
}
|
|
|
|
|
2010-09-27 18:25:02 -07:00
|
|
|
tag expr {
|
|
|
|
expr_box(@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_lval(@lval);
|
2010-09-09 15:59:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
tag lit {
|
2010-09-27 18:25:02 -07:00
|
|
|
lit_str(str);
|
2010-09-09 15:59:29 -07:00
|
|
|
lit_char(char);
|
|
|
|
lit_int(int);
|
2010-09-21 16:22:32 -07:00
|
|
|
lit_uint(uint);
|
2010-09-20 23:56:43 -07:00
|
|
|
lit_nil;
|
2010-09-09 15:59:29 -07:00
|
|
|
lit_bool(bool);
|
|
|
|
}
|
|
|
|
|
|
|
|
tag ty {
|
2010-09-20 23:56:43 -07:00
|
|
|
ty_nil;
|
|
|
|
ty_bool;
|
|
|
|
ty_int;
|
2010-09-21 16:22:32 -07:00
|
|
|
ty_uint;
|
|
|
|
ty_machine(util.common.ty_mach);
|
2010-09-20 23:56:43 -07:00
|
|
|
ty_char;
|
2010-09-21 16:22:32 -07:00
|
|
|
ty_str;
|
|
|
|
ty_box(@ty);
|
2010-09-09 15:59:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
tag mode {
|
2010-09-20 23:56:43 -07:00
|
|
|
val;
|
|
|
|
alias;
|
2010-09-09 15:59:29 -07:00
|
|
|
}
|
2010-08-18 09:00:10 -07:00
|
|
|
|
|
|
|
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];
|
|
|
|
|
2010-09-09 15:59:29 -07:00
|
|
|
tag item {
|
|
|
|
item_fn(@_fn);
|
|
|
|
item_mod(@_mod);
|
|
|
|
}
|
2010-08-18 09:00:10 -07:00
|
|
|
|
2010-08-12 10:27:50 -07:00
|
|
|
|
|
|
|
//
|
|
|
|
// 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:
|
|
|
|
//
|