All Projects → ympons → expreso

ympons / expreso

Licence: MIT license
☕ A boolean expression parser and evaluator in Elixir.

Programming Languages

elixir
2628 projects
erlang
1774 projects

Projects that are alternatives of or similar to expreso

Parser
A lexer and parser for GraphQL in .NET
Stars: ✭ 163 (+201.85%)
Mutual labels:  lexer
Parse
Go parsers for web formats
Stars: ✭ 224 (+314.81%)
Mutual labels:  lexer
ugo
µGo编程语言(从头开发一个迷你Go语言编译器)
Stars: ✭ 38 (-29.63%)
Mutual labels:  lexer
Libpypa
libpypa is a Python parser implemented in pure C++
Stars: ✭ 172 (+218.52%)
Mutual labels:  lexer
Diagon
Interactive ASCII art diagram generators. 🌟
Stars: ✭ 189 (+250%)
Mutual labels:  lexer
vdf
A Lexer and Parser for Valves Data Format (known as vdf) written in Go
Stars: ✭ 30 (-44.44%)
Mutual labels:  lexer
Grmtools
Rust grammar tool libraries and binaries
Stars: ✭ 153 (+183.33%)
Mutual labels:  lexer
monkey
The Monkey Programming Language & Interpreter written in PHP.
Stars: ✭ 21 (-61.11%)
Mutual labels:  lexer
Cub
The Cub Programming Language
Stars: ✭ 198 (+266.67%)
Mutual labels:  lexer
lexertk
C++ Lexer Toolkit Library (LexerTk) https://www.partow.net/programming/lexertk/index.html
Stars: ✭ 26 (-51.85%)
Mutual labels:  lexer
Monkey Rust
An interpreter for the Monkey programming language written in Rust
Stars: ✭ 174 (+222.22%)
Mutual labels:  lexer
Snapdragon
snapdragon is an extremely pluggable, powerful and easy-to-use parser-renderer factory.
Stars: ✭ 180 (+233.33%)
Mutual labels:  lexer
stutter
Implement a Lisp, in C, from scratch, no libs
Stars: ✭ 65 (+20.37%)
Mutual labels:  lexer
Flex
The Fast Lexical Analyzer - scanner generator for lexing in C and C++
Stars: ✭ 2,338 (+4229.63%)
Mutual labels:  lexer
re-typescript
An opinionated attempt at finally solving typescript interop for ReasonML / OCaml.
Stars: ✭ 68 (+25.93%)
Mutual labels:  lexer
Lioness
The Lioness Programming Language
Stars: ✭ 155 (+187.04%)
Mutual labels:  lexer
go-uci
Native Go bindings for OpenWrt's UCI.
Stars: ✭ 69 (+27.78%)
Mutual labels:  lexer
core.horse64.org
THIS IS A MIRROR, CHECK https://codeberg.org/Horse64/core.horse64.org
Stars: ✭ 3 (-94.44%)
Mutual labels:  lexer
types-and-programming-languages
C++ Implementations of programming languages and type systems studied in "Types and Programming Languages" by Benjamin C. Pierce..
Stars: ✭ 32 (-40.74%)
Mutual labels:  lexer
KAI
KAI is a distributed computing model written in modern C++ and is cross-plaftorm. Using custom language translators and an executor, KAI provides full reflection, persistence and cross-process communications without having to modify existing source code. KAI Comes with an automated, generational tricolor garbage collector, and Console- and Windo…
Stars: ✭ 13 (-75.93%)
Mutual labels:  lexer

Expreso Build Status Hex Version

An Elixir library for parsing and evaluating boolean expressions

Installation

From Hex, the package can be installed by adding it to your list of dependencies in mix.exs:

def deps do
  [{:expreso, "~> 0.1.1"}]
end

Usage

Expreso.eval(expression, variables)

Parses and evaluates the provided expression. The variables can be supplied as a map in the variables parameter.

eg.

# Evaluate if a + 2 is between 3 and 1
iex> Expreso.eval("a + 2 in (3, 1)", %{"a" => 1})
iex> {:ok, true}

# Check if the key "test" is "works"
iex> Expreso.eval("test = 'works'", %{"test" => "works"})
iex> {:ok, true}

# Check if the key "test" is "works" or "great"
iex> Expreso.eval("test = 'works' or test = 'great'", %{"test" => "great"})
iex> {:ok, true}

# Evaluate an expression with not_in_op and sum
iex> Expreso.eval("10 + 2 not in (3, 1)")
iex> {:ok, true}

# Evaluate an expression with and_logic
iex> Expreso.eval("a + 2 in (2, 3) and 1 + 1 >= 2", %{"a" => 1})
iex> {:ok, true}

# Evaluate an expression with string
iex> Expreso.eval("a = 'Hello' and b != 'World' and 1 + 1 = 2", %{"a" => "Hello", "b" => ""})
iex> {:ok, true}

# Evaluate an expression with an array variable
iex> Expreso.eval("a in b", %{"a" => 1, "b" => [2, 1]})
iex> {:ok, true}

# Evaluate another expression with an array variable
iex> Expreso.eval("a not in b", %{"a" => 1, "b" => [2, 1]})
iex> {:ok, false}

# Evaluate an expression using not operator
iex> Expreso.eval("not 1 > 1 + a", %{"a" => 2})
iex> {:ok, true}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].