go get https://github.com/Ro5bert/vera
The CLI binary can be built from the cli
folder; for example:
cd $(go env GOPATH)/src/github.com/Ro5bert/vera/cli && go build -o vera main.go
0 | False |
1 | True |
a -z , A -Z | Statement |
(...) | Grouping/explicit binary operator precedence |
! | Negate |
& | AND |
| | OR |
^ | XOR |
> | Conditional/Implication |
= | Bi-conditional/Equality/IFF |
- There is a maximum of 52 atomic statements (26 lowercase letters + 26 uppercase letter = 52). (Although, I am not sure why or how you would have 52 atomic statements... performance is O(2n) where n is number of atomic statements).
- To avoid subjectivity in operator precedence, all binary operators are assigned equal precedence and must be parenthesized as necessary (even if the operators are all AND, for example); this may change in the future. (Negation, of course, still has higher precedence than all binary operators.)
// Assuming "github.com/Ro5bert/vera" is imported
stmt, truth, err := vera.Parse("a > b")
if err != nil {
// handle error
}
// Iterate over all sets of truth values and print out the stmt evaluated at each set:
for ; truth.Val < (1 << len(truth.Names)); truth.Val++ {
fmt.Println(stmt.Eval(truth))
}