about summary refs log tree commit diff
path: root/src/rustdoc/parse.rs
blob: aab938e44433ed6dd9fa955a813184ccf9bbb20f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import rustc::driver::diagnostic;
import rustc::syntax::ast;
import rustc::syntax::codemap;
import rustc::syntax::parse::parser;

export from_file, from_str;

fn new_parse_sess() -> parser::parse_sess {
    let cm = codemap::new_codemap();
    let sess = @{
        cm: cm,
        mutable next_id: 0,
        diagnostic: diagnostic::mk_handler(cm, none)
    };
    ret sess;
}

fn from_file(file: str) -> @ast::crate {
    parser::parse_crate_from_file(
        file, [], new_parse_sess())
}

fn from_str(source: str) -> @ast::crate {
    parser::parse_crate_from_source_str(
        "-", source, [], new_parse_sess())
}