Skip to content

insomnious-melissa/melissa-rule-engine-lfe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rule-engine

LFE Versions Erlang Versions

LFE Rule Engine library

Rule Engine is a small subset of LISP aimed to handle user input (S-expessions) returning true if expression evaluates to true, false if it evalues to false or nil if it cannot be evaluated. It supports handling surrounding context and supposed to be extensible.

More to be done soon!

Documentation

See tests for usage info:

Examples

Using LFE:

;; Check if S-expression conforms Rule Engine

(== (rule-engine:check '(or true false) 'boolexpr?) 'true)
(== (rule-engine:check '(in true or) 'expr?) 'false)

;; Evaluate S-expression using Rule Engine
(== (rule-engine:evaluate '(or true false)) 'true)
(== (rule-engine:evaluate '(and true false (in 3 (1 2 3)) 'false)))

The same using Erlang:

% Check if S-expression conforms Rule Engine
'rule-engine':check(['or','true','false'], 'boolexpr?') == true.
'rule-engine':check(['in','true','or'], 'expr?') == false.

% Evaluate S-expression using Rule Engine
'rule-engine':evaluate(['or','true','false']) == true.
'rule-engine':evaluate(['and','true','false',['in',3,[1,2,3]]]) == false.

Build

$ rebar3 compile

Test

$ rebar3 eunit

License

Copyright © 2017, Sergey Sobko

MIT License