diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-08-02 22:21:58 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-08-02 22:21:58 +0200 |
| commit | 5a8f2fb73ddafba9fdbe952385ae2676126183ae (patch) | |
| tree | f65dcc5c8fc3809171e0cc1a985d466159ccb254 /src/syntax/parsing.rs | |
| parent | 266d457292e7461d448f9141030028ea68b573d1 (diff) | |
Replace body! macro with functions 🧰
Diffstat (limited to 'src/syntax/parsing.rs')
| -rw-r--r-- | src/syntax/parsing.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/syntax/parsing.rs b/src/syntax/parsing.rs index 7594c14d..bcbcb8d4 100644 --- a/src/syntax/parsing.rs +++ b/src/syntax/parsing.rs @@ -13,6 +13,27 @@ use super::tree::{SyntaxTree, SyntaxNode, DynamicNode}; /// A function which parses a function call into a tree. pub type CallParser = dyn Fn(FuncCall, &ParseState) -> Pass<Box<dyn DynamicNode>>; +/// Parse a function call. +pub trait ParseCall { + /// A metadata type whose value is passed into the function parser. This + /// allows a single function to do different things depending on the value + /// that needs to be given when inserting the function into a + /// [scope](crate::syntax::Scope). + /// + /// For example, the functions `word.spacing`, `line.spacing` and + /// `par.spacing` are actually all the same function + /// [`ContentSpacingFunc`](crate::library::ContentSpacingFunc) with the + /// metadata specifiy which content should be spaced. + type Meta: Clone; + + /// Parse the header and body into this function given a context. + fn parse( + header: FuncCall, + state: &ParseState, + metadata: Self::Meta, + ) -> Pass<Self> where Self: Sized; +} + /// An invocation of a function. #[derive(Debug, Clone, PartialEq)] pub struct FuncCall<'s> { |
