/** * Parser Utility: Type Reference Parsing * Parses a type-ref production: either a static type name (optionally * parameterized) or a dynamic $variable. * @internal */ import { type TypeRef, type FieldArg, type LiteralNode, type AnnotationArg } from '../types.js'; import { type ParserState } from './state.js'; /** * Parse a type reference from the current position in the token stream. * * Grammar: * ``` * type-ref = single-type { "|" single-type } * single-type = "$" identifier | type-name [ "(" type-ref-arg-list ")" ] * type-ref-arg-list = type-ref-arg { "," type-ref-arg } [ "," ] * type-ref-arg = identifier ":" type-ref | type-ref * ``` * * - `$identifier` → `{ kind: 'dynamic', varName: identifier }` * - `type-name` → `{ kind: 'static', typeName }` * - `type-name(arg, ...)` → `{ kind: 'static', typeName, args: [...] }` * - `A | B | ...` → `{ kind: 'union', members: [A, B, ...] }` * * Dynamic refs do not accept parameterization — `$T(...)` is not valid. * Union members are flattened: nested unions are spread into the member list. * * Throws ParseError if neither a `$identifier` nor a valid type name * is found. Throws ParseError if the arg list is malformed. * Throws ParseError (RILL-P011) if `|` is not followed by a valid type start. * * @internal */ export declare function parseTypeRef(state: ParserState, opts?: { allowTrailingPipe?: boolean; parseLiteral?: () => LiteralNode; parseAnnotations?: () => AnnotationArg[]; }): TypeRef; export declare function parseFieldArgList(state: ParserState, opts?: { parseLiteral?: () => LiteralNode; parseAnnotations?: () => AnnotationArg[]; }): FieldArg[];