diff options
| author | Graydon Hoare <[email protected]> | 2011-02-23 14:37:39 -0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-02-23 14:37:39 -0800 |
| commit | 381684043f1ad044c72347d759c1c545c6bccc3d (patch) | |
| tree | db6832b0e3be44071f294410e3a1570b42402ca4 /src | |
| parent | Parse auth clauses, drop them on the floor. Nothing exists to use them yet an... (diff) | |
| download | rust-381684043f1ad044c72347d759c1c545c6bccc3d.tar.xz rust-381684043f1ad044c72347d759c1c545c6bccc3d.zip | |
Add a type for crate directives, to support intermixing with exprs in crate files.
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/front/ast.rs | 14 | ||||
| -rw-r--r-- | src/comp/util/common.rs | 4 |
2 files changed, 17 insertions, 1 deletions
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); diff --git a/src/comp/util/common.rs b/src/comp/util/common.rs index 56f30e07..071acea2 100644 --- a/src/comp/util/common.rs +++ b/src/comp/util/common.rs @@ -2,8 +2,10 @@ import std._uint; import std._int; import front.ast; + +type filename = str; type pos = rec(uint line, uint col); -type span = rec(str filename, pos lo, pos hi); +type span = rec(filename filename, pos lo, pos hi); type spanned[T] = rec(T node, span span); tag ty_mach { |