# exp **Repository Path**: godLei6/exp ## Basic Information - **Project Name**: exp - **Description**: fofa转es语法解析 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-07-30 - **Last Updated**: 2023-07-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Binary Expression Tree [![godoc reference](https://godoc.org/github.com/alexkappa/exp?status.svg)](https://godoc.org/github.com/alexkappa/exp) [![wercker status](https://app.wercker.com/status/3627f2113c06b84a316c4d3ab59b414c/s/master "wercker status")](https://app.wercker.com/project/byKey/3627f2113c06b84a316c4d3ab59b414c) [![Code Climate](https://codeclimate.com/repos/57ee74cb0cee2109cb001a8d/badges/df8b36b023b964ac23ca/gpa.svg)](https://codeclimate.com/repos/57ee74cb0cee2109cb001a8d/feed) Package exp implements a binary expression tree which can be used to evaluate arbitrary binary expressions. You can use this package to build your own expressions however a few expressions are provided out of the box. ## Installation ``` $ go get github.com/alexkappa/exp/... ``` ## Usage ```Go import "github.com/alexkappa/exp" fmt.Printf("%t\n", exp.Or(exp.And(exp.True, exp.Or(exp.True, exp.False)), exp.Not(exp.False)).Eval(nil)) // true ``` It is also possible to use text to describe expressions. **Warning** this feature is not battle tested so use with caution. ```Go import "github.com/alexkappa/exp" x, err := exp.Parse(`(foo >= 100.00)`) if err != nil { // handle error } x.Eval(exp.Map{"foo": "150.00"}) // true ``` Currently only the following operators are supported. |Operator|Symbol|Data Type| |-|-|-| |`And`|`&&`|| |`Or`||||| |`Equal`, `Eq`|`==`|`string`, `float64`| |`NotEqual`, `Neq`|`!=`|`string`, `float64`| |`GreaterThan `, `Gt`|`>`|`string`, `float64`| |`GreaterThanEqual `, `Gte`|`>=`|`string`, `float64`| |`LessThan `, `Lt`|`<`|`string`, `float64`| |`LessThanEqual `, `Lte`|`<=`|`string`, `float64`| ## Documentation API documentation is available at [godoc](https://godoc.org/github.com/alexkappa/exp).