add hygiene support fns, move them around.
also adds test cases
This commit is contained in:
@@ -40,12 +40,19 @@ fn with_error_checking_parse<T>(s: @str, f: &fn(&mut Parser) -> T) -> T {
|
||||
x
|
||||
}
|
||||
|
||||
// parse a string, return a crate.
|
||||
pub fn string_to_crate (source_str : @str) -> @ast::Crate {
|
||||
do with_error_checking_parse(source_str) |p| {
|
||||
p.parse_crate_mod()
|
||||
}
|
||||
}
|
||||
|
||||
// parse a string, return a crate and the ParseSess
|
||||
pub fn string_to_crate_and_sess (source_str : @str) -> (@ast::Crate,@mut ParseSess) {
|
||||
let (p,ps) = string_to_parser_and_sess(source_str);
|
||||
(p.parse_crate_mod(),ps)
|
||||
}
|
||||
|
||||
// parse a string, return an expr
|
||||
pub fn string_to_expr (source_str : @str) -> @ast::Expr {
|
||||
do with_error_checking_parse(source_str) |p| {
|
||||
@@ -60,14 +67,6 @@ pub fn string_to_item (source_str : @str) -> Option<@ast::item> {
|
||||
}
|
||||
}
|
||||
|
||||
// parse a string, return an item and the ParseSess
|
||||
pub fn string_to_item_and_sess (source_str : @str) -> (Option<@ast::item>,@mut ParseSess) {
|
||||
let (p,ps) = string_to_parser_and_sess(source_str);
|
||||
let io = p.parse_item(~[]);
|
||||
p.abort_if_errors();
|
||||
(io,ps)
|
||||
}
|
||||
|
||||
// parse a string, return a stmt
|
||||
pub fn string_to_stmt(source_str : @str) -> @ast::Stmt {
|
||||
do with_error_checking_parse(source_str) |p| {
|
||||
|
||||
Reference in New Issue
Block a user