From 8ef22972dbe50b2e05c8983769a638fd5b6a23b5 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 1 Feb 2011 14:56:21 -0800 Subject: Add ty_type. --- src/comp/front/ast.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 10bcd5c4..9fddb66f 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -197,6 +197,7 @@ tag ty_ { ty_obj(vec[ty_method]); ty_path(path, option.t[def]); ty_mutable(@ty); + ty_type; } type arg = rec(mode mode, @ty ty, ident ident, def_id id); -- cgit v1.2.3 From 70bf54bcac587c0bc8a3a593bda75115e4c23aa8 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 1 Feb 2011 16:23:48 -0800 Subject: Implement 'else if' --- src/comp/front/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 9fddb66f..be47615a 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -149,7 +149,7 @@ tag expr_ { expr_unary(unop, @expr, ann); expr_lit(@lit, ann); expr_cast(@expr, @ty, ann); - expr_if(@expr, block, option.t[block], ann); + expr_if(@expr, block, vec[tup(@expr, block)], option.t[block], ann); expr_while(@expr, block, ann); expr_for(@decl, @expr, block, ann); expr_do_while(block, @expr, ann); -- cgit v1.2.3 From 4b06dc574ba7d3ae50795cbe4f10d4be6e9c64a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Tue, 1 Feb 2011 13:40:04 -0500 Subject: Add very minimal support for native modules. For now they must be empty. --- src/comp/front/ast.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index be47615a..5f527f2d 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -227,6 +227,8 @@ type _mod = rec(vec[@view_item] view_items, vec[@item] items, mod_index index); +type native_mod = rec(str native_name); + type variant_arg = rec(@ty ty, def_id id); type variant = rec(str name, vec[variant_arg] args, def_id id, ann ann); @@ -241,6 +243,7 @@ tag item_ { item_const(ident, @ty, @expr, def_id, ann); item_fn(ident, _fn, vec[ty_param], def_id, ann); item_mod(ident, _mod, def_id); + item_native_mod(ident, native_mod, def_id); item_ty(ident, @ty, vec[ty_param], def_id, ann); item_tag(ident, vec[variant], vec[ty_param], def_id); item_obj(ident, _obj, vec[ty_param], def_id, ann); @@ -268,6 +271,9 @@ fn index_item(mod_index index, @item it) { case (ast.item_mod(?id, _, _)) { index.insert(id, ast.mie_item(it)); } + case (ast.item_native_mod(?id, _, _)) { + index.insert(id, ast.mie_item(it)); + } case (ast.item_ty(?id, _, _, _, _)) { index.insert(id, ast.mie_item(it)); } -- cgit v1.2.3 From dd3ed6139a6fc6fda15403d0b5679535959945e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Wed, 2 Feb 2011 10:43:57 -0500 Subject: Add most of the plumbing for native items and add support for parsing native type declarations. --- src/comp/front/ast.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 5f527f2d..7b22e700 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -215,7 +215,6 @@ type obj_field = rec(@ty ty, ident ident, def_id id, ann ann); type _obj = rec(vec[obj_field] fields, vec[@method] methods); - tag mod_index_entry { mie_view_item(@view_item); mie_item(@item); @@ -227,7 +226,10 @@ type _mod = rec(vec[@view_item] view_items, vec[@item] items, mod_index index); -type native_mod = rec(str native_name); +type native_mod = rec(str native_name, + vec[@native_item] items, + native_mod_index index); +type native_mod_index = hashmap[ident,@native_item]; type variant_arg = rec(@ty ty, def_id id); type variant = rec(str name, vec[variant_arg] args, def_id id, ann ann); @@ -249,6 +251,11 @@ tag item_ { item_obj(ident, _obj, vec[ty_param], def_id, ann); } +type native_item = spanned[native_item_]; +tag native_item_ { + native_item_ty(ident, def_id); +} + fn index_view_item(mod_index index, @view_item it) { alt (it.node) { case(ast.view_item_use(?id, _, _)) { @@ -292,6 +299,14 @@ fn index_item(mod_index index, @item it) { } } +fn index_native_item(native_mod_index index, @native_item it) { + alt (it.node) { + case (ast.native_item_ty(?id, _)) { + index.insert(id, it); + } + } +} + // // Local Variables: // mode: rust -- cgit v1.2.3 From 57bb9d809bb029caf7b38042a433153bb965e1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Fri, 4 Feb 2011 11:10:04 -0500 Subject: Parse function declarations. --- src/comp/front/ast.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 7b22e700..1220d6ab 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -201,10 +201,11 @@ tag ty_ { } type arg = rec(mode mode, @ty ty, ident ident, def_id id); -type _fn = rec(effect effect, +type fn_decl = rec(effect effect, + vec[arg] inputs, + @ty output); +type _fn = rec(fn_decl decl, bool is_iter, - vec[arg] inputs, - @ty output, block body); @@ -254,6 +255,7 @@ tag item_ { type native_item = spanned[native_item_]; tag native_item_ { native_item_ty(ident, def_id); + native_item_fn(ident, fn_decl, vec[ty_param], def_id); } fn index_view_item(mod_index index, @view_item it) { @@ -304,6 +306,9 @@ fn index_native_item(native_mod_index index, @native_item it) { case (ast.native_item_ty(?id, _)) { index.insert(id, it); } + case (ast.native_item_fn(?id, _, _, _)) { + index.insert(id, it); + } } } -- cgit v1.2.3 From 3e613c1648141ac757d1f0608ad845686ebbe97e Mon Sep 17 00:00:00 2001 From: Rafael Avila de Espindola Date: Mon, 7 Feb 2011 15:07:27 -0500 Subject: Add native modules to resolve. With this hello world gets to typecheck. --- src/comp/front/ast.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 1220d6ab..5f315e58 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -36,6 +36,8 @@ tag def { def_ty_arg(def_id); def_binding(def_id); def_use(def_id); + def_native_ty(def_id); + def_native_fn(def_id); } type crate = spanned[crate_]; -- cgit v1.2.3 From 378c0087ca7572cd17726c704fe04d57bf4687af Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 30 Jan 2011 17:18:19 -0500 Subject: Parse 'be' statement. Pass tailcall tests. No actual tailcalls yet. --- src/comp/front/ast.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 5f315e58..756a7ad1 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -116,6 +116,7 @@ type stmt = spanned[stmt_]; tag stmt_ { stmt_decl(@decl); stmt_ret(option.t[@expr]); + stmt_be(@expr); stmt_log(@expr); stmt_check_expr(@expr); stmt_fail; -- cgit v1.2.3 From f17a3421e01399bcc1a6f8540273d7b4440397a1 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 9 Feb 2011 22:36:37 -0500 Subject: Cleanup for 'be' statement and comments about future typestate --- src/comp/front/ast.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 756a7ad1..61a7bdc1 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -315,6 +315,17 @@ fn index_native_item(native_mod_index index, @native_item it) { } } +fn is_call_expr(@expr e) -> bool { + alt (e.node) { + case (expr_call(_, _, _)) { + ret true; + } + case (_) { + ret false; + } + } +} + // // Local Variables: // mode: rust -- cgit v1.2.3 From a396652766bc6aa2b4526ddd9807439ecd12033a Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 10 Feb 2011 18:59:23 -0800 Subject: Add pat_lit to ast, and support parsing it. --- src/comp/front/ast.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 61a7bdc1..6aac7b50 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -57,6 +57,7 @@ type pat = spanned[pat_]; tag pat_ { pat_wild(ann); pat_bind(ident, def_id, ann); + pat_lit(@lit, ann); pat_tag(path, vec[@pat], option.t[variant_def], ann); } -- cgit v1.2.3 From 59bce06a967b3806c3d874b8956857f0f01287e1 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 14 Feb 2011 15:52:38 -0800 Subject: Expand expr_rec to take its optional trailing 'with' parameter. --- src/comp/front/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 6aac7b50..3aec3226 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -146,7 +146,7 @@ type expr = spanned[expr_]; tag expr_ { expr_vec(vec[@expr], ann); expr_tup(vec[elt], ann); - expr_rec(vec[field], ann); + expr_rec(vec[field], option.t[@expr], ann); expr_call(@expr, vec[@expr], ann); expr_bind(@expr, vec[option.t[@expr]], ann); expr_binary(binop, @expr, @expr, ann); -- cgit v1.2.3 From 890d027b653edd1722b186a5723944e622736313 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 14 Feb 2011 16:33:25 -0800 Subject: Add parse support for expr_ext. --- src/comp/front/ast.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 3aec3226..820bbbfa 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -164,6 +164,7 @@ tag expr_ { expr_field(@expr, ident, ann); expr_index(@expr, @expr, ann); expr_path(path, option.t[def], ann); + expr_ext(vec[@expr], option.t[@expr], ann); } type lit = spanned[lit_]; -- cgit v1.2.3 From f1f33abdeba156523d6db1752bbff75dc4088724 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 14 Feb 2011 17:46:28 -0800 Subject: Move all non-decl/non-expr stmts to exprs. --- src/comp/front/ast.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 820bbbfa..53ffdd87 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -116,11 +116,6 @@ tag mode { type stmt = spanned[stmt_]; tag stmt_ { stmt_decl(@decl); - stmt_ret(option.t[@expr]); - stmt_be(@expr); - stmt_log(@expr); - stmt_check_expr(@expr); - stmt_fail; stmt_expr(@expr); } @@ -165,6 +160,11 @@ tag expr_ { expr_index(@expr, @expr, ann); expr_path(path, option.t[def], ann); expr_ext(vec[@expr], option.t[@expr], ann); + expr_fail; + expr_ret(option.t[@expr]); + expr_be(@expr); + expr_log(@expr); + expr_check_expr(@expr); } type lit = spanned[lit_]; -- cgit v1.2.3 From 15a01f5c3691a152793d8933a7be9d16a0fc7030 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 14 Feb 2011 17:58:32 -0800 Subject: Add basic front-end support for expr_put. --- src/comp/front/ast.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 53ffdd87..cb2df2a5 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -162,6 +162,7 @@ tag expr_ { expr_ext(vec[@expr], option.t[@expr], ann); expr_fail; expr_ret(option.t[@expr]); + expr_put(option.t[@expr]); expr_be(@expr); expr_log(@expr); expr_check_expr(@expr); -- cgit v1.2.3 From 4a72a23171d87fb5a0f9b7ad039944856b93bf0f Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 14 Feb 2011 18:17:31 -0800 Subject: Add basic front-end support for 'for each' loops. --- src/comp/front/ast.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index cb2df2a5..9e43d349 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -151,6 +151,7 @@ tag expr_ { expr_if(@expr, block, vec[tup(@expr, block)], option.t[block], ann); expr_while(@expr, block, ann); expr_for(@decl, @expr, block, ann); + expr_for_each(@decl, @expr, block, ann); expr_do_while(block, @expr, ann); expr_alt(@expr, vec[arm], ann); expr_block(block, ann); -- cgit v1.2.3 From 2bba49a9feed613c2f018d5aa751df3c7a49a3d6 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 15 Feb 2011 12:20:13 -0800 Subject: Fix missing path in expr_ext. --- src/comp/front/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 9e43d349..520f5557 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -160,7 +160,7 @@ tag expr_ { expr_field(@expr, ident, ann); expr_index(@expr, @expr, ann); expr_path(path, option.t[def], ann); - expr_ext(vec[@expr], option.t[@expr], ann); + expr_ext(path, vec[@expr], option.t[@expr], ann); expr_fail; expr_ret(option.t[@expr]); expr_put(option.t[@expr]); -- cgit v1.2.3 From 9ae89bd404803be6b820189d8e0480b3395d05ee Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 15 Feb 2011 12:20:30 -0800 Subject: Add _mutable unop. --- src/comp/front/ast.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 520f5557..03ccc216 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -106,6 +106,7 @@ tag unop { bitnot; not; neg; + _mutable; } tag mode { -- cgit v1.2.3 From 012fa69ea500aa31cb3dd2cd3df67ecd3eefd44e Mon Sep 17 00:00:00 2001 From: Rafael Avila de Espindola Date: Wed, 16 Feb 2011 14:02:02 -0500 Subject: More typechecking for native types and the needed plumbing in codegen. --- src/comp/front/ast.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 03ccc216..ee358432 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -263,7 +263,7 @@ tag item_ { type native_item = spanned[native_item_]; tag native_item_ { native_item_ty(ident, def_id); - native_item_fn(ident, fn_decl, vec[ty_param], def_id); + native_item_fn(ident, fn_decl, vec[ty_param], def_id, ann); } fn index_view_item(mod_index index, @view_item it) { @@ -314,7 +314,7 @@ fn index_native_item(native_mod_index index, @native_item it) { case (ast.native_item_ty(?id, _)) { index.insert(id, it); } - case (ast.native_item_fn(?id, _, _, _)) { + case (ast.native_item_fn(?id, _, _, _, _)) { index.insert(id, it); } } -- cgit v1.2.3 From 34c60b6edb810d9f142d248b27d8e6e34c95d63c Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 18 Feb 2011 17:30:57 -0800 Subject: Make a tag for iterness / fnness, teach many places about it. --- src/comp/front/ast.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index ee358432..01739d19 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -78,6 +78,11 @@ tag effect { eff_unsafe; } +tag proto { + proto_iter; + proto_fn; +} + tag binop { add; sub; @@ -187,7 +192,8 @@ tag lit_ { type ty_field = rec(ident ident, @ty ty); type ty_arg = rec(mode mode, @ty ty); // TODO: effect -type ty_method = rec(ident ident, vec[ty_arg] inputs, @ty output); +type ty_method = rec(proto proto, ident ident, + vec[ty_arg] inputs, @ty output); type ty = spanned[ty_]; tag ty_ { ty_nil; @@ -201,7 +207,7 @@ tag ty_ { ty_vec(@ty); ty_tup(vec[@ty]); ty_rec(vec[ty_field]); - ty_fn(vec[ty_arg], @ty); // TODO: effect + ty_fn(proto, vec[ty_arg], @ty); // TODO: effect ty_obj(vec[ty_method]); ty_path(path, option.t[def]); ty_mutable(@ty); @@ -210,10 +216,10 @@ tag ty_ { type arg = rec(mode mode, @ty ty, ident ident, def_id id); type fn_decl = rec(effect effect, + proto proto, vec[arg] inputs, @ty output); type _fn = rec(fn_decl decl, - bool is_iter, block body); -- cgit v1.2.3 From ffcb4613700c968041f891985927b77f70a51c0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Wed, 23 Feb 2011 14:06:37 -0500 Subject: Parse the abi in native modules. --- src/comp/front/ast.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 01739d19..30b4d324 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -241,7 +241,13 @@ type _mod = rec(vec[@view_item] view_items, vec[@item] items, mod_index index); +tag native_abi { + native_abi_rust; + native_abi_cdecl; +} + type native_mod = rec(str native_name, + native_abi abi, vec[@native_item] items, native_mod_index index); type native_mod_index = hashmap[ident,@native_item]; -- cgit v1.2.3 From 381684043f1ad044c72347d759c1c545c6bccc3d Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 23 Feb 2011 14:37:39 -0800 Subject: Add a type for crate directives, to support intermixing with exprs in crate files. --- src/comp/front/ast.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 30b4d324..2c307478 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -5,6 +5,7 @@ import std._vec; import util.common.span; import util.common.spanned; import util.common.ty_mach; +import util.common.filename; type ident = str; @@ -43,6 +44,18 @@ tag def { type crate = spanned[crate_]; type crate_ = rec(_mod module); +tag crate_directive_ { + cdir_expr(@expr); + cdir_src_mod(ident, option.t[filename]); + cdir_dir_mod(ident, option.t[filename], vec[crate_directive]); + cdir_view_item(@view_item); + cdir_meta(@meta_item); + cdir_syntax(path); + cdir_auth(path, effect); +} +type crate_directive = spanned[crate_directive_]; + + type meta_item = spanned[meta_item_]; type meta_item_ = rec(ident name, str value); @@ -161,6 +174,7 @@ tag expr_ { expr_do_while(block, @expr, ann); expr_alt(@expr, vec[arm], ann); expr_block(block, ann); + expr_crate_directive_block(vec[crate_directive_]); expr_assign(@expr /* TODO: @expr|is_lval */, @expr, ann); expr_assign_op(binop, @expr /* TODO: @expr|is_lval */, @expr, ann); expr_field(@expr, ident, ann); -- cgit v1.2.3 From 127139aecd5c3a1227ee58c77fc083506125f7cd Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 24 Feb 2011 12:14:05 -0800 Subject: Parse crate directive tree in one pass, then evaluate it in a second. --- src/comp/front/ast.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 2c307478..088ef4ed 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -46,8 +46,9 @@ type crate_ = rec(_mod module); tag crate_directive_ { cdir_expr(@expr); + cdir_const(@item); cdir_src_mod(ident, option.t[filename]); - cdir_dir_mod(ident, option.t[filename], vec[crate_directive]); + cdir_dir_mod(ident, option.t[filename], vec[@crate_directive]); cdir_view_item(@view_item); cdir_meta(@meta_item); cdir_syntax(path); -- cgit v1.2.3 From b2a09562a6c0683ca528c866abc1ecc99b4bdcf0 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 24 Feb 2011 15:54:55 -0800 Subject: Factor crate expr evaluator out of parser, expand to simple scalars and ops, if, alt. --- src/comp/front/ast.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 088ef4ed..f5c03bd7 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -46,7 +46,10 @@ type crate_ = rec(_mod module); tag crate_directive_ { cdir_expr(@expr); - cdir_const(@item); + // FIXME: cdir_let should be eliminated + // and redirected to the use of const stmt_decls inside + // crate directive blocks. + cdir_let(ident, @expr, vec[@crate_directive]); cdir_src_mod(ident, option.t[filename]); cdir_dir_mod(ident, option.t[filename], vec[@crate_directive]); cdir_view_item(@view_item); @@ -137,6 +140,8 @@ type stmt = spanned[stmt_]; tag stmt_ { stmt_decl(@decl); stmt_expr(@expr); + // These only exist in crate-level blocks. + stmt_crate_directive(@crate_directive); } type local = rec(option.t[@ty] ty, @@ -175,7 +180,6 @@ tag expr_ { expr_do_while(block, @expr, ann); expr_alt(@expr, vec[arm], ann); expr_block(block, ann); - expr_crate_directive_block(vec[crate_directive_]); expr_assign(@expr /* TODO: @expr|is_lval */, @expr, ann); expr_assign_op(binop, @expr /* TODO: @expr|is_lval */, @expr, ann); expr_field(@expr, ident, ann); -- cgit v1.2.3 From f8f6f078c505dd0f20526e3ad86c360605fce109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20=C3=81vila=20de=20Esp=C3=ADndola?= Date: Fri, 25 Feb 2011 12:08:21 -0500 Subject: There are no native iterators (or at least they are not going to be supported soon.). --- src/comp/front/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index f5c03bd7..9b995f9a 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -235,10 +235,10 @@ tag ty_ { type arg = rec(mode mode, @ty ty, ident ident, def_id id); type fn_decl = rec(effect effect, - proto proto, vec[arg] inputs, @ty output); type _fn = rec(fn_decl decl, + proto proto, block body); -- cgit v1.2.3 From 64ab5eaaf09de6a75392554c13784c492ed19465 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Tue, 1 Mar 2011 17:32:16 -0800 Subject: Parse (and ignore) dtors on objs. --- src/comp/front/ast.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 9b995f9a..4ed513a3 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -247,7 +247,8 @@ type method = spanned[method_]; type obj_field = rec(@ty ty, ident ident, def_id id, ann ann); type _obj = rec(vec[obj_field] fields, - vec[@method] methods); + vec[@method] methods, + option.t[block] dtor); tag mod_index_entry { mie_view_item(@view_item); -- cgit v1.2.3 From 9528c34774ff27b112c9e66afff6e10fa7021635 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 23 Feb 2011 23:48:01 -0500 Subject: Begin implementing #fmt in rustc --- src/comp/front/ast.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 4ed513a3..18add3bd 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -185,7 +185,7 @@ tag expr_ { expr_field(@expr, ident, ann); expr_index(@expr, @expr, ann); expr_path(path, option.t[def], ann); - expr_ext(path, vec[@expr], option.t[@expr], ann); + expr_ext(path, vec[@expr], option.t[@expr], option.t[@expr], ann); expr_fail; expr_ret(option.t[@expr]); expr_put(option.t[@expr]); @@ -363,6 +363,17 @@ fn is_call_expr(@expr e) -> bool { } } +fn is_ext_expr(@expr e) -> bool { + alt (e.node) { + case (expr_ext(_, _, _, _, _)) { + ret true; + } + case (_) { + ret false; + } + } +} + // // Local Variables: // mode: rust -- cgit v1.2.3 From c1e6f5328c3f46884ed7a7e29c780e307b02100a Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 27 Feb 2011 22:35:27 -0500 Subject: Make the expanded expression in expr_ext not optional --- src/comp/front/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 18add3bd..694a709d 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -185,7 +185,7 @@ tag expr_ { expr_field(@expr, ident, ann); expr_index(@expr, @expr, ann); expr_path(path, option.t[def], ann); - expr_ext(path, vec[@expr], option.t[@expr], option.t[@expr], ann); + expr_ext(path, vec[@expr], option.t[@expr], @expr, ann); expr_fail; expr_ret(option.t[@expr]); expr_put(option.t[@expr]); -- cgit v1.2.3 From dbd90996ee1fd8eb996ac85f44fe17f0f3d834ca Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Tue, 1 Mar 2011 19:50:27 -0500 Subject: Remove unused is_ext_expr --- src/comp/front/ast.rs | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 694a709d..46f57168 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -363,17 +363,6 @@ fn is_call_expr(@expr e) -> bool { } } -fn is_ext_expr(@expr e) -> bool { - alt (e.node) { - case (expr_ext(_, _, _, _, _)) { - ret true; - } - case (_) { - ret false; - } - } -} - // // Local Variables: // mode: rust -- cgit v1.2.3 From 9e4943c9229e15fa11069eeb2b20060994f9ac0f Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 2 Mar 2011 13:50:42 -0800 Subject: Parse, add to AST, and otherwise ignore 'export' view items. Need to add support to resolve. --- src/comp/front/ast.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 46f57168..474dc4aa 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -279,6 +279,7 @@ type view_item = spanned[view_item_]; tag view_item_ { view_item_use(ident, vec[@meta_item], def_id); view_item_import(ident, vec[ident], def_id, option.t[def]); + view_item_export(ident); } type item = spanned[item_]; @@ -306,6 +307,11 @@ fn index_view_item(mod_index index, @view_item it) { case(ast.view_item_import(?def_ident,_,_,_)) { index.insert(def_ident, ast.mie_view_item(it)); } + case(ast.view_item_export(_)) { + // NB: don't index these, they might collide with + // the import or use that they're exporting. Have + // to do linear search for exports. + } } } -- cgit v1.2.3 From 02dff96b52cac4900fd35235623c8a2dd98ca08f Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 4 Mar 2011 11:28:40 -0800 Subject: Parse meta directives in crates. --- src/comp/front/ast.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 474dc4aa..e9dee7ec 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -53,7 +53,7 @@ tag crate_directive_ { cdir_src_mod(ident, option.t[filename]); cdir_dir_mod(ident, option.t[filename], vec[@crate_directive]); cdir_view_item(@view_item); - cdir_meta(@meta_item); + cdir_meta(vec[@meta_item]); cdir_syntax(path); cdir_auth(path, effect); } -- cgit v1.2.3 From 596face2745ccc11a959a530807ea3e36e9d1354 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 4 Mar 2011 14:15:19 -0800 Subject: Parse (and generally ignore) constraints and constrained types. --- src/comp/front/ast.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index e9dee7ec..a8bf4b00 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -231,8 +231,17 @@ tag ty_ { ty_path(path, option.t[def]); ty_mutable(@ty); ty_type; + ty_constr(@ty, vec[@constr]); } +tag constr_arg_ { + carg_base; + carg_ident(ident); +} +type constr_arg = spanned[constr_arg_]; +type constr_ = rec(path path, vec[@constr_arg] args); +type constr = spanned[constr_]; + type arg = rec(mode mode, @ty ty, ident ident, def_id id); type fn_decl = rec(effect effect, vec[arg] inputs, -- cgit v1.2.3 From 90f299e710c49d689d5bc815e32db375cca00394 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 7 Mar 2011 11:48:43 -0800 Subject: Permit view items in native modules. --- src/comp/front/ast.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index a8bf4b00..ed1e2114 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -265,6 +265,11 @@ tag mod_index_entry { mie_tag_variant(@item /* tag item */, uint /* variant index */); } +tag native_mod_index_entry { + nmie_view_item(@view_item); + nmie_item(@native_item); +} + type mod_index = hashmap[ident,mod_index_entry]; type _mod = rec(vec[@view_item] view_items, vec[@item] items, @@ -277,9 +282,10 @@ tag native_abi { type native_mod = rec(str native_name, native_abi abi, + vec[@view_item] view_items, vec[@native_item] items, native_mod_index index); -type native_mod_index = hashmap[ident,@native_item]; +type native_mod_index = hashmap[ident,native_mod_index_entry]; type variant_arg = rec(@ty ty, def_id id); type variant = rec(str name, vec[variant_arg] args, def_id id, ann ann); @@ -359,10 +365,23 @@ fn index_item(mod_index index, @item it) { fn index_native_item(native_mod_index index, @native_item it) { alt (it.node) { case (ast.native_item_ty(?id, _)) { - index.insert(id, it); + index.insert(id, ast.nmie_item(it)); } case (ast.native_item_fn(?id, _, _, _, _)) { - index.insert(id, it); + index.insert(id, ast.nmie_item(it)); + } + } +} + +fn index_native_view_item(native_mod_index index, @view_item it) { + alt (it.node) { + case(ast.view_item_import(?def_ident,_,_,_)) { + index.insert(def_ident, ast.nmie_view_item(it)); + } + case(ast.view_item_export(_)) { + // NB: don't index these, they might collide with + // the import or use that they're exporting. Have + // to do linear search for exports. } } } -- cgit v1.2.3 From 0624f9db4aeaa5681941750c3a1a17ca5fbb7e72 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 4 Mar 2011 07:22:43 +0100 Subject: Add a pretty-printer Adds a -pp option to the compiler which will cause it to simply pretty-print the given file. --- src/comp/front/ast.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index ed1e2114..d45260f3 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -122,6 +122,31 @@ tag binop { gt; } +fn binop_to_str(binop op) -> str { + alt (op) { + case (add) {ret "+";} + case (sub) {ret "-";} + case (mul) {ret "*";} + case (div) {ret "/";} + case (rem) {ret "%";} + case (and) {ret "&&";} + case (or) {ret "||";} + case (bitxor) {ret "^";} + case (bitand) {ret "&";} + case (bitor) {ret "|";} + case (lsl) {ret "<<";} + case (lsr) {ret ">>";} + case (asr) {ret ">>>";} + case (eq) {ret "==";} + case (lt) {ret "<";} + case (le) {ret "<=";} + case (ne) {ret "!=";} + case (ge) {ret ">=";} + case (gt) {ret ">";} + } +} + + tag unop { box; deref; @@ -131,6 +156,17 @@ tag unop { _mutable; } +fn unop_to_str(unop op) -> str { + alt (op) { + case (box) {ret "@";} + case (deref) {ret "*";} + case (bitnot) {ret "~";} + case (not) {ret "!";} + case (neg) {ret "-";} + case (_mutable) {ret "mutable";} + } +} + tag mode { val; alias; -- cgit v1.2.3 From df3038e68bf1189cd9cb0fc81e57da2c23594b63 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Mon, 7 Mar 2011 15:38:20 -0800 Subject: Parse opacity (and drop on the floor), so std.rc parses now. --- src/comp/front/ast.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/comp/front/ast.rs') diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index d45260f3..52ae66c8 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -83,6 +83,11 @@ tag mutability { imm; } +tag opacity { + op_abstract; + op_transparent; +} + tag layer { layer_value; layer_state; -- cgit v1.2.3