import type { EventSchema, EventSchemaElement } from "./types"; /** An event schema compiled to instructions, indexed by program counter. */ export type EventSchemaProgram = Readonly<{ /** The instructions. */ code: readonly Instruction[]; /** The program counter a message starts at. */ start: number; /** The segment IDs the `segment` instructions consume. */ segmentIds: ReadonlySet; }>; /** * One instruction of a program, discriminated by `op`. `next` and `targets` * are program counters. */ export type Instruction = Readonly<{ op: "segment"; id: string; next: number; }> | Readonly<{ op: "any"; next: number; }> | Readonly<{ op: "z"; next: number; }> | Readonly<{ op: "split"; targets: readonly number[]; }> | Readonly<{ op: "open"; id: string; name: string; next: number; }> | Readonly<{ op: "close"; next: number; }> | Readonly<{ op: "match"; }>; /** The segment ID that matches any segment in a schema. */ export declare const ANY_SEGMENT = "Hxx"; /** The segment ID that matches any Z-segment in a schema. */ export declare const ANY_Z_SEGMENT = "anyZSegment"; /** The prefix HL7v2 reserves for locally defined segment IDs. */ export declare const Z_SEGMENT_PREFIX = "Z"; /** * Compiles `schema` into the program `runner()` runs. * * The program prefers, in order: entering an optional element over skipping * it, repeating an element over leaving it, and earlier choice alternatives * over later ones. Neither `start` nor any instruction targets a split with a * single target. * * @throws {Error} When `schema` has no elements, a segment has no name, a * group has no ID, no name, or no elements, a choice has no alternatives, * or a choice alternative can match no segment. */ export declare function compile(schema: EventSchema): EventSchemaProgram; /** * The program `compile()` builds for `schema`, compiled on its first call and * kept for the object. `schema` MUST NOT change after its first call. * * @throws {Error} As `compile()`. */ export declare const compileOnce: (arg: Readonly<{ $schema?: string; id: string; elements: readonly EventSchemaElement[]; }>) => Readonly<{ /** The instructions. */ code: readonly Instruction[]; /** The program counter a message starts at. */ start: number; /** The segment IDs the `segment` instructions consume. */ segmentIds: ReadonlySet; }>; //# sourceMappingURL=compile.d.ts.map