From 69652efe8ad9738a94fef571c8b81e342f96e7b4 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Sun, 7 Feb 2021 22:19:21 -0300 Subject: Finish porting parser --- src/pattern.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/pattern.rs') diff --git a/src/pattern.rs b/src/pattern.rs index e0a5174..3349db8 100644 --- a/src/pattern.rs +++ b/src/pattern.rs @@ -16,8 +16,12 @@ * along with this program. If not, see . */ +use std::borrow::Borrow; +use std::collections::BTreeMap; + use crate::PatternTypes; use crate::RefOwn; +use crate::Predicate; use crate::errors::PatternError; use crate::parser::parse; use crate::vm::Matcher; @@ -29,9 +33,18 @@ pub struct Pattern { } impl Pattern { - pub fn compile(s: &str, defs: Option<()>/*TODO*/) -> Result { + /// Compiles the input into a pattern. + pub fn compile<'s, P, O>( + input: &'s str, + preds: Option>>>, + objs: Option> + ) -> Result> + where + P: Borrow + Ord, + O: Borrow + Ord, + { Ok(Self { - consts: parse(s, defs)? + consts: parse(input, preds, objs)? }) } -- cgit 1.4.1