diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-01-19 21:50:20 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-01-19 21:53:24 +0100 |
| commit | 95e6b078fecddeaa3d6f2c920b617201b74bf01e (patch) | |
| tree | 1c03b0b16d614a5a2350dccf71a1eb1e34f9a812 /tests/src/parser.rs | |
| parent | 277f2d2176f5e98305870f90b16af3feae1bb3d1 (diff) | |
Move to non-fatal errors 🪂 [WIP]
- Dynamic models instead of SyntaxTrees
- No more ParseResult/LayoutResult
- Errors and Decorations which are propagated to parent contexts
- Models are finally clonable
Diffstat (limited to 'tests/src/parser.rs')
| -rw-r--r-- | tests/src/parser.rs | 38 |
1 files changed, 9 insertions, 29 deletions
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::<DebugFn>() + Scope::with_fallback::<DebugFn>() } /// 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 { |
