summaryrefslogtreecommitdiff
path: root/src/syntax
diff options
context:
space:
mode:
authorMartin Haug <mhaug@live.de>2021-10-31 15:01:39 +0100
committerMartin Haug <mhaug@live.de>2021-11-05 13:44:49 +0100
commit1c0ac793d2b9c403f1a8fa60a3748f4ff8623acb (patch)
treea101236a3e7b8e3407fa9bfc5e8df739e21ab942 /src/syntax
parent84d35efee38d137a77e368c50421ac24327371c6 (diff)
Slim `NodeKind` memory footprint
Diffstat (limited to 'src/syntax')
-rw-r--r--src/syntax/mod.rs6
-rw-r--r--src/syntax/token.rs22
2 files changed, 4 insertions, 24 deletions
diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs
index 8e04a569..ca5b6a1b 100644
--- a/src/syntax/mod.rs
+++ b/src/syntax/mod.rs
@@ -121,12 +121,12 @@ pub enum NodeKind {
Text(EcoString),
/// A slash and the letter "u" followed by a hexadecimal unicode entity
/// enclosed in curly braces: `\u{1F5FA}`.
- UnicodeEscape(UnicodeEscapeToken),
+ UnicodeEscape(Rc<UnicodeEscapeToken>),
/// An arbitrary number of backticks followed by inner contents, terminated
/// with the same number of backticks: `` `...` ``.
- Raw(RawToken),
+ Raw(Rc<RawToken>),
/// Dollar signs surrounding inner contents.
- Math(MathToken),
+ Math(Rc<MathToken>),
/// A numbering: `23.`.
///
/// Can also exist without the number: `.`.
diff --git a/src/syntax/token.rs b/src/syntax/token.rs
index 49613667..5a621495 100644
--- a/src/syntax/token.rs
+++ b/src/syntax/token.rs
@@ -2,15 +2,10 @@ use crate::util::EcoString;
/// A quoted string token: `"..."`.
#[derive(Debug, Clone, PartialEq)]
+#[repr(transparent)]
pub struct StrToken {
/// The string inside the quotes.
- ///
- /// _Note_: If the string contains escape sequences these are not yet
- /// applied to be able to just store a string slice here instead of
- /// a `String`. The resolving is done later in the parser.
pub string: EcoString,
- /// Whether the closing quote was present.
- pub terminated: bool,
}
/// A raw block token: `` `...` ``.
@@ -22,8 +17,6 @@ pub struct RawToken {
pub lang: Option<EcoString>,
/// The number of opening backticks.
pub backticks: u8,
- /// Whether all closing backticks were present.
- pub terminated: bool,
/// Whether to display this as a block.
pub block: bool,
}
@@ -36,8 +29,6 @@ pub struct MathToken {
/// Whether the formula is display-level, that is, it is surrounded by
/// `$[..]`.
pub display: bool,
- /// Whether the closing dollars were present.
- pub terminated: bool,
}
/// A unicode escape sequence token: `\u{1F5FA}`.
@@ -47,15 +38,4 @@ pub struct UnicodeEscapeToken {
pub sequence: EcoString,
/// The resulting unicode character.
pub character: Option<char>,
- /// Whether the closing brace was present.
- pub terminated: bool,
-}
-
-/// A unit-bound number token: `1.2em`.
-#[derive(Debug, Clone, PartialEq)]
-pub struct UnitToken {
- /// The number part.
- pub number: std::ops::Range<usize>,
- /// The unit part.
- pub unit: std::ops::Range<usize>,
}