syntex_syntax 0.9.0

Export of libsyntax for code generation
1
2
3
4
5
6
7
8
9
10
11
12
b0VIM 7.4�U�\~ericktErick-Tryzelaar-MBP.local~erickt/projects/rust/rust-syntex/syntex_syntax/src/ext/source_util.rsutf-8
3210#"! Utpc^d�ad/�c�{XU��M)(�
�
�
�
�
�
�

Z
Y
F
-


���{UT$��xwO�
�
�
�
T
 
�	�	�	�	�	B	@	?		��e0���_&$#��uL��O0���td-+*���V����NB	��                                        cx.cfg(),        parse::new_sub_parser_from_file(cx.parse_sess(),    let p =    // The file will be added to the code map by the parser    };        None => return DummyResult::expr(sp),        Some(f) => f,    let file = match get_single_str_from_tts(cx, sp, tts, "include!") {                           -> Box<base::MacResult+'cx> {pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])/// unhygienically./// This is generally a bad idea because it's going to behave/// include! : parse the given file as an expr}            token::intern_and_get_ident(&string[..])))            sp,    base::MacEager::expr(cx.expr_str(                   .connect("::");                   .collect::<Vec<String>>()                   .map(|x| x.to_string())                   .iter()    let string = cx.mod_path()    base::check_zero_tts(cx, sp, tts, "module_path!");                  -> Box<base::MacResult+'static> {pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])}                                   token::intern_and_get_ident(&s[..])))    base::MacEager::expr(cx.expr_str(sp,    let s = pprust::tts_to_string(tts);                        -> Box<base::MacResult+'static> {pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])}    base::MacEager::expr(cx.expr_str(topmost, filename))    let filename = token::intern_and_get_ident(&loc.file.name);    let loc = cx.codemap().lookup_char_pos(topmost.lo);    let topmost = cx.expansion_cause();    base::check_zero_tts(cx, sp, tts, "file!");                   -> Box<base::MacResult+'static> {pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])/// out if we wanted./// The filemap (`loc.file`) contains a bunch more information we could spit/// file!(): expands to the current filename */}    base::MacEager::expr(cx.expr_u32(topmost, loc.col.to_usize() as u32))    let loc = cx.codemap().lookup_char_pos(topmost.lo);    let topmost = cx.expansion_cause();    base::check_zero_tts(cx, sp, tts, "column!");                  -> Box<base::MacResult+'static> {pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])/* column!(): expands to the current column number */}    base::MacEager::expr(cx.expr_u32(topmost, loc.line as u32))    let loc = cx.codemap().lookup_char_pos(topmost.lo);    let topmost = cx.expansion_cause();    base::check_zero_tts(cx, sp, tts, "line!");                   -> Box<base::MacResult+'static> {pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])/// line!(): expands to the current line number// a given file into the current one.// the column/row/filename of the expression, or they include// These macros all relate to the file system; they either returnuse std::rc::Rc;use std::path::{Path, PathBuf};use std::io::prelude::*;use std::fs::File;use util::small_vector::SmallVector;use ptr::P;use print::pprust;use parse;use parse::token;use ext::build::AstBuilder;use ext::base;use ext::base::*;use codemap;use codemap::{Pos, Span};use ast;// except according to those terms.// option. This file may not be copied, modified, or distributed// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or//// http://rust-lang.org/COPYRIGHT.// file at the top-level directory of this distribution and at// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHTad�
D�����R
���~sfLFDC}    }        arg.to_path_buf()    } else {        cu        cu.push(arg);        cu.pop();        let mut cu = PathBuf::from(&cx.codemap().span_to_filename(sp));    if !arg.is_absolute() {    // NB: relative paths are resolved relative to the compilation unitfn res_rel_file(cx: &mut ExtCtxt, sp: codemap::Span, arg: &Path) -> PathBuf {// isn't already)// resolve a file-system path to an absolute file-system path (if it}    }ad�^��C����uo;�
�
�
�
G

���U0����{e[UT0.-�
�
Y

�	�	�	�	l	"	
	���tO%���i/���oeQ5�������;���le.���F��n4����        }            base::MacEager::expr(cx.expr_lit(sp, ast::LitBinary(Rc::new(bytes))))            cx.codemap().new_filemap_and_lines(&filename, "");            let filename = format!("{}", file.display());            // dependency information, but don't enter it's contents            // Add this input file to the code map to make it available as        Ok(..) => {        }            return DummyResult::expr(sp);                        &format!("couldn't read {}: {}", file.display(), e));            cx.span_err(sp,        Err(e) => {    match File::open(&file).and_then(|mut f| f.read_to_end(&mut bytes)) {    let mut bytes = Vec::new();    let file = res_rel_file(cx, sp, Path::new(&file));    };        None => return DummyResult::expr(sp)        Some(f) => f,    let file = match get_single_str_from_tts(cx, sp, tts, "include_bytes!") {                            -> Box<base::MacResult+'static> {pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])}    }        }            return DummyResult::expr(sp);                                file.display()));                        &format!("{} wasn't a utf-8 file",            cx.span_err(sp,        Err(_) => {        }            base::MacEager::expr(cx.expr_str(sp, interned))            cx.codemap().new_filemap_and_lines(&filename, &src);            let interned = token::intern_and_get_ident(&src[..]);            let filename = format!("{}", file.display());            // dependency information            // Add this input file to the code map to make it available as        Ok(src) => {    match String::from_utf8(bytes) {    };        }            return DummyResult::expr(sp);                                e));                                file.display(),                        &format!("couldn't read {}: {}",            cx.span_err(sp,        Err(e) => {        Ok(..) => {}    match File::open(&file).and_then(|mut f| f.read_to_end(&mut bytes)) {    let mut bytes = Vec::new();    let file = res_rel_file(cx, sp, Path::new(&file));    };        None => return DummyResult::expr(sp)        Some(f) => f,    let file = match get_single_str_from_tts(cx, sp, tts, "include_str!") {                          -> Box<base::MacResult+'static> {pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])// include_str! : read the given file, insert it as a literal string expr}    Box::new(ExpandResult { p: p })    }        }            Some(ret)            }                }                    ))                                 self.p.this_token_to_string())                        &format!("expected item, found `{}`",                        self.p.span,                    None => panic!(self.p.span_fatal(                    Some(item) => ret.push(item),                match self.p.parse_item() {            while self.p.token != token::Eof {            let mut ret = SmallVector::zero();                      -> Option<SmallVector<P<ast::Item>>> {        fn make_items(mut self: Box<ExpandResult<'a>>)        }            Some(self.p.parse_expr())        fn make_expr(mut self: Box<ExpandResult<'a>>) -> Option<P<ast::Expr>> {    impl<'a> base::MacResult for ExpandResult<'a> {    }        p: parse::parser::Parser<'a>,    struct ExpandResult<'a> {                                        sp);                                        None,                                        true,                                                      Path::new(&file)),                                                      sp,                                        &res_rel_file(cx,