diff options
| author | cAttte <26514199+cAttte@users.noreply.github.com> | 2025-06-12 11:09:37 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-12 14:09:37 +0000 |
| commit | f9897479d2a8a865c4033bc44ec9a85fb5000795 (patch) | |
| tree | 498f159589cb1cf14c171a31750189023cad8327 /crates/typst-eval | |
| parent | bd41fb9427f3965b91ac467fe12045bbb793b5e9 (diff) | |
Unify `EvalMode` and `LexMode` into `SyntaxMode` (#6432)
Diffstat (limited to 'crates/typst-eval')
| -rw-r--r-- | crates/typst-eval/src/lib.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/crates/typst-eval/src/lib.rs b/crates/typst-eval/src/lib.rs index 586da26b..e4bbe4f0 100644 --- a/crates/typst-eval/src/lib.rs +++ b/crates/typst-eval/src/lib.rs @@ -18,7 +18,6 @@ pub use self::call::{eval_closure, CapturesVisitor}; pub use self::flow::FlowEvent; pub use self::import::import; pub use self::vm::Vm; -pub use typst_library::routines::EvalMode; use self::access::*; use self::binding::*; @@ -32,7 +31,7 @@ use typst_library::introspection::Introspector; use typst_library::math::EquationElem; use typst_library::routines::Routines; use typst_library::World; -use typst_syntax::{ast, parse, parse_code, parse_math, Source, Span}; +use typst_syntax::{ast, parse, parse_code, parse_math, Source, Span, SyntaxMode}; /// Evaluate a source file and return the resulting module. #[comemo::memoize] @@ -104,13 +103,13 @@ pub fn eval_string( sink: TrackedMut<Sink>, string: &str, span: Span, - mode: EvalMode, + mode: SyntaxMode, scope: Scope, ) -> SourceResult<Value> { let mut root = match mode { - EvalMode::Code => parse_code(string), - EvalMode::Markup => parse(string), - EvalMode::Math => parse_math(string), + SyntaxMode::Code => parse_code(string), + SyntaxMode::Markup => parse(string), + SyntaxMode::Math => parse_math(string), }; root.synthesize(span); @@ -141,11 +140,11 @@ pub fn eval_string( // Evaluate the code. let output = match mode { - EvalMode::Code => root.cast::<ast::Code>().unwrap().eval(&mut vm)?, - EvalMode::Markup => { + SyntaxMode::Code => root.cast::<ast::Code>().unwrap().eval(&mut vm)?, + SyntaxMode::Markup => { Value::Content(root.cast::<ast::Markup>().unwrap().eval(&mut vm)?) } - EvalMode::Math => Value::Content( + SyntaxMode::Math => Value::Content( EquationElem::new(root.cast::<ast::Math>().unwrap().eval(&mut vm)?) .with_block(false) .pack() |
