Bool

Boolean expression evaluator

License

License

GroupId

GroupId

info.cukes
ArtifactId

ArtifactId

bool
Last Version

Last Version

1.0.20
Release Date

Release Date

Type

Type

jar
Description

Description

Bool
Boolean expression evaluator
Project URL

Project URL

https://github.com/cucumber/bool

Download bool

How to add to project

<!-- https://jarcasting.com/artifacts/info.cukes/bool/ -->
<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>bool</artifactId>
    <version>1.0.20</version>
</dependency>
// https://jarcasting.com/artifacts/info.cukes/bool/
implementation 'info.cukes:bool:1.0.20'
// https://jarcasting.com/artifacts/info.cukes/bool/
implementation ("info.cukes:bool:1.0.20")
'info.cukes:bool:jar:1.0.20'
<dependency org="info.cukes" name="bool" rev="1.0.20">
  <artifact name="bool" type="jar" />
</dependency>
@Grapes(
@Grab(group='info.cukes', module='bool', version='1.0.20')
)
libraryDependencies += "info.cukes" % "bool" % "1.0.20"
[info.cukes/bool "1.0.20"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

bool

Build Status

This is a cross-platform library for parsing boolean arithmetic expressions like a && b && (!c || !d) and evaluating them by assigning values to the variables.

Boolean expressions are parsed into an abstract syntax tree (AST).

This is done with a generated lexer and parser. The generators used are:

This choice of generators makes it easy to port the implementation to other languages since they are ported to most programming languages.

Evaluation of the boolean expressions is done by traversing the AST with a visitor. (This is obviously overkill for something as simple as boolean expressions, keep reading to understand why).

Supported platforms are Ruby, JRuby, Java and JavaScript. More platforms like Python, PHP and .NET may be added later.

The Ruby gem uses a C extension (for speed) and the JRuby gem uses a Java extension (also for speed). Support for e.g. Python could be added easily by using the same C code as the Ruby gem. Java programs (or any other JVM-based program such as Scala or Clojure) can also use the Java library as-is.

Why?

The purpose of this library is twofold.

First, it serves as a simple example of how to build a custom interpreted language with a fast lexer/parser that builds a visitor-traversable AST, and that runs on many different platforms. People who want to build a bigger cross-platform language could leverage the structure and build files in this project. For example, the Gherkin 3.0 project will use this project as a template.

Second, this project will be used by Cucumber to evaluate tag expressions in a more elegant way.

Building

See CONTRIBUTING.md

info.cukes

Cucumber

Cucumber Open

Versions

Version
1.0.20
1.0.19
1.0.18
1.0.16
1.0.15
1.0.14
1.0.11
1.0.10
1.0.9
1.0.8
1.0.6
1.0.5
1.0.3
1.0.0