summaryrefslogtreecommitdiff
path: root/src/syntax/scope.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2020-08-02 22:21:58 +0200
committerLaurenz <laurmaedje@gmail.com>2020-08-02 22:21:58 +0200
commit5a8f2fb73ddafba9fdbe952385ae2676126183ae (patch)
treef65dcc5c8fc3809171e0cc1a985d466159ccb254 /src/syntax/scope.rs
parent266d457292e7461d448f9141030028ea68b573d1 (diff)
Replace body! macro with functions 🧰
Diffstat (limited to 'src/syntax/scope.rs')
-rw-r--r--src/syntax/scope.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/syntax/scope.rs b/src/syntax/scope.rs
index d3092944..8fdad6a0 100644
--- a/src/syntax/scope.rs
+++ b/src/syntax/scope.rs
@@ -3,8 +3,7 @@
use std::collections::HashMap;
use std::fmt::{self, Debug, Formatter};
-use crate::func::ParseFunc;
-use super::parsing::CallParser;
+use super::parsing::{CallParser, ParseCall};
use super::tree::DynamicNode;
/// A map from identifiers to function parsers.
@@ -17,7 +16,7 @@ impl Scope {
/// Create a new empty scope with a fallback parser that is invoked when no
/// match is found.
pub fn new<F>() -> Scope
- where F: ParseFunc<Meta=()> + DynamicNode + 'static {
+ where F: ParseCall<Meta=()> + DynamicNode + 'static {
Scope {
parsers: HashMap::new(),
fallback: make_parser::<F>(()),
@@ -31,14 +30,14 @@ impl Scope {
/// Associate the given name with a type that is parseable into a function.
pub fn add<F>(&mut self, name: &str)
- where F: ParseFunc<Meta=()> + DynamicNode + 'static {
+ where F: ParseCall<Meta=()> + DynamicNode + 'static {
self.add_with_meta::<F>(name, ());
}
/// Add a parseable type with additional metadata that is given to the
/// parser (other than the default of `()`).
- pub fn add_with_meta<F>(&mut self, name: &str, metadata: <F as ParseFunc>::Meta)
- where F: ParseFunc + DynamicNode + 'static {
+ pub fn add_with_meta<F>(&mut self, name: &str, metadata: <F as ParseCall>::Meta)
+ where F: ParseCall + DynamicNode + 'static {
self.parsers.insert(
name.to_string(),
make_parser::<F>(metadata),
@@ -64,8 +63,8 @@ impl Debug for Scope {
}
}
-fn make_parser<F>(metadata: <F as ParseFunc>::Meta) -> Box<CallParser>
-where F: ParseFunc + DynamicNode + 'static {
+fn make_parser<F>(metadata: <F as ParseCall>::Meta) -> Box<CallParser>
+where F: ParseCall + DynamicNode + 'static {
Box::new(move |f, s| {
F::parse(f, s, metadata.clone())
.map(|tree| Box::new(tree) as Box<dyn DynamicNode>)