From bc1b4216a802d09e8d00dd277a0e204d49bcaa7f Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 30 Sep 2020 12:38:02 +0200 Subject: =?UTF-8?q?Reorganize=20syntax=20types=20into=20two=20modules=20?= =?UTF-8?q?=F0=9F=93=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/syntax/mod.rs | 57 +++++++++---------------------------------------------- 1 file changed, 9 insertions(+), 48 deletions(-) (limited to 'src/syntax/mod.rs') diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs index 70935e79..1b9f8ba8 100644 --- a/src/syntax/mod.rs +++ b/src/syntax/mod.rs @@ -1,50 +1,11 @@ -//! Syntax trees, parsing and tokenization. +//! Syntax types. -pub mod decoration; -pub mod parsing; -pub mod span; -pub mod tokens; -pub mod tree; +mod decoration; +mod span; +mod token; +mod tree; -#[cfg(test)] -mod tests { - use super::span; - use crate::prelude::*; - use std::fmt::Debug; - - /// Assert that expected and found are equal, printing both and panicking - /// and the source of their test case if they aren't. - /// - /// When `cmp_spans` is false, spans are ignored. - pub fn check(src: &str, exp: T, found: T, cmp_spans: bool) - where - T: Debug + PartialEq, - { - span::set_cmp(cmp_spans); - let equal = exp == found; - span::set_cmp(true); - - if !equal { - println!("source: {:?}", src); - if cmp_spans { - println!("expected: {:#?}", exp); - println!("found: {:#?}", found); - } else { - println!("expected: {:?}", exp); - println!("found: {:?}", found); - } - panic!("test failed"); - } - } - - pub fn s(sl: usize, sc: usize, el: usize, ec: usize, v: T) -> Spanned { - Spanned::new(v, Span::new(Pos::new(sl, sc), Pos::new(el, ec))) - } - - // Enables tests to optionally specify spans. - impl From for Spanned { - fn from(t: T) -> Self { - Spanned::zero(t) - } - } -} +pub use decoration::*; +pub use span::*; +pub use token::*; +pub use tree::*; -- cgit v1.2.3