From 95e6b078fecddeaa3d6f2c920b617201b74bf01e Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 19 Jan 2020 21:50:20 +0100 Subject: =?UTF-8?q?Move=20to=20non-fatal=20errors=20=F0=9F=AA=82=20[WIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Dynamic models instead of SyntaxTrees - No more ParseResult/LayoutResult - Errors and Decorations which are propagated to parent contexts - Models are finally clonable --- tests/src/parser.rs | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) (limited to 'tests/src/parser.rs') diff --git a/tests/src/parser.rs b/tests/src/parser.rs index b2aa01da..550090a8 100644 --- a/tests/src/parser.rs +++ b/tests/src/parser.rs @@ -107,23 +107,22 @@ macro_rules! case { (ps $($rest:tt)*) => (case!(@parse PartialEq::eq, $($rest)*)); (@parse $cmp:expr, $src:expr, [$($e:tt)*]) => ({ - let expected = SyntaxTree { nodes: list!(nodes [$($e)*]) }; + let expected = SyntaxModel { nodes: list!(nodes [$($e)*]) }; let found = parse($src, ParseContext { scope: &scope() }).0; ($cmp(&found, &expected), expected, found) }); (c $src:expr, [$($e:tt)*]) => ({ - let expected = Colorization { tokens: list!(colors [$($e)*]) }; + let expected = Colorization { tokens: list!(decorations [$($e)*]) }; let found = parse($src, ParseContext { scope: &scope() }).1; (expected == found, expected, found) }); (e $src:expr, [$($e:tt)*]) => ({ - let errors = list!([$($e)*]).into_iter() + let expected = list!([$($e)*]).into_iter() .map(|s| s.map(|m| m.to_string())) .collect(); - let expected = ErrorMap { errors }; let found = parse($src, ParseContext { scope: &scope() }).2; (expected == found, expected, found) }); @@ -131,7 +130,7 @@ macro_rules! case { /// A scope containing the `DebugFn` as a fallback. fn scope() -> Scope { - Scope::with_debug::() + Scope::with_fallback::() } /// Parses possibly-spanned lists of token or node expressions. @@ -182,7 +181,7 @@ macro_rules! func { $(positional = list!(expr [$($p)*]);)? $(keyword = list!(expr [$($k)*]);)? - Node::Func(FuncCall(Box::new(DebugFn { + Node::Model(Box::new(DebugFn { header: FuncHeader { name: zspan(Ident($name.to_string())), args: FuncArgs { @@ -191,10 +190,10 @@ macro_rules! func { }, }, body: func!(@body $($b)*), - }))) + })) }); - (@body Some($($b:tt)*)) => (Some(SyntaxTree { nodes: list!(nodes $($b)*) })); + (@body Some($($b:tt)*)) => (Some(SyntaxModel{ nodes: list!(nodes $($b)*) })); (@body None) => (None); } @@ -270,27 +269,8 @@ mod cuts { } } - pub mod colors { - pub use typstc::syntax::ColorToken::{ - Comment as C, - Bracket as B, - FuncName as FN, - Colon as CL, - Key as K, - Equals as EQ, - Comma as CM, - Paren as P, - Brace as BR, - ExprIdent as ID, - ExprStr as STR, - ExprNumber as NUM, - ExprSize as SIZE, - ExprBool as BOOL, - Bold as BD, - Italic as IT, - Monospace as MS, - Invalid as INV, - }; + pub mod decorations { + pub use typstc::syntax::Decoration::*; } pub mod expr { -- cgit v1.2.3