From 30f16bbf6431ca0c174ca0a1abaa6a13ef50ab06 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 16 Aug 2020 22:14:27 +0200 Subject: =?UTF-8?q?Add=20Value=20type=20and=20replace=20dyn-nodes=20with?= =?UTF-8?q?=20call-exprs=20=F0=9F=8F=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - In addition to syntax trees there are now `Value`s, which syntax trees can be evaluated into (e.g. the tree is `5+5` and the value is `10`) - Parsing is completely pure, function calls are not parsed into nodes, but into simple call expressions, which are resolved later - Functions aren't dynamic nodes anymore, but simply functions which receive their arguments as a table and the layouting context - Functions may return any `Value` - Layouting is powered by functions which return the new `Commands` value, which informs the layouting engine what to do - When a function returns a non-`Commands` value, the layouter simply dumps the value into the document in monospace --- src/syntax/span.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/syntax/span.rs') diff --git a/src/syntax/span.rs b/src/syntax/span.rs index 923d13c2..89f773c7 100644 --- a/src/syntax/span.rs +++ b/src/syntax/span.rs @@ -39,13 +39,11 @@ impl Offset for SpanVec { } /// A value with the span it corresponds to in the source code. -#[derive(Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize))] pub struct Spanned { - /// The value. - pub v: T, - /// The corresponding span. pub span: Span, + pub v: T, } impl Spanned { @@ -99,7 +97,7 @@ impl Debug for Spanned { } /// Locates a slice of source code. -#[derive(Copy, Clone, Hash)] +#[derive(Copy, Clone, Ord, PartialOrd, Hash)] #[cfg_attr(feature = "serialize", derive(Serialize))] pub struct Span { /// The inclusive start position. -- cgit v1.2.3