about summary refs log tree commit diff
path: root/src/comp/syntax/parse/parser.rs
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-08-21 21:44:41 -0700
committerBrian Anderson <banderson@mozilla.com>2011-08-22 10:44:04 -0700
commit152cbaade7bc2ec36546554eb2d2090a9833bfff (patch)
treed6bb39fcdcce9f67cc97f97a6259e85cbf315650 /src/comp/syntax/parse/parser.rs
parenta3affaa20fcd718080951d5be2da3f578c960664 (diff)
downloadrust-152cbaade7bc2ec36546554eb2d2090a9833bfff.tar.gz
rust-152cbaade7bc2ec36546554eb2d2090a9833bfff.zip
Move functions from syntax::ast to syntax::ast_util
This leaves syntax::ast just defining the AST, which strikes me as somewhat
nicer
Diffstat (limited to 'src/comp/syntax/parse/parser.rs')
-rw-r--r--src/comp/syntax/parse/parser.rs31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/comp/syntax/parse/parser.rs b/src/comp/syntax/parse/parser.rs
index b20c7905013..527f6927010 100644
--- a/src/comp/syntax/parse/parser.rs
+++ b/src/comp/syntax/parse/parser.rs
@@ -90,7 +90,7 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader,
             if vec::len(buffer) == 0u {
                 let next = lexer::next_token(rdr);
                 tok = next.tok;
-                tok_span = ast::mk_sp(next.chpos, rdr.get_chpos());
+                tok_span = ast_util::mk_sp(next.chpos, rdr.get_chpos());
             } else {
                 let next = vec::pop(buffer);
                 tok = next.tok;
@@ -99,12 +99,12 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader,
         }
         fn swap(next: token::token, lo: uint, hi: uint) {
             tok = next;
-            tok_span = ast::mk_sp(lo, hi);
+            tok_span = ast_util::mk_sp(lo, hi);
         }
         fn look_ahead(distance: uint) -> token::token {
             while vec::len(buffer) < distance {
                 let next = lexer::next_token(rdr);
-                let sp = ast::mk_sp(next.chpos, rdr.get_chpos());
+                let sp = ast_util::mk_sp(next.chpos, rdr.get_chpos());
                 buffer = [{tok: next.tok, span: sp}] + buffer;
             }
             ret buffer[distance - 1u].tok;
@@ -139,7 +139,7 @@ fn new_parser(sess: parse_sess, cfg: ast::crate_cfg, rdr: lexer::reader,
     }
 
     let tok0 = lexer::next_token(rdr);
-    let span0 = ast::mk_sp(tok0.chpos, rdr.get_chpos());
+    let span0 = ast_util::mk_sp(tok0.chpos, rdr.get_chpos());
     ret stdio_parser(sess, cfg, ftype, tok0.tok, span0, span0, [],
                      UNRESTRICTED, rdr, prec_table(), bad_expr_word_table());
 }
@@ -223,7 +223,7 @@ fn expect_gt(p: &parser) {
 }
 
 fn spanned<T>(lo: uint, hi: uint, node: &T) -> spanned<T> {
-    ret {node: node, span: ast::mk_sp(lo, hi)};
+    ret {node: node, span: ast_util::mk_sp(lo, hi)};
 }
 
 fn parse_ident(p: &parser) -> ast::ident {
@@ -792,13 +792,13 @@ fn parse_field(p: &parser, sep: &token::token) -> ast::field {
 }
 
 fn mk_expr(p: &parser, lo: uint, hi: uint, node: &ast::expr_) -> @ast::expr {
-    ret @{id: p.get_id(), node: node, span: ast::mk_sp(lo, hi)};
+    ret @{id: p.get_id(), node: node, span: ast_util::mk_sp(lo, hi)};
 }
 
 fn mk_mac_expr(p: &parser, lo: uint, hi: uint, m: &ast::mac_) -> @ast::expr {
     ret @{id: p.get_id(),
-          node: ast::expr_mac({node: m, span: ast::mk_sp(lo, hi)}),
-          span: ast::mk_sp(lo, hi)};
+          node: ast::expr_mac({node: m, span: ast_util::mk_sp(lo, hi)}),
+          span: ast_util::mk_sp(lo, hi)};
 }
 
 fn parse_bottom_expr(p: &parser) -> @ast::expr {
@@ -999,7 +999,7 @@ fn parse_bottom_expr(p: &parser) -> @ast::expr {
         let e = parse_expr(p);
 
         // FIXME: Is this the right place for this check?
-        if /*check*/ast::is_call_expr(e) {
+        if /*check*/ast_util::is_call_expr(e) {
             hi = e.span.hi;
             ex = ast::expr_be(e);
         } else { p.fatal("Non-call expression in tail call"); }
@@ -1460,7 +1460,7 @@ fn parse_pat(p: &parser) -> @ast::pat {
                 subpat =
                     @{id: p.get_id(),
                       node: ast::pat_bind(fieldname),
-                      span: ast::mk_sp(lo, hi)};
+                      span: ast_util::mk_sp(lo, hi)};
             }
             fields += [{ident: fieldname, pat: subpat}];
         }
@@ -1474,7 +1474,8 @@ fn parse_pat(p: &parser) -> @ast::pat {
             hi = p.get_hi_pos();
             p.bump();
             pat =
-                ast::pat_lit(@{node: ast::lit_nil, span: ast::mk_sp(lo, hi)});
+                ast::pat_lit(@{node: ast::lit_nil,
+                               span: ast_util::mk_sp(lo, hi)});
         } else {
             let fields = [parse_pat(p)];
             while p.peek() == token::COMMA {
@@ -1520,7 +1521,7 @@ fn parse_pat(p: &parser) -> @ast::pat {
         }
       }
     }
-    ret @{id: p.get_id(), node: pat, span: ast::mk_sp(lo, hi)};
+    ret @{id: p.get_id(), node: pat, span: ast_util::mk_sp(lo, hi)};
 }
 
 fn parse_local(p: &parser, allow_init: bool) -> @ast::local {
@@ -1808,7 +1809,7 @@ fn mk_item(p: &parser, lo: uint, hi: uint, ident: &ast::ident,
           attrs: attrs,
           id: p.get_id(),
           node: node,
-          span: ast::mk_sp(lo, hi)};
+          span: ast_util::mk_sp(lo, hi)};
 }
 
 fn parse_item_fn_or_iter(p: &parser, purity: ast::purity, proto: ast::proto,
@@ -1945,7 +1946,7 @@ fn parse_item_native_type(p: &parser, attrs: &[ast::attribute]) ->
           attrs: attrs,
           node: ast::native_item_ty,
           id: p.get_id(),
-          span: ast::mk_sp(t.lo, hi)};
+          span: ast_util::mk_sp(t.lo, hi)};
 }
 
 fn parse_item_native_fn(p: &parser, attrs: &[ast::attribute]) ->
@@ -1961,7 +1962,7 @@ fn parse_item_native_fn(p: &parser, attrs: &[ast::attribute]) ->
           attrs: attrs,
           node: ast::native_item_fn(link_name, decl, t.tps),
           id: p.get_id(),
-          span: ast::mk_sp(lo, hi)};
+          span: ast_util::mk_sp(lo, hi)};
 }
 
 fn parse_native_item(p: &parser, attrs: &[ast::attribute]) ->