diff options
| author | Martin Haug <mhaug@live.de> | 2021-10-31 15:01:39 +0100 |
|---|---|---|
| committer | Martin Haug <mhaug@live.de> | 2021-11-05 13:44:49 +0100 |
| commit | 1c0ac793d2b9c403f1a8fa60a3748f4ff8623acb (patch) | |
| tree | a101236a3e7b8e3407fa9bfc5e8df739e21ab942 /src/syntax | |
| parent | 84d35efee38d137a77e368c50421ac24327371c6 (diff) | |
Slim `NodeKind` memory footprint
Diffstat (limited to 'src/syntax')
| -rw-r--r-- | src/syntax/mod.rs | 6 | ||||
| -rw-r--r-- | src/syntax/token.rs | 22 |
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>, } |
