Expr is a handy expression parser
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
NOTICE
README.md
pom.xml

README.md

Expr

Expr is a handy expression parser.

Expr is released under the Apache License 2.0.

Expr is deployed to Maven Central with GAV io.mfj:expr.

The grammar:

* Expression :      Term ( Conjunction Term )*
* Term :            Statement | Not | Parens
* Parens :          '(' Expression ')'
* Not :             'not' Whitespace* '(' Expression ')'
* Statement :       Value Operator Value ( Operator Value )?
* Value :           VariableName | LiteralValue
* Conjunction :     Whitespace+ ( 'and' | 'or' ) Whitespace+
* Operator :        '!=' | '<>' | '>=' | '<=' | '>' | '<' | '=~' | '='
* Whitespace :      ' ' | '\t' | '\n'
* LiteralValue :    Integer | Decimal | String | Regex | Boolean | Date | Time | DateTime
* String :          '"' TextOrEmpty{" escaped by \} '"'
* Regex :           '/' TextOrEmpty{/ escaped by \} '/'
* Decimal :         '-'? Digit+ ( '.' Digit+ )?
* Integer :         '-'? Digit+
* Boolean :         'true' | 'false'
* Date :            "d'" ISO_8601_Date "'"
* Time :            "t'" ISO_8601_Time "'"
* DateTime :        "dt'" ISO_8601_DateTime "'"
* VariableName :    /[a-zA-Z_][a-zA-Z0-9_]+/

What is up with the optional part of Statement?

1 < myVar <= 6 is valid. It means 1 < myVar and myVar <= 6.

It is awesome.

Variable types

  • STRING - kotlin.String
  • Regex - kotlin.text.Regex
  • Integer - kotlin.Int
  • Double - kotlin.Double
  • Date - java.time.LocalDate
  • Time - java.time.LocalTime
  • DateTime - java.time.LocalDateTime
  • Boolean - kotlin.Boolean

Versioning

Expr's version is of the format major.minor.build.

The major number is incremented for breaking changes or major new features.

The minor number is incremented for minor new features.

The build number is generated by Measures for Justice's private CI tool. It is incremented for each build, regardless of the major and minor numbers (it does not reset to zero when minor or major numbers are increased).