diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-12-05 20:29:55 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-12-05 20:29:55 +0100 |
| commit | f5b104d0da1c414fb59878d7378add316ee14798 (patch) | |
| tree | 56968591bd997aa78cb8690da318ee97a822f2a9 /src/syntax | |
| parent | 72a9631b038d1a60e4e4a78e92cd69e6f8ce4316 (diff) | |
Rename crate `typst` -> `typstc` ✏
Diffstat (limited to 'src/syntax')
| -rw-r--r-- | src/syntax/mod.rs | 6 | ||||
| -rw-r--r-- | src/syntax/parsing.rs | 13 | ||||
| -rw-r--r-- | src/syntax/tokens.rs | 1 |
3 files changed, 8 insertions, 12 deletions
diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs index 21088b83..a3fe06bd 100644 --- a/src/syntax/mod.rs +++ b/src/syntax/mod.rs @@ -91,13 +91,11 @@ pub enum Node { /// An invocation of a function. #[derive(Debug)] -pub struct FuncCall { - pub call: Box<dyn LayoutFunc>, -} +pub struct FuncCall(pub Box<dyn LayoutFunc>); impl PartialEq for FuncCall { fn eq(&self, other: &FuncCall) -> bool { - &self.call == &other.call + &self.0 == &other.0 } } diff --git a/src/syntax/parsing.rs b/src/syntax/parsing.rs index 3527e6b1..8245904c 100644 --- a/src/syntax/parsing.rs +++ b/src/syntax/parsing.rs @@ -6,7 +6,6 @@ use crate::size::Size; use super::*; /// Parses source code into a syntax tree given a context. -#[inline] pub fn parse(src: &str, ctx: ParseContext) -> ParseResult<SyntaxTree> { Parser::new(src, ctx).parse() } @@ -105,11 +104,11 @@ impl<'s> Parser<'s> { _ => error!("expected arguments or closing bracket"), }; - let call = self.parse_func_call(name, args)?; + let func = FuncCall(self.parse_func_call(name, args)?); span.end = self.tokens.string_index(); // Finally this function is parsed to the end. - self.append(Node::Func(FuncCall { call }), span); + self.append(Node::Func(func), span); Ok(()) } @@ -531,13 +530,13 @@ mod tests { /// Shortcut macro to create a function. macro_rules! func { () => ( - FuncCall { call: Box::new(BodylessFn(vec![], vec![])) } + FuncCall(Box::new(BodylessFn(vec![], vec![]))) ); (body: $tree:expr $(,)*) => ( - FuncCall { call: Box::new(TreeFn { tree: $tree }) } + FuncCall(Box::new(TreeFn { tree: $tree })) ); (args: $pos:expr, $key:expr) => ( - FuncCall { call: Box::new(BodylessFn($pos, $key)) } + FuncCall(Box::new(BodylessFn($pos, $key))) ); } @@ -710,7 +709,7 @@ mod tests { assert_eq!(tree[2].span.pair(), (5, 37)); let func = if let Node::Func(f) = &tree[2].v { f } else { panic!() }; - let body = &func.call.downcast::<TreeFn>().unwrap().tree.nodes; + let body = &func.0.downcast::<TreeFn>().unwrap().tree.nodes; assert_eq!(body[0].span.pair(), (0, 4)); assert_eq!(body[1].span.pair(), (4, 5)); assert_eq!(body[2].span.pair(), (5, 6)); diff --git a/src/syntax/tokens.rs b/src/syntax/tokens.rs index f5609b59..4fdee371 100644 --- a/src/syntax/tokens.rs +++ b/src/syntax/tokens.rs @@ -3,7 +3,6 @@ use smallvec::SmallVec; use super::*; /// Builds an iterator over the tokens of the source code. -#[inline] pub fn tokenize(src: &str) -> Tokens { Tokens::new(src) } |
