From fa6c981606b89ebed80b0dd5e829d86cdb3078d8 Mon Sep 17 00:00:00 2001 From: John Clements Date: Tue, 25 Jun 2013 11:40:51 -0700 Subject: add hygiene support fns, move them around. also adds test cases --- src/libsyntax/util/parser_testing.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/libsyntax/util/parser_testing.rs') diff --git a/src/libsyntax/util/parser_testing.rs b/src/libsyntax/util/parser_testing.rs index ca1e53f7fcd..51fd5be71ab 100644 --- a/src/libsyntax/util/parser_testing.rs +++ b/src/libsyntax/util/parser_testing.rs @@ -40,12 +40,19 @@ fn with_error_checking_parse(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| { -- cgit 1.4.1-3-g733a5