Skip to content

Commit 3816840

Browse files
committed
Add a type for crate directives, to support intermixing with exprs in crate files.
1 parent c6bc5cc commit 3816840

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/comp/front/ast.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import std._vec;
55
import util.common.span;
66
import util.common.spanned;
77
import util.common.ty_mach;
8+
import util.common.filename;
89

910
type ident = str;
1011

@@ -43,6 +44,18 @@ tag def {
4344
type crate = spanned[crate_];
4445
type crate_ = rec(_mod module);
4546

47+
tag crate_directive_ {
48+
cdir_expr(@expr);
49+
cdir_src_mod(ident, option.t[filename]);
50+
cdir_dir_mod(ident, option.t[filename], vec[crate_directive]);
51+
cdir_view_item(@view_item);
52+
cdir_meta(@meta_item);
53+
cdir_syntax(path);
54+
cdir_auth(path, effect);
55+
}
56+
type crate_directive = spanned[crate_directive_];
57+
58+
4659
type meta_item = spanned[meta_item_];
4760
type meta_item_ = rec(ident name, str value);
4861

@@ -161,6 +174,7 @@ tag expr_ {
161174
expr_do_while(block, @expr, ann);
162175
expr_alt(@expr, vec[arm], ann);
163176
expr_block(block, ann);
177+
expr_crate_directive_block(vec[crate_directive_]);
164178
expr_assign(@expr /* TODO: @expr|is_lval */, @expr, ann);
165179
expr_assign_op(binop, @expr /* TODO: @expr|is_lval */, @expr, ann);
166180
expr_field(@expr, ident, ann);

src/comp/util/common.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import std._uint;
22
import std._int;
33
import front.ast;
44

5+
6+
type filename = str;
57
type pos = rec(uint line, uint col);
6-
type span = rec(str filename, pos lo, pos hi);
8+
type span = rec(filename filename, pos lo, pos hi);
79
type spanned[T] = rec(T node, span span);
810

911
tag ty_mach {

0 commit comments

Comments
 (0)