librustc: De-@mut
the parse session
This commit is contained in:
parent
f553701da6
commit
3aa19a6b86
8 changed files with 48 additions and 49 deletions
|
@ -204,7 +204,7 @@ pub struct Session_ {
|
||||||
targ_cfg: @config,
|
targ_cfg: @config,
|
||||||
opts: @options,
|
opts: @options,
|
||||||
cstore: @metadata::cstore::CStore,
|
cstore: @metadata::cstore::CStore,
|
||||||
parse_sess: @mut ParseSess,
|
parse_sess: @ParseSess,
|
||||||
codemap: @codemap::CodeMap,
|
codemap: @codemap::CodeMap,
|
||||||
// For a library crate, this is always none
|
// For a library crate, this is always none
|
||||||
entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
|
entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
|
||||||
|
|
|
@ -1429,18 +1429,18 @@ fn decode_item_ast(par_doc: ebml::Doc) -> @ast::item {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
trait fake_ext_ctxt {
|
trait fake_ext_ctxt {
|
||||||
fn cfg(&self) -> ast::CrateConfig;
|
fn cfg(&self) -> ast::CrateConfig;
|
||||||
fn parse_sess(&self) -> @mut parse::ParseSess;
|
fn parse_sess(&self) -> @parse::ParseSess;
|
||||||
fn call_site(&self) -> Span;
|
fn call_site(&self) -> Span;
|
||||||
fn ident_of(&self, st: &str) -> ast::Ident;
|
fn ident_of(&self, st: &str) -> ast::Ident;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
type fake_session = @mut parse::ParseSess;
|
type fake_session = @parse::ParseSess;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
impl fake_ext_ctxt for fake_session {
|
impl fake_ext_ctxt for fake_session {
|
||||||
fn cfg(&self) -> ast::CrateConfig { ~[] }
|
fn cfg(&self) -> ast::CrateConfig { ~[] }
|
||||||
fn parse_sess(&self) -> @mut parse::ParseSess { *self }
|
fn parse_sess(&self) -> @parse::ParseSess { *self }
|
||||||
fn call_site(&self) -> Span {
|
fn call_site(&self) -> Span {
|
||||||
codemap::Span {
|
codemap::Span {
|
||||||
lo: codemap::BytePos(0),
|
lo: codemap::BytePos(0),
|
||||||
|
|
|
@ -284,7 +284,7 @@ pub fn syntax_expander_table() -> SyntaxEnv {
|
||||||
// when a macro expansion occurs, the resulting nodes have the backtrace()
|
// when a macro expansion occurs, the resulting nodes have the backtrace()
|
||||||
// -> expn_info of their expansion context stored into their span.
|
// -> expn_info of their expansion context stored into their span.
|
||||||
pub struct ExtCtxt {
|
pub struct ExtCtxt {
|
||||||
parse_sess: @mut parse::ParseSess,
|
parse_sess: @parse::ParseSess,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
backtrace: Option<@ExpnInfo>,
|
backtrace: Option<@ExpnInfo>,
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ pub struct ExtCtxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExtCtxt {
|
impl ExtCtxt {
|
||||||
pub fn new(parse_sess: @mut parse::ParseSess, cfg: ast::CrateConfig)
|
pub fn new(parse_sess: @parse::ParseSess, cfg: ast::CrateConfig)
|
||||||
-> ExtCtxt {
|
-> ExtCtxt {
|
||||||
ExtCtxt {
|
ExtCtxt {
|
||||||
parse_sess: parse_sess,
|
parse_sess: parse_sess,
|
||||||
|
@ -320,7 +320,7 @@ impl ExtCtxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn codemap(&self) -> @CodeMap { self.parse_sess.cm }
|
pub fn codemap(&self) -> @CodeMap { self.parse_sess.cm }
|
||||||
pub fn parse_sess(&self) -> @mut parse::ParseSess { self.parse_sess }
|
pub fn parse_sess(&self) -> @parse::ParseSess { self.parse_sess }
|
||||||
pub fn cfg(&self) -> ast::CrateConfig { self.cfg.clone() }
|
pub fn cfg(&self) -> ast::CrateConfig { self.cfg.clone() }
|
||||||
pub fn call_site(&self) -> Span {
|
pub fn call_site(&self) -> Span {
|
||||||
match self.backtrace {
|
match self.backtrace {
|
||||||
|
|
|
@ -889,7 +889,7 @@ impl ast_fold for Injector {
|
||||||
|
|
||||||
// add a bunch of macros as though they were placed at the head of the
|
// add a bunch of macros as though they were placed at the head of the
|
||||||
// program (ick). This should run before cfg stripping.
|
// program (ick). This should run before cfg stripping.
|
||||||
pub fn inject_std_macros(parse_sess: @mut parse::ParseSess,
|
pub fn inject_std_macros(parse_sess: @parse::ParseSess,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
c: Crate)
|
c: Crate)
|
||||||
-> Crate {
|
-> Crate {
|
||||||
|
@ -939,7 +939,7 @@ impl<'a> ast_fold for MacroExpander<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expand_crate(parse_sess: @mut parse::ParseSess,
|
pub fn expand_crate(parse_sess: @parse::ParseSess,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
c: Crate) -> Crate {
|
c: Crate) -> Crate {
|
||||||
let mut cx = ExtCtxt::new(parse_sess, cfg.clone());
|
let mut cx = ExtCtxt::new(parse_sess, cfg.clone());
|
||||||
|
|
|
@ -188,9 +188,9 @@ pub enum named_match {
|
||||||
|
|
||||||
pub type earley_item = ~MatcherPos;
|
pub type earley_item = ~MatcherPos;
|
||||||
|
|
||||||
pub fn nameize(p_s: @mut ParseSess, ms: &[matcher], res: &[@named_match])
|
pub fn nameize(p_s: @ParseSess, ms: &[matcher], res: &[@named_match])
|
||||||
-> HashMap<Ident,@named_match> {
|
-> HashMap<Ident,@named_match> {
|
||||||
fn n_rec(p_s: @mut ParseSess, m: &matcher, res: &[@named_match],
|
fn n_rec(p_s: @ParseSess, m: &matcher, res: &[@named_match],
|
||||||
ret_val: &mut HashMap<Ident, @named_match>) {
|
ret_val: &mut HashMap<Ident, @named_match>) {
|
||||||
match *m {
|
match *m {
|
||||||
codemap::Spanned {node: match_tok(_), .. } => (),
|
codemap::Spanned {node: match_tok(_), .. } => (),
|
||||||
|
@ -222,7 +222,7 @@ pub enum parse_result {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_or_else(
|
pub fn parse_or_else(
|
||||||
sess: @mut ParseSess,
|
sess: @ParseSess,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
rdr: @mut reader,
|
rdr: @mut reader,
|
||||||
ms: ~[matcher]
|
ms: ~[matcher]
|
||||||
|
@ -243,12 +243,11 @@ pub fn token_name_eq(t1 : &Token, t2 : &Token) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse(
|
pub fn parse(sess: @ParseSess,
|
||||||
sess: @mut ParseSess,
|
cfg: ast::CrateConfig,
|
||||||
cfg: ast::CrateConfig,
|
rdr: @mut reader,
|
||||||
rdr: @mut reader,
|
ms: &[matcher])
|
||||||
ms: &[matcher]
|
-> parse_result {
|
||||||
) -> parse_result {
|
|
||||||
let mut cur_eis = ~[];
|
let mut cur_eis = ~[];
|
||||||
cur_eis.push(initial_matcher_pos(ms.to_owned(), None, rdr.peek().sp.lo));
|
cur_eis.push(initial_matcher_pos(ms.to_owned(), None, rdr.peek().sp.lo));
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,9 @@ pub struct ParseSess {
|
||||||
included_mod_stack: RefCell<~[Path]>,
|
included_mod_stack: RefCell<~[Path]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_parse_sess(demitter: Option<@Emitter>) -> @mut ParseSess {
|
pub fn new_parse_sess(demitter: Option<@Emitter>) -> @ParseSess {
|
||||||
let cm = @CodeMap::new();
|
let cm = @CodeMap::new();
|
||||||
@mut ParseSess {
|
@ParseSess {
|
||||||
cm: cm,
|
cm: cm,
|
||||||
span_diagnostic: mk_span_handler(mk_handler(demitter), cm),
|
span_diagnostic: mk_span_handler(mk_handler(demitter), cm),
|
||||||
included_mod_stack: RefCell::new(~[]),
|
included_mod_stack: RefCell::new(~[]),
|
||||||
|
@ -58,8 +58,8 @@ pub fn new_parse_sess(demitter: Option<@Emitter>) -> @mut ParseSess {
|
||||||
|
|
||||||
pub fn new_parse_sess_special_handler(sh: @mut SpanHandler,
|
pub fn new_parse_sess_special_handler(sh: @mut SpanHandler,
|
||||||
cm: @codemap::CodeMap)
|
cm: @codemap::CodeMap)
|
||||||
-> @mut ParseSess {
|
-> @ParseSess {
|
||||||
@mut ParseSess {
|
@ParseSess {
|
||||||
cm: cm,
|
cm: cm,
|
||||||
span_diagnostic: sh,
|
span_diagnostic: sh,
|
||||||
included_mod_stack: RefCell::new(~[]),
|
included_mod_stack: RefCell::new(~[]),
|
||||||
|
@ -74,7 +74,7 @@ pub fn new_parse_sess_special_handler(sh: @mut SpanHandler,
|
||||||
pub fn parse_crate_from_file(
|
pub fn parse_crate_from_file(
|
||||||
input: &Path,
|
input: &Path,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
sess: @mut ParseSess
|
sess: @ParseSess
|
||||||
) -> ast::Crate {
|
) -> ast::Crate {
|
||||||
new_parser_from_file(sess, /*bad*/ cfg.clone(), input).parse_crate_mod()
|
new_parser_from_file(sess, /*bad*/ cfg.clone(), input).parse_crate_mod()
|
||||||
// why is there no p.abort_if_errors here?
|
// why is there no p.abort_if_errors here?
|
||||||
|
@ -83,7 +83,7 @@ pub fn parse_crate_from_file(
|
||||||
pub fn parse_crate_attrs_from_file(
|
pub fn parse_crate_attrs_from_file(
|
||||||
input: &Path,
|
input: &Path,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
sess: @mut ParseSess
|
sess: @ParseSess
|
||||||
) -> ~[ast::Attribute] {
|
) -> ~[ast::Attribute] {
|
||||||
let mut parser = new_parser_from_file(sess, cfg, input);
|
let mut parser = new_parser_from_file(sess, cfg, input);
|
||||||
let (inner, _) = parser.parse_inner_attrs_and_next();
|
let (inner, _) = parser.parse_inner_attrs_and_next();
|
||||||
|
@ -94,7 +94,7 @@ pub fn parse_crate_from_source_str(
|
||||||
name: @str,
|
name: @str,
|
||||||
source: @str,
|
source: @str,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
sess: @mut ParseSess
|
sess: @ParseSess
|
||||||
) -> ast::Crate {
|
) -> ast::Crate {
|
||||||
let mut p = new_parser_from_source_str(sess,
|
let mut p = new_parser_from_source_str(sess,
|
||||||
/*bad*/ cfg.clone(),
|
/*bad*/ cfg.clone(),
|
||||||
|
@ -107,7 +107,7 @@ pub fn parse_crate_attrs_from_source_str(
|
||||||
name: @str,
|
name: @str,
|
||||||
source: @str,
|
source: @str,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
sess: @mut ParseSess
|
sess: @ParseSess
|
||||||
) -> ~[ast::Attribute] {
|
) -> ~[ast::Attribute] {
|
||||||
let mut p = new_parser_from_source_str(sess,
|
let mut p = new_parser_from_source_str(sess,
|
||||||
/*bad*/ cfg.clone(),
|
/*bad*/ cfg.clone(),
|
||||||
|
@ -121,7 +121,7 @@ pub fn parse_expr_from_source_str(
|
||||||
name: @str,
|
name: @str,
|
||||||
source: @str,
|
source: @str,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
sess: @mut ParseSess
|
sess: @ParseSess
|
||||||
) -> @ast::Expr {
|
) -> @ast::Expr {
|
||||||
let mut p = new_parser_from_source_str(sess, cfg, name, source);
|
let mut p = new_parser_from_source_str(sess, cfg, name, source);
|
||||||
maybe_aborted(p.parse_expr(), p)
|
maybe_aborted(p.parse_expr(), p)
|
||||||
|
@ -132,7 +132,7 @@ pub fn parse_item_from_source_str(
|
||||||
source: @str,
|
source: @str,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
attrs: ~[ast::Attribute],
|
attrs: ~[ast::Attribute],
|
||||||
sess: @mut ParseSess
|
sess: @ParseSess
|
||||||
) -> Option<@ast::item> {
|
) -> Option<@ast::item> {
|
||||||
let mut p = new_parser_from_source_str(sess, cfg, name, source);
|
let mut p = new_parser_from_source_str(sess, cfg, name, source);
|
||||||
maybe_aborted(p.parse_item(attrs),p)
|
maybe_aborted(p.parse_item(attrs),p)
|
||||||
|
@ -142,7 +142,7 @@ pub fn parse_meta_from_source_str(
|
||||||
name: @str,
|
name: @str,
|
||||||
source: @str,
|
source: @str,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
sess: @mut ParseSess
|
sess: @ParseSess
|
||||||
) -> @ast::MetaItem {
|
) -> @ast::MetaItem {
|
||||||
let mut p = new_parser_from_source_str(sess, cfg, name, source);
|
let mut p = new_parser_from_source_str(sess, cfg, name, source);
|
||||||
maybe_aborted(p.parse_meta_item(),p)
|
maybe_aborted(p.parse_meta_item(),p)
|
||||||
|
@ -153,7 +153,7 @@ pub fn parse_stmt_from_source_str(
|
||||||
source: @str,
|
source: @str,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
attrs: ~[ast::Attribute],
|
attrs: ~[ast::Attribute],
|
||||||
sess: @mut ParseSess
|
sess: @ParseSess
|
||||||
) -> @ast::Stmt {
|
) -> @ast::Stmt {
|
||||||
let mut p = new_parser_from_source_str(
|
let mut p = new_parser_from_source_str(
|
||||||
sess,
|
sess,
|
||||||
|
@ -168,7 +168,7 @@ pub fn parse_tts_from_source_str(
|
||||||
name: @str,
|
name: @str,
|
||||||
source: @str,
|
source: @str,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
sess: @mut ParseSess
|
sess: @ParseSess
|
||||||
) -> ~[ast::token_tree] {
|
) -> ~[ast::token_tree] {
|
||||||
let mut p = new_parser_from_source_str(
|
let mut p = new_parser_from_source_str(
|
||||||
sess,
|
sess,
|
||||||
|
@ -192,7 +192,7 @@ pub fn parse_from_source_str<T>(
|
||||||
ss: codemap::FileSubstr,
|
ss: codemap::FileSubstr,
|
||||||
source: @str,
|
source: @str,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
sess: @mut ParseSess)
|
sess: @ParseSess)
|
||||||
-> T {
|
-> T {
|
||||||
let mut p = new_parser_from_source_substr(sess, cfg, name, ss, source);
|
let mut p = new_parser_from_source_substr(sess, cfg, name, ss, source);
|
||||||
let r = f(&mut p);
|
let r = f(&mut p);
|
||||||
|
@ -203,7 +203,7 @@ pub fn parse_from_source_str<T>(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new parser from a source string
|
// Create a new parser from a source string
|
||||||
pub fn new_parser_from_source_str(sess: @mut ParseSess,
|
pub fn new_parser_from_source_str(sess: @ParseSess,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
name: @str,
|
name: @str,
|
||||||
source: @str)
|
source: @str)
|
||||||
|
@ -213,7 +213,7 @@ pub fn new_parser_from_source_str(sess: @mut ParseSess,
|
||||||
|
|
||||||
// Create a new parser from a source string where the origin
|
// Create a new parser from a source string where the origin
|
||||||
// is specified as a substring of another file.
|
// is specified as a substring of another file.
|
||||||
pub fn new_parser_from_source_substr(sess: @mut ParseSess,
|
pub fn new_parser_from_source_substr(sess: @ParseSess,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
name: @str,
|
name: @str,
|
||||||
ss: codemap::FileSubstr,
|
ss: codemap::FileSubstr,
|
||||||
|
@ -225,7 +225,7 @@ pub fn new_parser_from_source_substr(sess: @mut ParseSess,
|
||||||
/// Create a new parser, handling errors as appropriate
|
/// Create a new parser, handling errors as appropriate
|
||||||
/// if the file doesn't exist
|
/// if the file doesn't exist
|
||||||
pub fn new_parser_from_file(
|
pub fn new_parser_from_file(
|
||||||
sess: @mut ParseSess,
|
sess: @ParseSess,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
path: &Path
|
path: &Path
|
||||||
) -> Parser {
|
) -> Parser {
|
||||||
|
@ -236,7 +236,7 @@ pub fn new_parser_from_file(
|
||||||
/// the file at the given path to the codemap, and return a parser.
|
/// the file at the given path to the codemap, and return a parser.
|
||||||
/// On an error, use the given span as the source of the problem.
|
/// On an error, use the given span as the source of the problem.
|
||||||
pub fn new_sub_parser_from_file(
|
pub fn new_sub_parser_from_file(
|
||||||
sess: @mut ParseSess,
|
sess: @ParseSess,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
path: &Path,
|
path: &Path,
|
||||||
sp: Span
|
sp: Span
|
||||||
|
@ -245,7 +245,7 @@ pub fn new_sub_parser_from_file(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a filemap and config, return a parser
|
/// Given a filemap and config, return a parser
|
||||||
pub fn filemap_to_parser(sess: @mut ParseSess,
|
pub fn filemap_to_parser(sess: @ParseSess,
|
||||||
filemap: @FileMap,
|
filemap: @FileMap,
|
||||||
cfg: ast::CrateConfig) -> Parser {
|
cfg: ast::CrateConfig) -> Parser {
|
||||||
tts_to_parser(sess,filemap_to_tts(sess,filemap),cfg)
|
tts_to_parser(sess,filemap_to_tts(sess,filemap),cfg)
|
||||||
|
@ -253,7 +253,7 @@ pub fn filemap_to_parser(sess: @mut ParseSess,
|
||||||
|
|
||||||
// must preserve old name for now, because quote! from the *existing*
|
// must preserve old name for now, because quote! from the *existing*
|
||||||
// compiler expands into it
|
// compiler expands into it
|
||||||
pub fn new_parser_from_tts(sess: @mut ParseSess,
|
pub fn new_parser_from_tts(sess: @ParseSess,
|
||||||
cfg: ast::CrateConfig,
|
cfg: ast::CrateConfig,
|
||||||
tts: ~[ast::token_tree]) -> Parser {
|
tts: ~[ast::token_tree]) -> Parser {
|
||||||
tts_to_parser(sess,tts,cfg)
|
tts_to_parser(sess,tts,cfg)
|
||||||
|
@ -264,7 +264,7 @@ pub fn new_parser_from_tts(sess: @mut ParseSess,
|
||||||
|
|
||||||
/// Given a session and a path and an optional span (for error reporting),
|
/// Given a session and a path and an optional span (for error reporting),
|
||||||
/// add the path to the session's codemap and return the new filemap.
|
/// add the path to the session's codemap and return the new filemap.
|
||||||
pub fn file_to_filemap(sess: @mut ParseSess, path: &Path, spanopt: Option<Span>)
|
pub fn file_to_filemap(sess: @ParseSess, path: &Path, spanopt: Option<Span>)
|
||||||
-> @FileMap {
|
-> @FileMap {
|
||||||
let err = |msg: &str| {
|
let err = |msg: &str| {
|
||||||
match spanopt {
|
match spanopt {
|
||||||
|
@ -293,20 +293,20 @@ pub fn file_to_filemap(sess: @mut ParseSess, path: &Path, spanopt: Option<Span>)
|
||||||
|
|
||||||
// given a session and a string, add the string to
|
// given a session and a string, add the string to
|
||||||
// the session's codemap and return the new filemap
|
// the session's codemap and return the new filemap
|
||||||
pub fn string_to_filemap(sess: @mut ParseSess, source: @str, path: @str)
|
pub fn string_to_filemap(sess: @ParseSess, source: @str, path: @str)
|
||||||
-> @FileMap {
|
-> @FileMap {
|
||||||
sess.cm.new_filemap(path, source)
|
sess.cm.new_filemap(path, source)
|
||||||
}
|
}
|
||||||
|
|
||||||
// given a session and a string and a path and a FileSubStr, add
|
// given a session and a string and a path and a FileSubStr, add
|
||||||
// the string to the CodeMap and return the new FileMap
|
// the string to the CodeMap and return the new FileMap
|
||||||
pub fn substring_to_filemap(sess: @mut ParseSess, source: @str, path: @str,
|
pub fn substring_to_filemap(sess: @ParseSess, source: @str, path: @str,
|
||||||
filesubstr: FileSubstr) -> @FileMap {
|
filesubstr: FileSubstr) -> @FileMap {
|
||||||
sess.cm.new_filemap_w_substr(path,filesubstr,source)
|
sess.cm.new_filemap_w_substr(path,filesubstr,source)
|
||||||
}
|
}
|
||||||
|
|
||||||
// given a filemap, produce a sequence of token-trees
|
// given a filemap, produce a sequence of token-trees
|
||||||
pub fn filemap_to_tts(sess: @mut ParseSess, filemap: @FileMap)
|
pub fn filemap_to_tts(sess: @ParseSess, filemap: @FileMap)
|
||||||
-> ~[ast::token_tree] {
|
-> ~[ast::token_tree] {
|
||||||
// it appears to me that the cfg doesn't matter here... indeed,
|
// it appears to me that the cfg doesn't matter here... indeed,
|
||||||
// parsing tt's probably shouldn't require a parser at all.
|
// parsing tt's probably shouldn't require a parser at all.
|
||||||
|
@ -317,7 +317,7 @@ pub fn filemap_to_tts(sess: @mut ParseSess, filemap: @FileMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
// given tts and cfg, produce a parser
|
// given tts and cfg, produce a parser
|
||||||
pub fn tts_to_parser(sess: @mut ParseSess,
|
pub fn tts_to_parser(sess: @ParseSess,
|
||||||
tts: ~[ast::token_tree],
|
tts: ~[ast::token_tree],
|
||||||
cfg: ast::CrateConfig) -> Parser {
|
cfg: ast::CrateConfig) -> Parser {
|
||||||
let trdr = lexer::new_tt_reader(sess.span_diagnostic, None, tts);
|
let trdr = lexer::new_tt_reader(sess.span_diagnostic, None, tts);
|
||||||
|
|
|
@ -286,8 +286,8 @@ struct ParsedItemsAndViewItems {
|
||||||
|
|
||||||
/* ident is handled by common.rs */
|
/* ident is handled by common.rs */
|
||||||
|
|
||||||
pub fn Parser(sess: @mut ParseSess, cfg: ast::CrateConfig, rdr: @mut reader)
|
pub fn Parser(sess: @ParseSess, cfg: ast::CrateConfig, rdr: @mut reader)
|
||||||
-> Parser {
|
-> Parser {
|
||||||
let tok0 = rdr.next_token();
|
let tok0 = rdr.next_token();
|
||||||
let interner = get_ident_interner();
|
let interner = get_ident_interner();
|
||||||
let span = tok0.sp;
|
let span = tok0.sp;
|
||||||
|
@ -324,7 +324,7 @@ pub fn Parser(sess: @mut ParseSess, cfg: ast::CrateConfig, rdr: @mut reader)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Parser {
|
pub struct Parser {
|
||||||
sess: @mut ParseSess,
|
sess: @ParseSess,
|
||||||
cfg: CrateConfig,
|
cfg: CrateConfig,
|
||||||
// the current token:
|
// the current token:
|
||||||
token: token::Token,
|
token: token::Token,
|
||||||
|
|
|
@ -17,7 +17,7 @@ use parse::token;
|
||||||
|
|
||||||
// map a string to tts, using a made-up filename: return both the token_trees
|
// map a string to tts, using a made-up filename: return both the token_trees
|
||||||
// and the ParseSess
|
// and the ParseSess
|
||||||
pub fn string_to_tts_and_sess (source_str : @str) -> (~[ast::token_tree],@mut ParseSess) {
|
pub fn string_to_tts_and_sess (source_str : @str) -> (~[ast::token_tree],@ParseSess) {
|
||||||
let ps = new_parse_sess(None);
|
let ps = new_parse_sess(None);
|
||||||
(filemap_to_tts(ps,string_to_filemap(ps,source_str,@"bogofile")),ps)
|
(filemap_to_tts(ps,string_to_filemap(ps,source_str,@"bogofile")),ps)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ pub fn string_to_tts(source_str : @str) -> ~[ast::token_tree] {
|
||||||
tts
|
tts
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn string_to_parser_and_sess(source_str: @str) -> (Parser,@mut ParseSess) {
|
pub fn string_to_parser_and_sess(source_str: @str) -> (Parser,@ParseSess) {
|
||||||
let ps = new_parse_sess(None);
|
let ps = new_parse_sess(None);
|
||||||
(new_parser_from_source_str(ps,~[],@"bogofile",source_str),ps)
|
(new_parser_from_source_str(ps,~[],@"bogofile",source_str),ps)
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ pub fn string_to_crate (source_str : @str) -> ast::Crate {
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse a string, return a crate and the ParseSess
|
// parse a string, return a crate and the ParseSess
|
||||||
pub fn string_to_crate_and_sess (source_str : @str) -> (ast::Crate,@mut ParseSess) {
|
pub fn string_to_crate_and_sess (source_str : @str) -> (ast::Crate,@ParseSess) {
|
||||||
let (mut p,ps) = string_to_parser_and_sess(source_str);
|
let (mut p,ps) = string_to_parser_and_sess(source_str);
|
||||||
(p.parse_crate_mod(),ps)
|
(p.parse_crate_mod(),ps)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue