Simple expression parsers in Go.
go get github.com/orkes-io/go-parse
All parsers implemented in this package perform tokenization and produce an Abstract Syntax Tree (AST) of their results, which can be consumed by other functions.
Supports parsing boolean expressions using AND
, OR
, and NOT
, according to the following grammar.
The syntax used for each operator can be configured at runtime.
expr -> and
and -> or 'AND' and | or
or -> not 'OR' or | not
not -> 'NOT' parens | parens
parens -> '(' expr ')' | unparsed
unparsed -> '.*
Supports parsing comparison expressions using equality and comparison operators, according to the following grammar. The syntax used for each operator can be configured at runtime.
expr -> equal
equal -> ordinal ( '!=' | '==' ) ordinal | ordinal
ordinal -> term ( '>=' | '>' | '<' | '<=' ) term | term
term -> '(' expr ')' | unparsed
unparsed -> .*