mirror of
https://github.com/chenasraf/search-ast-parser-js.git
synced 2026-05-17 17:48:09 +00:00
chore: update name
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<h1>Search Query AST for JS</h1>
|
||||
<h1>Search Query Parser for JS</h1>
|
||||
|
||||
This is a package for JS applications that parses search queries with the common search operator
|
||||
features such as logical or/and, grouping, phrases (in quotes), etc.
|
||||
@@ -6,6 +6,8 @@ features such as logical or/and, grouping, phrases (in quotes), etc.
|
||||
This package **does not** implement a search mechanism using the resulting tree, that is up to the
|
||||
package user (you). It only returns the logical tree of search.
|
||||
|
||||
---
|
||||
|
||||
<!-- toc -->
|
||||
<details>
|
||||
<summary>Table of contents</summary>
|
||||
@@ -91,7 +93,7 @@ const result = [
|
||||
Simply pass a string to the parse to get the result.
|
||||
|
||||
```js
|
||||
import { parse } from 'search-query-ast'
|
||||
import { parse } from 'search-query-parser'
|
||||
const result = parse('(mango banana lemon) OR apple -pineapple')
|
||||
```
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "search-query-ast",
|
||||
"name": "search-query-parser",
|
||||
"version": "0.1.0",
|
||||
"description": "Parses search query syntax into AST tree",
|
||||
"main": "index.js",
|
||||
"repository": "https://github.com/chenasraf/search-query-ast-js",
|
||||
"repository": "https://github.com/chenasraf/search-query-parser-js",
|
||||
"author": "Chen Asraf <contact@casraf.dev>",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
|
||||
10
src/index.ts
10
src/index.ts
@@ -0,0 +1,10 @@
|
||||
import { Lexer } from './lexer'
|
||||
import { Parser, ParserToken } from './parser'
|
||||
import { StringReader } from './reader'
|
||||
|
||||
export function parse(search: string): ParserToken[] {
|
||||
const reader = new StringReader(search)
|
||||
const lexer = new Lexer(reader)
|
||||
const parser = new Parser(lexer)
|
||||
return parser.parse()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user