@samatawy/rules
    Preparing search index...

    Class RuleParser

    Parser class for parsing rule syntax into AbstractRule objects. You should normally not need to use this parser directly, as it is primarily used internally when creating rules from syntax. This parser handles parsing of conditional rules (IF-THEN, IF-THEN-ELSE, IF-THROW) as well as assignment rules (SET x = value). It also supports parsing of annotations for rules, such as @name, @hint, and @salience. The parser uses regular expressions to identify the structure of the rule syntax and delegates to the ExpressionParser and ExecutableParser for parsing specific components of the rules (like conditions and consequences). The parser is designed to be extensible, allowing for additional rule types and syntax patterns to be added in the future as needed.

    Index

    Constructors

    Methods

    • Parse a rule from its syntax string and return the corresponding AbstractRule implementation.

      Parameters

      • syntax: string

        The syntax string of the rule to parse.

      Returns AbstractRule | null

      The parsed implementation of AbstractRule object if successful, null otherwise.

      An error if the syntax is invalid or if parsing fails for any reason.

    • Create a deep clone of the given AbstractRule by parsing its syntax and copying its annotations.

      Parameters

      • original: AbstractRule

        the original AbstractRule object to clone.

      Returns AbstractRule

      a new AbstractRule object that is a deep clone of the original.

      an error if the original AbstractRule cannot be cloned for any reason.