From ca4090fe348622086ba0bfb3b86a5daa70401b5d Mon Sep 17 00:00:00 2001 From: Innokenty Date: Thu, 28 Nov 2024 15:12:06 +0300 Subject: [PATCH] fixes after Vitaly's review --- lib/src/metta/runner/stdlib/core.rs | 4 ++-- lib/src/metta/runner/stdlib/debug.rs | 5 ++++- lib/src/metta/runner/stdlib/mod.rs | 4 ++-- lib/src/metta/runner/stdlib/package.rs | 3 --- lib/src/metta/runner/stdlib/random.rs | 3 --- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/src/metta/runner/stdlib/core.rs b/lib/src/metta/runner/stdlib/core.rs index 3fc9e4772..b6b6349a3 100644 --- a/lib/src/metta/runner/stdlib/core.rs +++ b/lib/src/metta/runner/stdlib/core.rs @@ -366,6 +366,8 @@ pub fn register_common_tokens(tref: &mut Tokenizer) { tref.register_token(regex(r"nop"), move |_| { nop_op.clone() }); let match_op = Atom::gnd(MatchOp{}); tref.register_token(regex(r"match"), move |_| { match_op.clone() }); + let sealed_op = Atom::gnd(SealedOp{}); + tref.register_token(regex(r"sealed"), move |_| { sealed_op.clone() }); } pub fn register_runner_tokens(tref: &mut Tokenizer, space: &DynSpace, metta: &Metta) { @@ -379,8 +381,6 @@ pub fn register_runner_tokens(tref: &mut Tokenizer, space: &DynSpace, metta: &Me tref.register_token(regex(r"capture"), move |_| { capture_op.clone() }); let pragma_op = Atom::gnd(PragmaOp::new(metta.settings().clone())); tref.register_token(regex(r"pragma!"), move |_| { pragma_op.clone() }); - let sealed_op = Atom::gnd(SealedOp{}); - tref.register_token(regex(r"sealed"), move |_| { sealed_op.clone() }); } pub fn register_rust_stdlib_tokens(tref: &mut Tokenizer) { diff --git a/lib/src/metta/runner/stdlib/debug.rs b/lib/src/metta/runner/stdlib/debug.rs index fb72bf654..5f8006784 100644 --- a/lib/src/metta/runner/stdlib/debug.rs +++ b/lib/src/metta/runner/stdlib/debug.rs @@ -179,11 +179,14 @@ impl CustomExecute for AssertEqualToResultOp { } } -pub fn register_runner_tokens(tref: &mut Tokenizer, space: &DynSpace) { +pub fn register_common_tokens(tref: &mut Tokenizer) { let trace_op = Atom::gnd(TraceOp{}); tref.register_token(regex(r"trace!"), move |_| { trace_op.clone() }); let print_alternatives_op = Atom::gnd(PrintAlternativesOp{}); tref.register_token(regex(r"print-alternatives!"), move |_| { print_alternatives_op.clone() }); +} + +pub fn register_runner_tokens(tref: &mut Tokenizer, space: &DynSpace) { let assert_equal_op = Atom::gnd(AssertEqualOp::new(space.clone())); tref.register_token(regex(r"assertEqual"), move |_| { assert_equal_op.clone() }); let assert_equal_to_result_op = Atom::gnd(AssertEqualToResultOp::new(space.clone())); diff --git a/lib/src/metta/runner/stdlib/mod.rs b/lib/src/metta/runner/stdlib/mod.rs index e352f28dc..50655dbe9 100644 --- a/lib/src/metta/runner/stdlib/mod.rs +++ b/lib/src/metta/runner/stdlib/mod.rs @@ -3,6 +3,7 @@ pub mod math; pub mod random; pub mod atom; pub mod module; +#[cfg(feature = "pkg_mgmt")] pub mod package; pub mod string; pub mod debug; @@ -14,7 +15,6 @@ use crate::space::*; use crate::metta::*; use crate::metta::text::{Tokenizer, SExprParser}; use crate::common::shared::Shared; -#[cfg(feature = "pkg_mgmt")] use crate::metta::runner::{Metta, RunContext, ModuleLoader}; use regex::Regex; @@ -84,6 +84,7 @@ pub fn register_common_tokens(tref: &mut Tokenizer, _tokenizer: Shared