diff options
| author | Graydon Hoare <[email protected]> | 2011-03-04 11:28:40 -0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-03-04 11:28:40 -0800 |
| commit | 02dff96b52cac4900fd35235623c8a2dd98ca08f (patch) | |
| tree | d47452bf2290efcc0f7d1d774ac93e0f7456b570 /src/comp | |
| parent | Assortment of additional work on vec-append. Not done yet. (diff) | |
| download | rust-02dff96b52cac4900fd35235623c8a2dd98ca08f.tar.xz rust-02dff96b52cac4900fd35235623c8a2dd98ca08f.zip | |
Parse meta directives in crates.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/front/ast.rs | 2 | ||||
| -rw-r--r-- | src/comp/front/parser.rs | 35 |
2 files changed, 22 insertions, 15 deletions
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); } diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 1be4226c..f80c3bd5 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -1564,14 +1564,14 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool { case (ast.expr_if(_,_,_,_,_)) { ret false; } case (ast.expr_for(_,_,_,_)) { ret false; } case (ast.expr_for_each(_,_,_,_)) - { ret false; } + { ret false; } case (ast.expr_while(_,_,_)) { ret false; } case (ast.expr_do_while(_,_,_)) { ret false; } case (ast.expr_alt(_,_,_)) { ret false; } case (ast.expr_block(_,_)) { ret false; } case (ast.expr_assign(_,_,_)) { ret true; } case (ast.expr_assign_op(_,_,_,_)) - { ret true; } + { ret true; } case (ast.expr_field(_,_,_)) { ret true; } case (ast.expr_index(_,_,_)) { ret true; } case (ast.expr_path(_,_,_)) { ret true; } @@ -1583,16 +1583,8 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool { case (ast.expr_check_expr(_)) { ret true; } } } - case (ast.stmt_crate_directive(?cdir)) { - alt (cdir.node) { - case (ast.cdir_src_mod(_, _)) { ret true; } - case (ast.cdir_view_item(_)) { ret true; } - case (ast.cdir_meta(_)) { ret true; } - case (ast.cdir_syntax(_)) { ret true; } - case (ast.cdir_auth(_, _)) { ret true; } - case (_) { ret false; } - } - } + // We should not be calling this on a cdir. + case (ast.stmt_crate_directive(?cdir)) { fail; } } } @@ -1636,8 +1628,13 @@ impure fn parse_block(parser p) -> ast.block { case (none[@ast.expr]) { // Not an expression statement. stmts += vec(stmt); - if (stmt_ends_with_semi(stmt)) { - expect(p, token.SEMI); + // FIXME: crazy differentiation between conditions + // used in branches and binary expressions in rustboot + // means we cannot use && here. I know, right? + if (p.get_file_type() == SOURCE_FILE) { + if (stmt_ends_with_semi(stmt)) { + expect(p, token.SEMI); + } } } } @@ -2261,6 +2258,16 @@ impure fn parse_crate_directive(parser p) -> ast.crate_directive ret spanned(lo, hi, ast.cdir_auth(n, e)); } + case (token.META) { + // FIXME: currently dropping meta clauses on the floor, + // as there is no crate metadata system + p.bump(); + auto mis = parse_meta(p); + hi = p.get_span(); + expect(p, token.SEMI); + ret spanned(lo, hi, ast.cdir_meta(mis)); + } + case (token.MOD) { p.bump(); auto id = parse_ident(p); |