create-query-language
Version:
A flexible TypeScript library for parsing and building query languages with support for lexical analysis, AST generation, and token stream processing
56 lines (55 loc) • 1.57 kB
TypeScript
import type { IQueryParser } from './QueryParser.interface';
import type { ParseResult, QueryParserOptions } from './types';
export declare class QueryParser implements IQueryParser {
private tokenStream;
private errors;
private openParenthesisCount;
private options;
private queryLexer;
constructor(options?: Partial<QueryParserOptions>);
parse(input: string): ParseResult;
private reset;
/**
* Parse OR expressions (lowest precedence)
*/
private parseOrExpression;
/**
* Parse AND expressions (higher precedence than OR)
*/
private parseAndExpression;
/**
* Parse NOT expressions (highest precedence for unary operators)
*/
private parseNotExpression;
/**
* Parse primary expressions (conditions and groups)
*/
private parsePrimaryExpression;
/**
* Parse grouped expression (parentheses)
*/
private parseGroupExpression;
/**
* Parse condition expression (key comparator value)
*/
private parseCondition;
/**
* Check if current token matches a boolean operator
*/
private matchLogicalOperatorAND;
/**
* Check if current token matches a boolean operator
*/
private matchLogicalOperatorOR;
/**
* Check if current token matches NOT operator
*/
private matchLogicalOperatorNOT;
private addError;
/**
* Get position after a token for error reporting
*/
private getPositionAfterToken;
private isPartialLogicalOperator;
private isPartialComparator;
}