/** * The pipe-expression front-end: a moo lexer plus a hand-rolled recursive-descent parser that * compiles `select pages=2-5 | redact match=/…/ | convert to=pdf` into a {@link MediaPlan}. * * @remarks * Internal sibling of the `@nhtio/adk/batteries/media` entry. The grammar is frozen in the * design doc (section 0): * * - `pipeline := segment ('|' segment)*` ; `segment := verb arg*` ; `arg := IDENT '=' value` — * named args only, no positionals (an IDENT followed by `=` is an arg; otherwise it is the * verb's second word — 2-token lookahead, no verb table needed at parse time). * - Verb matching is separator-insensitive (`extract_text` ≡ `extract text` ≡ `extract.text`). * - Values: bareword idents, ints/floats, `a-b` ranges, comma lists, `true`/`false`, quoted * strings (single or double), class-aware `/regex/flags` literals, `@id` media refs, and * quoted-JSON structured payloads (a quoted string that the verb's arg schema declares as * `json` is JSON-parsed). * - `#` line comments are tolerated (models add them; ignoring them is free robustness). * - Two error layers: syntactic ({@link E_MEDIA_PIPE_SYNTAX}, with line/col and a corrective * exemplar) and semantic ({@link E_MEDIA_UNKNOWN_VERB} etc., produced by the validator in * `validate.ts` — this module only parses to a raw AST and lowers to the plan). * * Parsing is deployment-independent: the full verb table drives folding, and engine narrowing * happens later in validation (frozen 0.3). */ import type { MediaPlan, MediaArgValue, SourceSpan } from "./plan"; /** A parsed-but-unvalidated arg value, before the verb's arg schema refines it. */ export interface RawArgValue { /** The lowered value. Quoted strings stay strings here; schema may JSON-parse `json` args. */ value: MediaArgValue; /** Whether the source token was a quoted string (drives json-arg parsing + name/index rules). */ quoted: boolean; /** Source position of the value token. */ span: SourceSpan; } /** One parsed segment: verb words plus named args, all position-bearing. */ export interface RawSegment { /** Canonical verb id when fold-matching succeeded, else the raw folded text. */ verb: string; /** Whether `verb` resolved against the verb table. */ known: boolean; /** The parsed named args, in source order. */ args: Map; /** Source position of the verb token(s). */ span: SourceSpan; } /** * Parse a pipe expression into raw, position-bearing segments. * * @remarks * Purely syntactic — verbs are fold-matched against the full verb table for canonicalization * but unknown verbs are NOT an error here (the validator reports them with did-you-mean and the * deployment's narrowed verb list). Pair with `validateSegments` for the validated path. * * @param input - The pipe expression. * @returns The raw segments. */ export declare const parsePipeRaw: (input: string) => RawSegment[]; /** * Lower raw segments to an (unvalidated) {@link MediaPlan}. Quoted-JSON arg parsing and * type/enum checks happen in the validator, which consumes the raw segments — this lowering * exists for tooling that wants the structural plan without validation. * * @param segments - Output of {@link parsePipeRaw}. * @returns The structural plan (args carried as parsed, json args still strings). */ export declare const lowerSegments: (segments: RawSegment[]) => MediaPlan;