Skip to content

Commit

Permalink
fixes after Vitaly's review
Browse files Browse the repository at this point in the history
  • Loading branch information
Innokenty committed Nov 28, 2024
1 parent b52aa10 commit ca4090f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/src/metta/runner/stdlib/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion lib/src/metta/runner/stdlib/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
4 changes: 2 additions & 2 deletions lib/src/metta/runner/stdlib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -84,6 +84,7 @@ pub fn register_common_tokens(tref: &mut Tokenizer, _tokenizer: Shared<Tokenizer
atom::register_common_tokens(tref, space);
module::register_common_tokens(tref, metta);
space::register_common_tokens(tref);
debug::register_common_tokens(tref);

#[cfg(feature = "pkg_mgmt")]
package::register_pkg_mgmt_tokens(tref, metta);
Expand Down Expand Up @@ -150,7 +151,6 @@ pub fn register_rust_stdlib_tokens(target: &mut Tokenizer) {
let xor_op = Atom::gnd(XorOp{});
tref.register_token(regex(r"xor"), move |_| { xor_op.clone() });

random::register_rust_stdlib_tokens(tref);
core::register_rust_stdlib_tokens(tref);

target.move_front(&mut rust_tokens);
Expand Down
3 changes: 0 additions & 3 deletions lib/src/metta/runner/stdlib/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ use crate::metta::runner::stdlib::{grounded_op, regex, unit_result};
use crate::*;
use crate::metta::*;
use crate::metta::text::Tokenizer;
#[cfg(feature = "pkg_mgmt")]
use crate::metta::runner::{Metta, RunContext, string::Str,
git_catalog::ModuleGitLocation, mod_name_from_url, pkg_mgmt::UpdateMode};

use crate::metta::runner::string::*;
#[cfg(feature = "pkg_mgmt")]
/// The op atoms that depend on the pkg_mgmt feature


/// Provides a way to access [Metta::load_module_at_path] from within MeTTa code
Expand Down
3 changes: 0 additions & 3 deletions lib/src/metta/runner/stdlib/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ pub fn register_common_tokens(tref: &mut Tokenizer) {
tref.register_token(regex(r"random-int"), move |_| { random_int_op.clone() });
let random_float_op = Atom::gnd(RandomFloatOp{});
tref.register_token(regex(r"random-float"), move |_| { random_float_op.clone() });
}

pub fn register_rust_stdlib_tokens(tref: &mut Tokenizer) {
let flip_op = Atom::gnd(FlipOp{});
tref.register_token(regex(r"flip"), move |_| { flip_op.clone() });
}
Expand Down

0 comments on commit ca4090f

Please sign in to comment.