UNPKG

4.02 kBTypeScriptView Raw
1type Entries = {
2 op?: AlgorithmBiblioEntry[];
3 production?: ProductionBiblioEntry[];
4 clause?: ClauseBiblioEntry[];
5 term?: TermBiblioEntry[];
6 table?: FigureBiblioEntry[];
7 figure?: FigureBiblioEntry[];
8 example?: FigureBiblioEntry[];
9 note?: FigureBiblioEntry[];
10 step?: StepBiblioEntry[];
11};
12declare class EnvRec {
13 entries: Array<BiblioEntry>;
14 _parent: EnvRec | undefined;
15 _namespace: string;
16 _children: EnvRec[];
17 _byType: Entries;
18 _byLocation: {
19 [key: string]: BiblioEntry[];
20 };
21 _byProductionName: {
22 [key: string]: ProductionBiblioEntry;
23 };
24 _byAoid: {
25 [key: string]: AlgorithmBiblioEntry;
26 };
27 _keys: Set<String>;
28 constructor(parent: EnvRec | undefined, namespace: string);
29 push(...items: BiblioEntry[]): number;
30}
31export default class Biblio {
32 private _byId;
33 private _location;
34 private _root;
35 private _nsToEnvRec;
36 constructor(location: string);
37 byId(id: string): BiblioEntry;
38 byNamespace(ns: string): EnvRec;
39 byProductionName(name: string, ns?: string): ProductionBiblioEntry | undefined;
40 byAoid(aoid: string, ns?: string): AlgorithmBiblioEntry | undefined;
41 getOpNames(ns: string): Set<string>;
42 getDefinedWords(ns: string): Record<string, AlgorithmBiblioEntry | TermBiblioEntry>;
43 private lookup;
44 keysForNamespace(ns: string): Set<String>;
45 localEntries(): BiblioEntry[];
46 export(): ExportedBiblio;
47 dump(): void;
48}
49export interface BiblioEntryBase {
50 type: string;
51 location: string;
52 namespace?: string;
53 id?: string;
54 refId?: string;
55 aoid?: string | null;
56 referencingIds: string[];
57}
58export type Type = {
59 kind: 'opaque';
60 type: string;
61} | {
62 kind: 'unused';
63} | {
64 kind: 'completion';
65 completionType: 'abrupt';
66} | {
67 kind: 'completion';
68 typeOfValueIfNormal: Type | null;
69 completionType: 'normal' | 'mixed';
70} | {
71 kind: 'list';
72 elements: Type | null;
73} | {
74 kind: 'union';
75 types: Exclude<Type, {
76 kind: 'union';
77 }>[];
78} | {
79 kind: 'record';
80 fields: Record<string, Type | null>;
81};
82export type Parameter = {
83 name: string;
84 type: null | Type;
85};
86export type Signature = {
87 parameters: Parameter[];
88 optionalParameters: Parameter[];
89 return: null | Type;
90};
91export type AlgorithmType = 'abstract operation' | 'host-defined abstract operation' | 'implementation-defined abstract operation' | 'syntax-directed operation' | 'numeric method';
92export interface AlgorithmBiblioEntry extends BiblioEntryBase {
93 type: 'op';
94 aoid: string;
95 kind?: AlgorithmType;
96 signature: null | Signature;
97 effects: string[];
98 skipGlobalChecks?: boolean;
99}
100export interface ProductionBiblioEntry extends BiblioEntryBase {
101 type: 'production';
102 name: string;
103}
104export interface ClauseBiblioEntry extends BiblioEntryBase {
105 type: 'clause';
106 id: string;
107 aoid: string | null;
108 title: string;
109 titleHTML: string;
110 number: string | number;
111}
112export interface TermBiblioEntry extends BiblioEntryBase {
113 type: 'term';
114 term: string;
115 variants?: string[];
116}
117export interface FigureBiblioEntry extends BiblioEntryBase {
118 type: 'table' | 'figure' | 'example' | 'note';
119 id: string;
120 number: string | number;
121 clauseId?: string;
122 caption?: string;
123}
124export interface StepBiblioEntry extends BiblioEntryBase {
125 type: 'step';
126 id: string;
127 stepNumbers: number[];
128}
129export type BiblioEntry = AlgorithmBiblioEntry | ProductionBiblioEntry | ClauseBiblioEntry | TermBiblioEntry | FigureBiblioEntry | StepBiblioEntry;
130type Unkey<T, S extends string> = T extends any ? Omit<T, S> : never;
131type NonExportedKeys = 'location' | 'referencingIds' | 'namespace';
132export type PartialBiblioEntry = Unkey<BiblioEntry, NonExportedKeys>;
133export type ExportedBiblio = {
134 location: string;
135 entries: Unkey<PartialBiblioEntry, `_${string}`>[];
136};
137export declare function getKeys(entry: TermBiblioEntry): string[];
138export {};