File: tauProlog.d.ts

package info (click to toggle)
node-yarnpkg 4.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 24,752 kB
  • sloc: javascript: 38,953; ansic: 26,035; cpp: 7,247; sh: 2,829; makefile: 724; perl: 493
file content (281 lines) | stat: -rw-r--r-- 7,863 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/* eslint-disable */

declare module 'tau-prolog' {
  namespace tau {
    namespace type {
      type _Value = Var|Num|Term<number, string>|Substitution|State|Rule;
      type Value = Var|Num|Term<number, string>;

      class Var {
        // private property to ensure types don't overlap
        private _uniqueProperty;

        public readonly id: string;

        public constructor(id: string);

        public unify(obj: _Value, occurs_check: boolean): Substitution|null;

        public clone(): this;

        public equals(obj: _Value): boolean;

        public rename(thread: Thread): this;

        public variables(): string[];

        public apply(subs: Substitution): this;

        public compare(other: this): -1|0|1;
      }

      class Num {
        // private property to ensure types don't overlap
        private _uniqueProperty;

        public readonly is_float: boolean;

        public readonly value: number;

        public constructor(value: number, is_float?: boolean);

        public unify(obj: _Value, occurs_check: boolean): Substitution|null;

        public clone(): this;

        public equals(obj: _Value): boolean;

        public rename(thread: Thread): this;

        public variables(): string[];

        public apply(subs: Substitution): this;

        public compare(other: this): -1|0|1;
      }

      class Term<Arity extends number, Indicator extends string> {
        // private property to ensure types don't overlap
        private _uniqueProperty;

        public readonly indicator: Indicator;

        public readonly id: string;

        public readonly args: Value[]&{length: Arity};

        public constructor(id: string, args?: Value[], ref?: number);

        public unify(obj: _Value, occurs_check: boolean): Substitution|null;

        public clone(): this;

        public equals(obj: _Value): boolean;

        public rename(thread: Thread): this;

        public variables(): string[];

        public apply(subs: Substitution): this;

        public select(): Term<number, string>;

        public replace(term: Term<number, string>): Term<number, string>;

        public search(expr: Term<number, string>): boolean;

        public compare(other: this): -1|0|1;

        public toJavaScript(): string|number|(string|number)[];
      }

      class Substitution {
        // private property to ensure types don't overlap
        private _uniqueProperty;

        public readonly links: {};

        public constructor(links?: {});

        public clone(): this;

        public equals(obj: _Value): boolean;

        public apply(subs: Substitution): this;
      }

      class State {
        // private property to ensure types don't overlap
        private _uniqueProperty;

        public readonly goal: Term<number, string>;

        public readonly substitution: Substitution;

        public readonly parent: State|null;

        public constructor(goal?: Term<number, string>, subs?: Substitution, parent?: State);

        public clone(): this;

        public equals(obj: _Value): boolean;
      }

      class Rule {
        // private property to ensure types don't overlap
        private _uniqueProperty;

        public readonly head: Term<number, string>;

        public readonly body: Term<number, string>|null;

        public readonly dynamic: boolean;

        public constructor(
          head: Term<number, string>, body: Term<number, string>|null, dynamic?: boolean);

        public clone(): this;

        public equals(obj: _Value): boolean;

        public rename(thread: Thread): this;

        public variables(): string[];

        public apply(subs: Substitution): this;
      }

      class Session {
        // private property to ensure types don't overlap
        private _uniqueProperty;

        public readonly rules: Record<string, Rule>;

        public readonly modules: string[];

        public readonly threads: Thread[];

        public readonly total_threads: number;

        public constructor(limit?: number);

        public consult(program: string): void;

        public query(query: string): true | Term<1, 'throw'>;

        public answer(callback: (answer: Answer) => void): void;

        public answers(callback: (answer: Answer) => void, maxCount?: number, after?: () => void):
        void;

        public add_rule(rule: Rule, options?: {from?: string}): true;

        public prepend(states: State[]): void;

        public throw_error(error: Term<1, 'error'>): void;

        public success(state: State, parent?: State): void;
      }

      class Thread {
        // private property to ensure types don't overlap
        private _uniqueProperty;

        public readonly epoch: number;
        public readonly session: Session;
        public readonly total_steps: Number;
        public readonly cpu_time: Number;
        public readonly cpu_time_last: Number;
        public readonly points: [];
        public readonly debugger: boolean;
        public readonly debugger_states: [];
        public readonly level: string;
        public readonly current_limit: number;

        public consult(program: string): void;

        public query(query: string): void;

        public answer(callback: (answer: Answer) => void): void;

        public answers(callback: (answer: Answer) => void, maxCount?: number, after?: () => void):
        void;

        public add_rule(rule: Rule, options?: {from?: string}): true;

        public prepend(states: State[]): void;

        public throw_error(error: Term<1, 'error'>): void;

        public success(state: State, parent?: State): void;
      }

      interface PredicateFn {
        (thread: Thread, point: State, atom: Term<number, string>): void|true;
      }

      type Predicate = Rule[]|PredicateFn;

      class Module {
        public readonly id: string;

        public readonly predicates: Record<string, Predicate>;

        public readonly exports: string[];

        public constructor(id: string, predicates: Record<string, Predicate>, exports: string[]);

        public exports_predicate(indicator: string): boolean;
      }

      function is_variable(obj: any): obj is Var;

      function is_atom(obj: any): obj is Term<0, string>;

      function is_module(obj: any): obj is Term<1, 'module/1'>;

      function is_error(obj: any): obj is Term<1, 'throw/1'>;

      function is_instantiated_list(obj: any): obj is Term<2, './2'>;
    }

    namespace error {
      function existence(type: string, object: type.Term<number, string>|string, indicator: string):
      type.Term<1, 'error'>;
      function type(expected: string, found: type.Term<number, string>, indicator: string):
      type.Term<1, 'error'>;
      function instantiation(indicator: string): type.Term<1, 'error'>;
      function domain(expected: string, found: type.Term<number, string>, indicator: string):
      type.Term<1, 'error'>;
      function representation(flag: string, indicator: string): type.Term<1, 'error'>;
      function permission(
        operation: string, type: string, found: type.Term<number, string>, indicator: string):
      type.Term<1, 'error'>;
      function evaluation(error: string, indicator: string): type.Term<1, 'error'>;
      function syntax(
        token: undefined|
        {value: string, line: number, column: number, matches: string[], start: number},
        expected: string,
        last: boolean): type.Term<1, 'error'>;
      function syntax_by_predicate(expected: string, indicator: string): type.Term<1, 'error'>;
    }

    interface Answer {
      id: string;

      links: Record<string, Link>;
    }

    interface Link {
      id: string;

      toJavaScript(): string|number|(string|number)[];
    }

    function format_answer(answer: Answer): string;

    function create(limit?: number): type.Session;
  }

  export = tau;
}