diff --git a/README.md b/README.md index ad5e32b..af45fc4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

Search Query AST for JS

+

Search Query Parser for JS

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. +--- +
Table of contents @@ -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') ``` diff --git a/package.json b/package.json index e5af2ff..d54d194 100644 --- a/package.json +++ b/package.json @@ -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 ", "license": "MIT", "private": false, diff --git a/src/index.ts b/src/index.ts index e69de29..17cd77f 100644 --- a/src/index.ts +++ b/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() +}