pub struct GRLParser;👎Deprecated since 1.18.0: Use
grl_helpers or parallel parsers for 4-60x better performance. See module docs.Expand description
GRL (Grule Rule Language) Parser Parses Grule-like syntax into Rule objects
§⚠️ Performance Note
This parser uses regex internally which is 4-60x slower than the new literal search parsers.
For new code, consider using the faster alternatives:
use rust_rule_engine::parser::{grl_helpers, parallel};
// Example: a small dummy GRL string (doctest is marked no_run to avoid
// executing heavy parsing during docs build)
let grl = r#"rule \"Example\" { when true then }"#;
// Fast rule splitting with SIMD (3.5x faster)
let rules = grl_helpers::split_into_rules(&grl);
// Or parallel parsing for large files (up to 8x faster on multi-core)
let rules = parallel::parse_rules_adaptive(&grl);This parser (GRLParser) is kept for backward compatibility with existing code.
Implementations§
Source§impl GRLParser
impl GRLParser
Sourcepub fn parse_rule(grl_text: &str) -> Result<Rule>
pub fn parse_rule(grl_text: &str) -> Result<Rule>
Parse a single rule from GRL syntax
Example GRL syntax:
rule CheckAge "Age verification rule" salience 10 {
when
User.Age >= 18 && User.Country == "US"
then
User.IsAdult = true;
Retract("User");
}Sourcepub fn parse_with_modules(grl_text: &str) -> Result<ParsedGRL>
pub fn parse_with_modules(grl_text: &str) -> Result<ParsedGRL>
Parse GRL text with module support
Example:
defmodule SENSORS {
export: all
}
defmodule CONTROL {
import: SENSORS (rules * (templates temperature))
}
rule "CheckTemp" {
when temperature.value > 28
then println("Hot");
}Auto Trait Implementations§
impl Freeze for GRLParser
impl RefUnwindSafe for GRLParser
impl Send for GRLParser
impl Sync for GRLParser
impl Unpin for GRLParser
impl UnwindSafe for GRLParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more