UNPKG

@adguard/agtree

Version:
43 lines (42 loc) 1.55 kB
import { type AnyExpressionNode } from '../../nodes/index.js'; import { BaseParser } from '../base-parser.js'; /** * Possible node types in the logical expression. */ export declare const NodeType: { readonly Variable: "Variable"; readonly Operator: "Operator"; readonly Parenthesis: "Parenthesis"; }; export type NodeType = typeof NodeType[keyof typeof NodeType]; /** * `LogicalExpressionParser` is responsible for parsing logical expressions. * * @example * From the following rule: * ```adblock * !#if (adguard_ext_android_cb || adguard_ext_safari) * ``` * this parser will parse the expression `(adguard_ext_android_cb || adguard_ext_safari)`. */ export declare class LogicalExpressionParser extends BaseParser { /** * Split the expression into tokens. * * @param raw Source code of the expression * @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset. * @returns Token list * @throws {AdblockSyntaxError} If the expression is invalid */ private static tokenize; /** * Parses a logical expression. * * @param raw Raw input to parse. * @param options Global parser options. * @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset. * @returns Parsed expression * @throws {AdblockSyntaxError} If the expression is invalid */ static parse(raw: string, options?: import("../index.js").ParserOptions, baseOffset?: number): AnyExpressionNode; }