aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-08-18 09:00:10 -0700
committerGraydon Hoare <[email protected]>2010-08-18 09:00:10 -0700
commit102ec1687700d51b5367bd68c43ce146bb8c9b74 (patch)
treea7577cc95b055183b35b1c00d08d0a08d6ed5ee8 /src
parentAdd test code that exercises LLVM in rustc. Works. (diff)
downloadrust-102ec1687700d51b5367bd68c43ce146bb8c9b74.tar.xz
rust-102ec1687700d51b5367bd68c43ce146bb8c9b74.zip
Flesh out the ast module in rustc a little.
Diffstat (limited to 'src')
-rw-r--r--src/comp/fe/ast.rs48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/comp/fe/ast.rs b/src/comp/fe/ast.rs
index 8aea570d..3a329ded 100644
--- a/src/comp/fe/ast.rs
+++ b/src/comp/fe/ast.rs
@@ -1,4 +1,50 @@
-type crate = rec( str filename );
+
+import std.util.option;
+import std.map.hashmap;
+
+type ident = str;
+
+type crate = rec( str filename,
+ _mod module);
+
+type block = vec[stmt];
+
+type stmt = tag( stmt_block(block),
+ stmt_decl(@decl),
+ stmt_ret(option[@lval]) );
+
+type decl = tag( decl_local(ident, option[ty]),
+ decl_item(ident, @item) );
+
+type lval = tag( lval_ident(ident),
+ lval_ext(@lval, ident),
+ lval_idx(@lval, @atom) );
+
+type atom = tag( atom_lit(lit));
+
+type lit = tag( lit_char(char),
+ lit_int(int),
+ lit_nil(),
+ lit_bool(bool) );
+
+type ty = tag( ty_nil(),
+ ty_bool(),
+ ty_int(),
+ ty_char() );
+
+type mode = tag( local(), 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];
+
+type item = tag( item_fn(@_fn),
+ item_mod(@_mod) );
+
//
// Local Variables: