2010-08-18 09:00:10 -07:00
|
|
|
|
2010-10-04 15:55:12 -07:00
|
|
|
import util.common.option;
|
2010-08-18 09:00:10 -07:00
|
|
|
import std.map.hashmap;
|
2010-09-01 13:24:14 -07:00
|
|
|
import util.common.span;
|
2010-10-05 18:21:44 -07:00
|
|
|
import util.common.spanned;
|
2010-10-04 15:55:12 -07:00
|
|
|
import util.common.option;
|
|
|
|
import util.common.some;
|
|
|
|
import util.common.none;
|
2010-08-18 09:00:10 -07:00
|
|
|
|
|
|
|
type ident = str;
|
|
|
|
|
2010-10-06 15:41:14 -07:00
|
|
|
type name_ = rec(ident ident, vec[@ty] types);
|
2010-10-05 18:21:44 -07:00
|
|
|
type name = spanned[name_];
|
2010-10-04 17:25:52 -07:00
|
|
|
type path = vec[name];
|
|
|
|
|
2010-10-05 18:21:44 -07:00
|
|
|
type crate_num = int;
|
|
|
|
type slot_num = int;
|
|
|
|
type item_num = int;
|
2010-10-04 17:25:52 -07:00
|
|
|
|
2010-10-05 18:21:44 -07:00
|
|
|
tag slot_id {
|
|
|
|
id_slot(crate_num, slot_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
tag item_id {
|
|
|
|
id_item(crate_num, slot_num);
|
2010-10-04 17:25:52 -07:00
|
|
|
}
|
|
|
|
|
2010-10-05 18:21:44 -07:00
|
|
|
tag referent {
|
|
|
|
ref_slot(slot_id);
|
|
|
|
ref_item(item_id);
|
|
|
|
}
|
2010-10-04 17:25:52 -07:00
|
|
|
|
2010-10-05 18:21:44 -07:00
|
|
|
type crate = spanned[crate_];
|
|
|
|
type crate_ = rec(_mod module);
|
2010-08-18 09:00:10 -07:00
|
|
|
|
2010-10-05 18:21:44 -07:00
|
|
|
type block = spanned[block_];
|
|
|
|
type block_ = vec[@stmt];
|
2010-08-18 09:00:10 -07:00
|
|
|
|
2010-09-27 18:25:02 -07:00
|
|
|
tag binop {
|
2010-09-28 10:30:34 -07:00
|
|
|
add;
|
|
|
|
sub;
|
|
|
|
mul;
|
|
|
|
div;
|
|
|
|
rem;
|
|
|
|
and;
|
|
|
|
or;
|
|
|
|
bitxor;
|
2010-09-27 18:25:02 -07:00
|
|
|
bitand;
|
|
|
|
bitor;
|
|
|
|
lsl;
|
|
|
|
lsr;
|
|
|
|
asr;
|
|
|
|
eq;
|
|
|
|
lt;
|
|
|
|
le;
|
|
|
|
ne;
|
|
|
|
ge;
|
|
|
|
gt;
|
|
|
|
}
|
|
|
|
|
|
|
|
tag unop {
|
2010-09-28 10:30:34 -07:00
|
|
|
box;
|
|
|
|
deref;
|
2010-09-27 18:25:02 -07:00
|
|
|
bitnot;
|
|
|
|
not;
|
|
|
|
neg;
|
|
|
|
}
|
|
|
|
|
2010-10-05 18:21:44 -07:00
|
|
|
type stmt = spanned[stmt_];
|
|
|
|
tag stmt_ {
|
2010-09-09 15:59:29 -07:00
|
|
|
stmt_decl(@decl);
|
2010-09-27 18:25:02 -07:00
|
|
|
stmt_ret(option[@expr]);
|
|
|
|
stmt_log(@expr);
|
2010-10-04 15:55:12 -07:00
|
|
|
stmt_expr(@expr);
|
2010-09-09 15:59:29 -07:00
|
|
|
}
|
|
|
|
|
2010-10-05 18:21:44 -07:00
|
|
|
type decl = spanned[decl_];
|
|
|
|
tag decl_ {
|
2010-10-11 18:13:14 -07:00
|
|
|
decl_local(ident, option[@ty], option[@expr]);
|
2010-10-05 18:21:44 -07:00
|
|
|
decl_item(name, @item);
|
2010-09-09 15:59:29 -07:00
|
|
|
}
|
|
|
|
|
2010-10-05 18:21:44 -07:00
|
|
|
type expr = spanned[expr_];
|
|
|
|
tag expr_ {
|
2010-09-27 18:25:02 -07:00
|
|
|
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);
|
2010-10-04 17:25:52 -07:00
|
|
|
expr_name(name, option[referent]);
|
2010-09-28 10:30:34 -07:00
|
|
|
expr_field(@expr, ident);
|
|
|
|
expr_index(@expr, @expr);
|
2010-10-06 15:41:14 -07:00
|
|
|
expr_cast(@expr, @ty);
|
2010-10-04 15:55:12 -07:00
|
|
|
expr_if(@expr, block, option[block]);
|
|
|
|
expr_block(block);
|
2010-09-09 15:59:29 -07:00
|
|
|
}
|
|
|
|
|
2010-10-05 18:21:44 -07:00
|
|
|
type lit = spanned[lit_];
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-10-05 18:21:44 -07:00
|
|
|
type ty = spanned[ty_];
|
|
|
|
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-10-04 17:25:52 -07:00
|
|
|
ty_path(path, option[referent]);
|
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
|
|
|
|
2010-10-06 15:41:14 -07:00
|
|
|
type slot = rec(@ty ty, mode mode, option[slot_id] id);
|
2010-10-06 18:36:28 -07:00
|
|
|
type input = rec(slot slot, ident ident);
|
2010-08-18 09:00:10 -07:00
|
|
|
|
2010-10-06 18:36:28 -07:00
|
|
|
type _fn = rec(vec[input] inputs,
|
2010-10-08 12:26:34 -07:00
|
|
|
ty output,
|
2010-08-18 09:00:10 -07:00
|
|
|
block body);
|
|
|
|
|
2010-10-06 15:41:14 -07:00
|
|
|
type _mod = hashmap[ident,@item];
|
2010-08-18 09:00:10 -07:00
|
|
|
|
2010-10-05 18:21:44 -07:00
|
|
|
type item = spanned[item_];
|
|
|
|
tag item_ {
|
2010-10-06 15:41:14 -07:00
|
|
|
item_fn(_fn, item_id);
|
|
|
|
item_mod(_mod);
|
2010-10-05 18:21:44 -07:00
|
|
|
item_ty(@ty, item_id);
|
2010-09-09 15:59:29 -07:00
|
|
|
}
|
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:
|
|
|
|
//
|