mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Add a syntax tree expression kind 🎍
This allows bodies to be passed as regular arguments.
This commit is contained in:
parent
1fb2d5103d
commit
650c712eab
@ -9,6 +9,7 @@ use crate::length::Length;
|
|||||||
use crate::Feedback;
|
use crate::Feedback;
|
||||||
use super::span::{SpanVec, Spanned};
|
use super::span::{SpanVec, Spanned};
|
||||||
use super::tokens::is_identifier;
|
use super::tokens::is_identifier;
|
||||||
|
use super::tree::SyntaxTree;
|
||||||
use super::value::Value;
|
use super::value::Value;
|
||||||
|
|
||||||
/// An expression.
|
/// An expression.
|
||||||
@ -26,6 +27,8 @@ pub enum Expr {
|
|||||||
Length(Length),
|
Length(Length),
|
||||||
/// A color value with alpha channel: `#f79143ff`.
|
/// A color value with alpha channel: `#f79143ff`.
|
||||||
Color(RgbaColor),
|
Color(RgbaColor),
|
||||||
|
/// A syntax tree containing typesetting content.
|
||||||
|
Tree(SyntaxTree),
|
||||||
/// A tuple: `(false, 12cm, "hi")`.
|
/// A tuple: `(false, 12cm, "hi")`.
|
||||||
Tuple(Tuple),
|
Tuple(Tuple),
|
||||||
/// A named tuple: `cmyk(37.7, 0, 3.9, 1.1)`.
|
/// A named tuple: `cmyk(37.7, 0, 3.9, 1.1)`.
|
||||||
@ -56,6 +59,7 @@ impl Expr {
|
|||||||
Number(_) => "number",
|
Number(_) => "number",
|
||||||
Length(_) => "length",
|
Length(_) => "length",
|
||||||
Color(_) => "color",
|
Color(_) => "color",
|
||||||
|
Tree(_) => "syntax tree",
|
||||||
Tuple(_) => "tuple",
|
Tuple(_) => "tuple",
|
||||||
NamedTuple(_) => "named tuple",
|
NamedTuple(_) => "named tuple",
|
||||||
Object(_) => "object",
|
Object(_) => "object",
|
||||||
@ -78,6 +82,7 @@ impl Debug for Expr {
|
|||||||
Number(n) => n.fmt(f),
|
Number(n) => n.fmt(f),
|
||||||
Length(s) => s.fmt(f),
|
Length(s) => s.fmt(f),
|
||||||
Color(c) => c.fmt(f),
|
Color(c) => c.fmt(f),
|
||||||
|
Tree(t) => t.fmt(f),
|
||||||
Tuple(t) => t.fmt(f),
|
Tuple(t) => t.fmt(f),
|
||||||
NamedTuple(t) => t.fmt(f),
|
NamedTuple(t) => t.fmt(f),
|
||||||
Object(o) => o.fmt(f),
|
Object(o) => o.fmt(f),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user