https://github.com/tlux/belp
A simple Boolean Expression Lexer and Parser
https://github.com/tlux/belp
boolean-algebra boolean-expression elixir expression-evaluator hex-package lexer-parser
Last synced: 4 months ago
JSON representation
A simple Boolean Expression Lexer and Parser
- Host: GitHub
- URL: https://github.com/tlux/belp
- Owner: tlux
- License: mit
- Created: 2020-04-30T14:58:15.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-25T10:34:18.000Z (over 1 year ago)
- Last Synced: 2024-04-25T13:02:18.692Z (over 1 year ago)
- Topics: boolean-algebra, boolean-expression, elixir, expression-evaluator, hex-package, lexer-parser
- Language: Elixir
- Size: 49.8 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Belp
[](https://github.com/tlux/belp/actions/workflows/elixir.yml)
[](https://coveralls.io/github/tlux/belp?branch=main)
[](https://hex.pm/packages/belp)
[](https://hexdocs.pm/belp/)
[](https://github.com/tlux/belp/blob/main/LICENSE.md)
[](https://github.com/tlux/belp/commits/main)A simple *B*oolean *E*xpression *L*exer and *P*arser written in Elixir.
## Installation
The package can be installed by adding `belp` to your list of dependencies in
`mix.exs`:```elixir
def deps do
[
{:belp, "~> 1.0"}
]
end
```## Usage
```elixir
iex> Belp.eval!(
...> "(foo or bar) and not baz",
...> %{"foo" => false, "bar" => true, "baz" => false}
...> )
true
``````elixir
iex> Belp.eval!("invalid expression")
** (Belp.SyntaxError) Syntax error near token "expression" on line 1
```See [HexDocs](https://hexdocs.pm/belp) for the full API.