From 956353cd80cc6335fc0e9f2aefe5494afa67be97 Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 8 Mar 2019 01:15:19 -0800 Subject: [PATCH] Move rc! macro to util So it can be used anywhere --- schala-lang/language/src/lib.rs | 4 +++- schala-lang/language/src/parsing.rs | 3 --- schala-lang/language/src/symbol_table.rs | 2 +- schala-lang/language/src/util.rs | 4 ++++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/schala-lang/language/src/lib.rs b/schala-lang/language/src/lib.rs index 24d75ef..7396303 100644 --- a/schala-lang/language/src/lib.rs +++ b/schala-lang/language/src/lib.rs @@ -30,8 +30,10 @@ macro_rules! bx { } #[macro_use] -mod typechecking; mod util; +#[macro_use] +mod typechecking; + mod tokenizing; mod ast; mod parsing; diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index 4b422f6..08bd58e 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -1138,9 +1138,6 @@ mod parse_tests { parser.parse() } - macro_rules! rc { - ($string:tt) => { Rc::new(stringify!($string).to_string()) } - } macro_rules! parse_test { ($string:expr, $correct:expr) => { assert_eq!(parse($string).unwrap(), $correct) }; } diff --git a/schala-lang/language/src/symbol_table.rs b/schala-lang/language/src/symbol_table.rs index 313bc05..0a370de 100644 --- a/schala-lang/language/src/symbol_table.rs +++ b/schala-lang/language/src/symbol_table.rs @@ -202,7 +202,7 @@ mod symbol_table_tests { #[test] fn basic_symbol_table() { - values_in_table! { "let a = 10; fn b() { 20 }", &Rc::new("b".to_string()) }; + values_in_table! { "let a = 10; fn b() { 20 }", &rc!(b) }; } } diff --git a/schala-lang/language/src/util.rs b/schala-lang/language/src/util.rs index 69d8749..111868f 100644 --- a/schala-lang/language/src/util.rs +++ b/schala-lang/language/src/util.rs @@ -47,3 +47,7 @@ pub fn quick_ast(input: &str) -> crate::ast::AST { let mut parser = crate::parsing::Parser::new(tokens); parser.parse().unwrap() } + +macro_rules! rc { + ($string:tt) => { Rc::new(stringify!($string).to_string()) } +}