From f5b104d0da1c414fb59878d7378add316ee14798 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 5 Dec 2019 20:29:55 +0100 Subject: =?UTF-8?q?Rename=20crate=20`typst`=20->=20`typstc`=20=E2=9C=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/syntax/mod.rs | 6 ++---- src/syntax/parsing.rs | 13 ++++++------- src/syntax/tokens.rs | 1 - 3 files changed, 8 insertions(+), 12 deletions(-) (limited to 'src/syntax') 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, -} +pub struct FuncCall(pub Box); 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 { 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::().unwrap().tree.nodes; + let body = &func.0.downcast::().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) } -- cgit v1.2.3