Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zslucky/advance-search-grammer-parser
a grammer for advance search
https://github.com/zslucky/advance-search-grammer-parser
Last synced: about 6 hours ago
JSON representation
a grammer for advance search
- Host: GitHub
- URL: https://github.com/zslucky/advance-search-grammer-parser
- Owner: zslucky
- Created: 2018-09-10T08:58:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-11T09:25:48.000Z (over 6 years ago)
- Last Synced: 2024-11-10T04:38:05.709Z (about 2 months ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# advance-search-grammer-parser
A grammer parser for advance search
---### Usage
```javascript
import { parse } from 'advance-search-grammer-parser'const ast = parse('name: "a" and age: 18 and gender: 0 or name: not "b"')
```### Grammer
Here are the all support grammers
#### Basic Usage
Expressions are consist of many `key:value` like words, So the basic grammer is:
```
[key]:[value] {(and|or) [key]:[value]}*e.g.
name: "lucky" and age: 18 or name: "lucy"// Group conditions
name: "lucky" and (age: 18 or name: "lucy")// Reverse result
name: not "lucky"
```#### Value Types
- `String` : `name: "lucky"` , wrapped by double quotation.
- `Float` : `height: 168.5` , `length: -2.2` .
- `Number` : `age: 18` .
- `Boolean` : `male: true` .
- `Function` : `user: current_user()` , `deadline: date("1y1m2d", 2, current_user())`
- Group:
- `In` : `user: <"1", "2", current_user()>` .
- `Contain` : `tag: |"red", "small"|` .
- `Range` : `date: [ 150000000 TO 157000000 ]` , `date: { date("1y2m3d") TO 157000000 ]`