import { AstNode, AstNodeDescription } from "langium"; import { Maybe } from "../../util/maybe.js"; export type AstNodeType = TNumber | TString | TBoolean | TList | TStruct | TEither | TOptional | TTypeDef | TFunction | TAny; export interface TNamedMetadata { readonly id: string; readonly name: string; readonly path: string; } export declare namespace TNamedMetadata { const from: (name: string, node: AstNodeDescription) => TNamedMetadata; } export interface TOptional { readonly $type: typeof TOptional.$type; readonly node?: AstNode; readonly inner: AstNodeType; } export declare namespace TOptional { const $type = "optional"; const create: (opts: Opts) => TOptional; const is: (item: AstNodeType) => item is TOptional; } export interface TEither { readonly $type: typeof TEither.$type; readonly node?: AstNode; readonly variations: AstNodeType[]; } export declare namespace TEither { const $type = "either"; const create: (opts: Opts) => TEither; const is: (item: AstNodeType) => item is TEither; } export interface TAny { readonly $type: typeof TAny.$type; readonly node?: AstNode; } export declare namespace TAny { const $type = "any"; const create: (opts?: Opts) => TAny; const is: (item: AstNodeType) => item is TAny; } export interface TBoolean { readonly $type: typeof TBoolean.$type; readonly node?: AstNode; readonly literal?: boolean; } export declare namespace TBoolean { const $type = "bool"; const create: (opts?: Opts) => TBoolean; const is: (item: AstNodeType) => item is TBoolean; } export interface TString { readonly $type: typeof TString.$type; readonly node?: AstNode; readonly literal?: string; } export declare namespace TString { const $type = "string"; const create: (opts?: Opts) => TString; const is: (item: AstNodeType) => item is TString; } export interface TNumber { readonly $type: typeof TNumber.$type; readonly node?: AstNode; readonly literal?: number; } export declare namespace TNumber { const $type = "number"; const create: (opts?: Opts) => TNumber; const is: (item: AstNodeType) => item is TNumber; } export interface TStruct { readonly $type: typeof TStruct.$type; readonly node?: AstNode; readonly parameters: { [x: string]: TStructItem | undefined; }; readonly restriction?: AstNodeType; readonly open: boolean; } export declare namespace TStruct { export const $type = "struct"; export const create: (opts: Opts) => TStruct; export const is: (item: AstNodeType) => item is TStruct; export const define: (opts: StructDef) => TStruct; export const open: (params?: StructDef["parameters"], restriction?: StructDef["restriction"]) => TStruct; export const closed: (params?: StructDef["parameters"], restriction?: StructDef["restriction"]) => TStruct; type StructDef = Omit, "parameters"> & { readonly parameters: Record; }; export {}; } export interface TStructItem { readonly node?: AstNode; readonly value: AstNodeType; readonly optional: boolean; } export declare namespace TStructItem { const create: (opts: Opts) => TStructItem; } export type TList = { readonly $type: typeof TList.$type; readonly node?: AstNode; readonly restriction: AstNodeType; }; export declare namespace TList { const $type = "list"; const create: (opts: Opts) => TList; const is: (item: AstNodeType) => item is TList; } export interface TFunction { readonly $type: typeof TFunction.$type; readonly node?: AstNode; readonly meta: TNamedMetadata; readonly returns: AstNodeType; readonly params: TFunctionParam[]; } export declare namespace TFunction { const $type = "function"; const create: (opts: Opts) => TFunction; const is: (item: AstNodeType) => item is TFunction; } export interface TFunctionParam { readonly node?: AstNode; readonly value: AstNodeType; readonly name: string; } export declare namespace TFunctionParam { const create: (opts: Opts) => TFunctionParam; } export type TLiteral = TBoolean | TString | TNumber; declare const literals: readonly ["bool", "string", "number"]; export declare namespace TLiteral { type literal = (typeof literals)[number]; export const is: (item: AstNodeType) => item is TLiteral; export const eq: (v: string) => v is literal; export {}; } export type TPrimitive = TLiteral | TAny; declare const primitives: readonly ["bool", "string", "number", "any"]; export declare namespace TPrimitive { type primitive = (typeof primitives)[number]; export const create: (kind: primitive, node?: AstNode) => TPrimitive; export const is: (item: AstNodeType) => item is TPrimitive; export const eq: (v: string) => v is primitive; export {}; } export type TTypeDef = TTypeDefAlias | TTypeDefNamed; export declare namespace TTypeDef { const is: (item: AstNodeType) => item is TTypeDef; } interface TTypeDefBase { readonly $type: string; readonly node?: AstNode; readonly spec: AstNodeType; } export interface TTypeDefAlias extends TTypeDefBase { readonly $type: typeof TTypeDefAlias.$type; readonly name: string; } export declare namespace TTypeDefAlias { const $type = "type-def-alias"; const create: (opts: Opts) => TTypeDefAlias; const is: (item: AstNodeType) => item is TTypeDefAlias; } export interface TTypeDefNamed extends TTypeDefBase { readonly $type: typeof TTypeDefNamed.$type; readonly meta: TNamedMetadata; } export declare namespace TTypeDefNamed { const $type = "type-def-named"; const create: (opts: Opts) => TTypeDefNamed; const is: (item: AstNodeType) => item is TTypeDefNamed; } export interface TypeSystemError { readonly $type: typeof TypeSystemError.$type; readonly node: AstNode; readonly message: string; } export declare namespace TypeSystemError { const $type = "error"; const create: (opts: { node: AstNode; message: string; }) => TypeSystemError; const is: (item: unknown) => item is TypeSystemError; } export declare function TypeToString(item: AstNodeType): string; type Opts = T extends unknown ? Omit : never; export declare function TAccessor(self: TStruct, segment: string, ...segments: string[]): Maybe; export {};