Move functions from syntax::ast to syntax::ast_util

This leaves syntax::ast just defining the AST, which strikes me as somewhat
nicer
This commit is contained in:
Brian Anderson 2011-08-21 21:44:41 -07:00
parent a3affaa20f
commit 152cbaade7
33 changed files with 358 additions and 314 deletions

View file

@ -78,7 +78,7 @@ fn new_reader(cm: &codemap::codemap, src: str, filemap: codemap::filemap,
fn get_col() -> uint { ret col; }
fn get_filemap() -> codemap::filemap { ret fm; }
fn err(m: str) {
codemap::emit_error(some(ast::mk_sp(chpos, chpos)), m, cm);
codemap::emit_error(some(ast_util::mk_sp(chpos, chpos)), m, cm);
}
}
let strs: [str] = [];

View file

@ -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]) ->

View file

@ -1,6 +1,6 @@
import ast::ty_mach;
import ast::ty_mach_to_str;
import ast_util::ty_mach_to_str;
import std::map::new_str_hash;
import util::interner;
import std::int;