summary refs log tree commit diff stats
path: root/src/pattern.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/pattern.rs')
-rw-r--r--src/pattern.rs17
1 files changed, 15 insertions, 2 deletions
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 <https://www.gnu.org/licenses/>.
  */
 
+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<T: PatternTypes> {
 }
 
 impl<T: PatternTypes> Pattern<T> {
-    pub fn compile(s: &str, defs: Option<()>/*TODO*/) -> Result<Self, PatternError> {
+    /// Compiles the input into a pattern.
+    pub fn compile<'s, P, O>(
+        input: &'s str,
+        preds: Option<BTreeMap<P, Box<Predicate<T>>>>,
+        objs: Option<BTreeMap<O, T::Own>>
+    ) -> Result<Self, PatternError<'s>>
+        where
+            P: Borrow<str> + Ord,
+            O: Borrow<str> + Ord,
+    {
         Ok(Self {
-            consts: parse(s, defs)?
+            consts: parse(input, preds, objs)?
         })
     }