@sharpee/if-domain 0.9.60-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -0
- package/dist/changes.d.ts +8 -0
- package/dist/changes.d.ts.map +1 -0
- package/dist/changes.js +6 -0
- package/dist/changes.js.map +1 -0
- package/dist/contracts.d.ts +270 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +6 -0
- package/dist/contracts.js.map +1 -0
- package/dist/events.d.ts +124 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +123 -0
- package/dist/events.js.map +1 -0
- package/dist/grammar/grammar-builder.d.ts +507 -0
- package/dist/grammar/grammar-builder.d.ts.map +1 -0
- package/dist/grammar/grammar-builder.js +47 -0
- package/dist/grammar/grammar-builder.js.map +1 -0
- package/dist/grammar/grammar-engine.d.ts +65 -0
- package/dist/grammar/grammar-engine.d.ts.map +1 -0
- package/dist/grammar/grammar-engine.js +370 -0
- package/dist/grammar/grammar-engine.js.map +1 -0
- package/dist/grammar/index.d.ts +10 -0
- package/dist/grammar/index.d.ts.map +1 -0
- package/dist/grammar/index.js +26 -0
- package/dist/grammar/index.js.map +1 -0
- package/dist/grammar/pattern-compiler.d.ts +38 -0
- package/dist/grammar/pattern-compiler.d.ts.map +1 -0
- package/dist/grammar/pattern-compiler.js +22 -0
- package/dist/grammar/pattern-compiler.js.map +1 -0
- package/dist/grammar/scope-builder.d.ts +26 -0
- package/dist/grammar/scope-builder.d.ts.map +1 -0
- package/dist/grammar/scope-builder.js +67 -0
- package/dist/grammar/scope-builder.js.map +1 -0
- package/dist/grammar/vocabulary-provider.d.ts +163 -0
- package/dist/grammar/vocabulary-provider.d.ts.map +1 -0
- package/dist/grammar/vocabulary-provider.js +89 -0
- package/dist/grammar/vocabulary-provider.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/language-provider.d.ts +106 -0
- package/dist/language-provider.d.ts.map +1 -0
- package/dist/language-provider.js +14 -0
- package/dist/language-provider.js.map +1 -0
- package/dist/parser-contracts/index.d.ts +10 -0
- package/dist/parser-contracts/index.d.ts.map +1 -0
- package/dist/parser-contracts/index.js +26 -0
- package/dist/parser-contracts/index.js.map +1 -0
- package/dist/parser-contracts/parser-factory.d.ts +46 -0
- package/dist/parser-contracts/parser-factory.d.ts.map +1 -0
- package/dist/parser-contracts/parser-factory.js +78 -0
- package/dist/parser-contracts/parser-factory.js.map +1 -0
- package/dist/parser-contracts/parser-internals.d.ts +125 -0
- package/dist/parser-contracts/parser-internals.d.ts.map +1 -0
- package/dist/parser-contracts/parser-internals.js +26 -0
- package/dist/parser-contracts/parser-internals.js.map +1 -0
- package/dist/parser-contracts/parser-types.d.ts +128 -0
- package/dist/parser-contracts/parser-types.d.ts.map +1 -0
- package/dist/parser-contracts/parser-types.js +9 -0
- package/dist/parser-contracts/parser-types.js.map +1 -0
- package/dist/parser-language-provider.d.ts +158 -0
- package/dist/parser-language-provider.d.ts.map +1 -0
- package/dist/parser-language-provider.js +10 -0
- package/dist/parser-language-provider.js.map +1 -0
- package/dist/sequencing.d.ts +53 -0
- package/dist/sequencing.d.ts.map +1 -0
- package/dist/sequencing.js +6 -0
- package/dist/sequencing.js.map +1 -0
- package/dist/vocabulary-contracts/index.d.ts +7 -0
- package/dist/vocabulary-contracts/index.d.ts.map +1 -0
- package/dist/vocabulary-contracts/index.js +23 -0
- package/dist/vocabulary-contracts/index.js.map +1 -0
- package/dist/vocabulary-contracts/vocabulary-adapters.d.ts +19 -0
- package/dist/vocabulary-contracts/vocabulary-adapters.d.ts.map +1 -0
- package/dist/vocabulary-contracts/vocabulary-adapters.js +73 -0
- package/dist/vocabulary-contracts/vocabulary-adapters.js.map +1 -0
- package/dist/vocabulary-contracts/vocabulary-registry.d.ts +98 -0
- package/dist/vocabulary-contracts/vocabulary-registry.d.ts.map +1 -0
- package/dist/vocabulary-contracts/vocabulary-registry.js +383 -0
- package/dist/vocabulary-contracts/vocabulary-registry.js.map +1 -0
- package/dist/vocabulary-contracts/vocabulary-types.d.ts +240 -0
- package/dist/vocabulary-contracts/vocabulary-types.d.ts.map +1 -0
- package/dist/vocabulary-contracts/vocabulary-types.js +64 -0
- package/dist/vocabulary-contracts/vocabulary-types.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Grammar Engine Base
|
|
4
|
+
* @description Abstract base class for grammar matching engines
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.GrammarEngine = void 0;
|
|
8
|
+
const grammar_builder_1 = require("./grammar-builder");
|
|
9
|
+
/**
|
|
10
|
+
* Abstract base class for grammar engines
|
|
11
|
+
* Language-specific implementations provide concrete matching logic
|
|
12
|
+
*/
|
|
13
|
+
class GrammarEngine {
|
|
14
|
+
rules = [];
|
|
15
|
+
rulesByAction = new Map();
|
|
16
|
+
compiler;
|
|
17
|
+
constructor(compiler) {
|
|
18
|
+
this.compiler = compiler;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Add a grammar rule
|
|
22
|
+
*/
|
|
23
|
+
addRule(rule) {
|
|
24
|
+
// Compile the pattern if not already compiled
|
|
25
|
+
if (!rule.compiledPattern) {
|
|
26
|
+
rule.compiledPattern = this.compiler.compile(rule.pattern);
|
|
27
|
+
}
|
|
28
|
+
this.rules.push(rule);
|
|
29
|
+
// Index by action for faster lookup
|
|
30
|
+
const actionRules = this.rulesByAction.get(rule.action) || [];
|
|
31
|
+
actionRules.push(rule);
|
|
32
|
+
this.rulesByAction.set(rule.action, actionRules);
|
|
33
|
+
// Sort by priority
|
|
34
|
+
this.sortRules();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Add multiple rules
|
|
38
|
+
*/
|
|
39
|
+
addRules(rules) {
|
|
40
|
+
rules.forEach(rule => this.addRule(rule));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the best match from a set of tokens
|
|
44
|
+
*/
|
|
45
|
+
getBestMatch(tokens, context, options) {
|
|
46
|
+
const matches = this.findMatches(tokens, context, options);
|
|
47
|
+
return matches.length > 0 ? matches[0] : null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Clear all rules
|
|
51
|
+
*/
|
|
52
|
+
clear() {
|
|
53
|
+
this.rules = [];
|
|
54
|
+
this.rulesByAction.clear();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get all rules
|
|
58
|
+
*/
|
|
59
|
+
getRules() {
|
|
60
|
+
return [...this.rules];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get rules for a specific action
|
|
64
|
+
*/
|
|
65
|
+
getRulesForAction(action) {
|
|
66
|
+
return this.rulesByAction.get(action) || [];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Sort rules by priority (descending)
|
|
70
|
+
*/
|
|
71
|
+
sortRules() {
|
|
72
|
+
this.rules.sort((a, b) => b.priority - a.priority);
|
|
73
|
+
// Also sort within each action group
|
|
74
|
+
this.rulesByAction.forEach((rules) => {
|
|
75
|
+
rules.sort((a, b) => b.priority - a.priority);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Create a grammar builder connected to this engine
|
|
80
|
+
*/
|
|
81
|
+
createBuilder() {
|
|
82
|
+
const engine = this;
|
|
83
|
+
return {
|
|
84
|
+
define(pattern) {
|
|
85
|
+
const rule = {
|
|
86
|
+
id: `rule_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
87
|
+
pattern,
|
|
88
|
+
slots: new Map(),
|
|
89
|
+
priority: 100 // Default priority
|
|
90
|
+
};
|
|
91
|
+
const builder = {
|
|
92
|
+
hasTrait(slot, traitType) {
|
|
93
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [], traitFilters: [] };
|
|
94
|
+
if (!slotConstraint.traitFilters)
|
|
95
|
+
slotConstraint.traitFilters = [];
|
|
96
|
+
slotConstraint.traitFilters.push(traitType);
|
|
97
|
+
rule.slots.set(slot, slotConstraint);
|
|
98
|
+
return builder;
|
|
99
|
+
},
|
|
100
|
+
where(slot, constraint) {
|
|
101
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
102
|
+
slotConstraint.constraints.push(constraint);
|
|
103
|
+
rule.slots.set(slot, slotConstraint);
|
|
104
|
+
return builder;
|
|
105
|
+
},
|
|
106
|
+
text(slot) {
|
|
107
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
108
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.TEXT;
|
|
109
|
+
rule.slots.set(slot, slotConstraint);
|
|
110
|
+
return builder;
|
|
111
|
+
},
|
|
112
|
+
instrument(slot) {
|
|
113
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
114
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.INSTRUMENT;
|
|
115
|
+
rule.slots.set(slot, slotConstraint);
|
|
116
|
+
return builder;
|
|
117
|
+
},
|
|
118
|
+
mapsTo(action) {
|
|
119
|
+
rule.action = action;
|
|
120
|
+
return builder;
|
|
121
|
+
},
|
|
122
|
+
withPriority(priority) {
|
|
123
|
+
rule.priority = priority;
|
|
124
|
+
return builder;
|
|
125
|
+
},
|
|
126
|
+
withSemanticVerbs(verbs) {
|
|
127
|
+
if (!rule.semantics)
|
|
128
|
+
rule.semantics = {};
|
|
129
|
+
rule.semantics.verbs = verbs;
|
|
130
|
+
return builder;
|
|
131
|
+
},
|
|
132
|
+
withSemanticPrepositions(prepositions) {
|
|
133
|
+
if (!rule.semantics)
|
|
134
|
+
rule.semantics = {};
|
|
135
|
+
rule.semantics.prepositions = prepositions;
|
|
136
|
+
return builder;
|
|
137
|
+
},
|
|
138
|
+
withSemanticDirections(directions) {
|
|
139
|
+
if (!rule.semantics)
|
|
140
|
+
rule.semantics = {};
|
|
141
|
+
rule.semantics.directions = directions;
|
|
142
|
+
return builder;
|
|
143
|
+
},
|
|
144
|
+
withDefaultSemantics(defaults) {
|
|
145
|
+
rule.defaultSemantics = defaults;
|
|
146
|
+
return builder;
|
|
147
|
+
},
|
|
148
|
+
// ADR-082: Typed Value Slots
|
|
149
|
+
number(slot) {
|
|
150
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
151
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.NUMBER;
|
|
152
|
+
rule.slots.set(slot, slotConstraint);
|
|
153
|
+
return builder;
|
|
154
|
+
},
|
|
155
|
+
ordinal(slot) {
|
|
156
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
157
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.ORDINAL;
|
|
158
|
+
rule.slots.set(slot, slotConstraint);
|
|
159
|
+
return builder;
|
|
160
|
+
},
|
|
161
|
+
time(slot) {
|
|
162
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
163
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.TIME;
|
|
164
|
+
rule.slots.set(slot, slotConstraint);
|
|
165
|
+
return builder;
|
|
166
|
+
},
|
|
167
|
+
// ADR-082: Built-in Vocabulary Slots
|
|
168
|
+
direction(slot) {
|
|
169
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
170
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.DIRECTION;
|
|
171
|
+
rule.slots.set(slot, slotConstraint);
|
|
172
|
+
return builder;
|
|
173
|
+
},
|
|
174
|
+
manner(slot) {
|
|
175
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
176
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.MANNER;
|
|
177
|
+
rule.slots.set(slot, slotConstraint);
|
|
178
|
+
return builder;
|
|
179
|
+
},
|
|
180
|
+
// ADR-082: Category-Based Vocabulary Slots
|
|
181
|
+
fromVocabulary(slot, category) {
|
|
182
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
183
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.VOCABULARY;
|
|
184
|
+
slotConstraint.vocabularyCategory = category;
|
|
185
|
+
rule.slots.set(slot, slotConstraint);
|
|
186
|
+
return builder;
|
|
187
|
+
},
|
|
188
|
+
// Deprecated methods - use fromVocabulary() instead
|
|
189
|
+
adjective(slot) {
|
|
190
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
191
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.ADJECTIVE;
|
|
192
|
+
rule.slots.set(slot, slotConstraint);
|
|
193
|
+
return builder;
|
|
194
|
+
},
|
|
195
|
+
noun(slot) {
|
|
196
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
197
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.NOUN;
|
|
198
|
+
rule.slots.set(slot, slotConstraint);
|
|
199
|
+
return builder;
|
|
200
|
+
},
|
|
201
|
+
// ADR-082: Text Variant Slots
|
|
202
|
+
quotedText(slot) {
|
|
203
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
204
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.QUOTED_TEXT;
|
|
205
|
+
rule.slots.set(slot, slotConstraint);
|
|
206
|
+
return builder;
|
|
207
|
+
},
|
|
208
|
+
topic(slot) {
|
|
209
|
+
const slotConstraint = rule.slots.get(slot) || { name: slot, constraints: [] };
|
|
210
|
+
slotConstraint.slotType = grammar_builder_1.SlotType.TOPIC;
|
|
211
|
+
rule.slots.set(slot, slotConstraint);
|
|
212
|
+
return builder;
|
|
213
|
+
},
|
|
214
|
+
build() {
|
|
215
|
+
if (!rule.action) {
|
|
216
|
+
throw new Error('Grammar rule must have an action (use .mapsTo())');
|
|
217
|
+
}
|
|
218
|
+
engine.addRule(rule);
|
|
219
|
+
return rule;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
return builder;
|
|
223
|
+
},
|
|
224
|
+
forAction(actionId) {
|
|
225
|
+
// Accumulated configuration
|
|
226
|
+
const verbList = [];
|
|
227
|
+
const patternList = [];
|
|
228
|
+
const directionMap = {};
|
|
229
|
+
const slotConstraints = new Map();
|
|
230
|
+
const slotTraitFilters = new Map();
|
|
231
|
+
const slotTypes = new Map();
|
|
232
|
+
let priority = 100;
|
|
233
|
+
let defaultSemantics;
|
|
234
|
+
const actionBuilder = {
|
|
235
|
+
verbs(verbs) {
|
|
236
|
+
verbList.push(...verbs);
|
|
237
|
+
return actionBuilder;
|
|
238
|
+
},
|
|
239
|
+
pattern(pattern) {
|
|
240
|
+
patternList.push(pattern);
|
|
241
|
+
return actionBuilder;
|
|
242
|
+
},
|
|
243
|
+
patterns(patterns) {
|
|
244
|
+
patternList.push(...patterns);
|
|
245
|
+
return actionBuilder;
|
|
246
|
+
},
|
|
247
|
+
directions(map) {
|
|
248
|
+
Object.assign(directionMap, map);
|
|
249
|
+
return actionBuilder;
|
|
250
|
+
},
|
|
251
|
+
hasTrait(slot, traitType) {
|
|
252
|
+
const existing = slotTraitFilters.get(slot) || [];
|
|
253
|
+
existing.push(traitType);
|
|
254
|
+
slotTraitFilters.set(slot, existing);
|
|
255
|
+
return actionBuilder;
|
|
256
|
+
},
|
|
257
|
+
where(slot, constraint) {
|
|
258
|
+
const existing = slotConstraints.get(slot) || [];
|
|
259
|
+
existing.push({ constraint });
|
|
260
|
+
slotConstraints.set(slot, existing);
|
|
261
|
+
return actionBuilder;
|
|
262
|
+
},
|
|
263
|
+
withPriority(p) {
|
|
264
|
+
priority = p;
|
|
265
|
+
return actionBuilder;
|
|
266
|
+
},
|
|
267
|
+
withDefaultSemantics(defaults) {
|
|
268
|
+
defaultSemantics = defaults;
|
|
269
|
+
return actionBuilder;
|
|
270
|
+
},
|
|
271
|
+
slotType(slot, type) {
|
|
272
|
+
slotTypes.set(slot, type);
|
|
273
|
+
return actionBuilder;
|
|
274
|
+
},
|
|
275
|
+
build() {
|
|
276
|
+
// Generate verb × pattern combinations
|
|
277
|
+
if (verbList.length > 0 && patternList.length > 0) {
|
|
278
|
+
for (const verb of verbList) {
|
|
279
|
+
for (const patternTemplate of patternList) {
|
|
280
|
+
// Combine verb with pattern template
|
|
281
|
+
const fullPattern = patternTemplate.trim()
|
|
282
|
+
? `${verb} ${patternTemplate}`
|
|
283
|
+
: verb;
|
|
284
|
+
// Create the rule using the existing define() API
|
|
285
|
+
let builder = engine.createBuilder().define(fullPattern);
|
|
286
|
+
builder = builder.mapsTo(actionId);
|
|
287
|
+
builder = builder.withPriority(priority);
|
|
288
|
+
if (defaultSemantics) {
|
|
289
|
+
builder = builder.withDefaultSemantics(defaultSemantics);
|
|
290
|
+
}
|
|
291
|
+
// Apply slot constraints
|
|
292
|
+
for (const [slot, constraints] of slotConstraints) {
|
|
293
|
+
for (const { constraint } of constraints) {
|
|
294
|
+
builder = builder.where(slot, constraint);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// Apply trait filters
|
|
298
|
+
for (const [slot, traits] of slotTraitFilters) {
|
|
299
|
+
for (const traitType of traits) {
|
|
300
|
+
builder = builder.hasTrait(slot, traitType);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// Apply slot types
|
|
304
|
+
for (const [slot, type] of slotTypes) {
|
|
305
|
+
switch (type) {
|
|
306
|
+
case grammar_builder_1.SlotType.TEXT:
|
|
307
|
+
builder = builder.text(slot);
|
|
308
|
+
break;
|
|
309
|
+
case grammar_builder_1.SlotType.INSTRUMENT:
|
|
310
|
+
builder = builder.instrument(slot);
|
|
311
|
+
break;
|
|
312
|
+
case grammar_builder_1.SlotType.NUMBER:
|
|
313
|
+
builder = builder.number(slot);
|
|
314
|
+
break;
|
|
315
|
+
case grammar_builder_1.SlotType.ORDINAL:
|
|
316
|
+
builder = builder.ordinal(slot);
|
|
317
|
+
break;
|
|
318
|
+
case grammar_builder_1.SlotType.TIME:
|
|
319
|
+
builder = builder.time(slot);
|
|
320
|
+
break;
|
|
321
|
+
case grammar_builder_1.SlotType.DIRECTION:
|
|
322
|
+
builder = builder.direction(slot);
|
|
323
|
+
break;
|
|
324
|
+
case grammar_builder_1.SlotType.MANNER:
|
|
325
|
+
builder = builder.manner(slot);
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
builder.build();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// Generate standalone verb patterns (verb only, no template)
|
|
334
|
+
if (verbList.length > 0 && patternList.length === 0) {
|
|
335
|
+
for (const verb of verbList) {
|
|
336
|
+
let builder = engine.createBuilder().define(verb);
|
|
337
|
+
builder = builder.mapsTo(actionId);
|
|
338
|
+
builder = builder.withPriority(priority);
|
|
339
|
+
if (defaultSemantics) {
|
|
340
|
+
builder = builder.withDefaultSemantics(defaultSemantics);
|
|
341
|
+
}
|
|
342
|
+
builder.build();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
// Generate direction patterns
|
|
346
|
+
for (const [canonical, aliases] of Object.entries(directionMap)) {
|
|
347
|
+
for (const alias of aliases) {
|
|
348
|
+
let builder = engine.createBuilder().define(alias);
|
|
349
|
+
builder = builder.mapsTo(actionId);
|
|
350
|
+
// Lower priority for abbreviations (single character)
|
|
351
|
+
builder = builder.withPriority(alias.length === 1 ? 90 : priority);
|
|
352
|
+
builder = builder.withDefaultSemantics({ direction: canonical });
|
|
353
|
+
builder.build();
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
return actionBuilder;
|
|
359
|
+
},
|
|
360
|
+
getRules() {
|
|
361
|
+
return engine.getRules();
|
|
362
|
+
},
|
|
363
|
+
clear() {
|
|
364
|
+
engine.clear();
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
exports.GrammarEngine = GrammarEngine;
|
|
370
|
+
//# sourceMappingURL=grammar-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grammar-engine.js","sourceRoot":"","sources":["../../src/grammar/grammar-engine.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,uDAY2B;AAe3B;;;GAGG;AACH,MAAsB,aAAa;IACvB,KAAK,GAAkB,EAAE,CAAC;IAC1B,aAAa,GAA+B,IAAI,GAAG,EAAE,CAAC;IACtD,QAAQ,CAAkB;IAEpC,YAAY,QAAyB;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,IAAiB;QACvB,8CAA8C;QAC9C,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEtB,oCAAoC;QACpC,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC9D,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QAEjD,mBAAmB;QACnB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,KAAoB;QAC3B,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5C,CAAC;IAWD;;OAEG;IACH,YAAY,CACV,MAAe,EACf,OAAuB,EACvB,OA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AC;gCACnD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gCACnC,sDAAsD;gCACtD,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;gCACnE,OAAO,GAAG,OAAO,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,SAAgB,EAAE,CAAC,CAAC;gCACxE,OAAO,CAAC,KAAK,EAAE,CAAC;4BAClB,CAAC;wBACH,CAAC;oBACH,CAAC;iBACF,CAAC;gBAEF,OAAO,aAAa,CAAC;YACvB,CAAC;YAED,QAAQ;gBACN,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC3B,CAAC;YAED,KAAK;gBACH,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AA7aD,sCA6aC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Grammar system exports
|
|
3
|
+
* @description Exports for the grammar rules engine
|
|
4
|
+
*/
|
|
5
|
+
export * from './grammar-builder';
|
|
6
|
+
export * from './pattern-compiler';
|
|
7
|
+
export * from './grammar-engine';
|
|
8
|
+
export * from './scope-builder';
|
|
9
|
+
export * from './vocabulary-provider';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/grammar/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Grammar system exports
|
|
4
|
+
* @description Exports for the grammar rules engine
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./grammar-builder"), exports);
|
|
22
|
+
__exportStar(require("./pattern-compiler"), exports);
|
|
23
|
+
__exportStar(require("./grammar-engine"), exports);
|
|
24
|
+
__exportStar(require("./scope-builder"), exports);
|
|
25
|
+
__exportStar(require("./vocabulary-provider"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/grammar/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,oDAAkC;AAClC,qDAAmC;AACnC,mDAAiC;AACjC,kDAAgC;AAChC,wDAAsC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Pattern Compiler Interface
|
|
3
|
+
* @description Language-agnostic interface for compiling grammar patterns
|
|
4
|
+
*/
|
|
5
|
+
import { CompiledPattern } from './grammar-builder';
|
|
6
|
+
/**
|
|
7
|
+
* Pattern compiler interface
|
|
8
|
+
* Language-specific implementations handle their own syntax
|
|
9
|
+
*/
|
|
10
|
+
export interface PatternCompiler {
|
|
11
|
+
/**
|
|
12
|
+
* Compile a pattern string into tokens
|
|
13
|
+
* @param pattern The pattern string (e.g., "put :item in|into :container")
|
|
14
|
+
* @returns Compiled pattern with tokens and metadata
|
|
15
|
+
*/
|
|
16
|
+
compile(pattern: string): CompiledPattern;
|
|
17
|
+
/**
|
|
18
|
+
* Validate a pattern string
|
|
19
|
+
* @param pattern The pattern to validate
|
|
20
|
+
* @returns True if valid, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
validate(pattern: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Extract slot names from a pattern
|
|
25
|
+
* @param pattern The pattern string
|
|
26
|
+
* @returns Array of slot names
|
|
27
|
+
*/
|
|
28
|
+
extractSlots(pattern: string): string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Pattern syntax error
|
|
32
|
+
*/
|
|
33
|
+
export declare class PatternSyntaxError extends Error {
|
|
34
|
+
pattern: string;
|
|
35
|
+
position?: number | undefined;
|
|
36
|
+
constructor(message: string, pattern: string, position?: number | undefined);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=pattern-compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-compiler.d.ts","sourceRoot":"","sources":["../../src/grammar/pattern-compiler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAgB,MAAM,mBAAmB,CAAC;AAElE;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAAC;IAE1C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IAEnC;;;;OAIG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAGlC,OAAO,EAAE,MAAM;IACf,QAAQ,CAAC,EAAE,MAAM;gBAFxB,OAAO,EAAE,MAAM,EACR,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,YAAA;CAK3B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Pattern Compiler Interface
|
|
4
|
+
* @description Language-agnostic interface for compiling grammar patterns
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PatternSyntaxError = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Pattern syntax error
|
|
10
|
+
*/
|
|
11
|
+
class PatternSyntaxError extends Error {
|
|
12
|
+
pattern;
|
|
13
|
+
position;
|
|
14
|
+
constructor(message, pattern, position) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.pattern = pattern;
|
|
17
|
+
this.position = position;
|
|
18
|
+
this.name = 'PatternSyntaxError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.PatternSyntaxError = PatternSyntaxError;
|
|
22
|
+
//# sourceMappingURL=pattern-compiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-compiler.js","sourceRoot":"","sources":["../../src/grammar/pattern-compiler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA+BH;;GAEG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAGlC;IACA;IAHT,YACE,OAAe,EACR,OAAe,EACf,QAAiB;QAExB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAS;QAGxB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AATD,gDASC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Scope Builder Implementation
|
|
3
|
+
* @description Concrete implementation of the scope builder interface
|
|
4
|
+
*/
|
|
5
|
+
import { ScopeBuilder, ScopeConstraint, PropertyConstraint, FunctionConstraint } from './grammar-builder';
|
|
6
|
+
/**
|
|
7
|
+
* Concrete scope builder implementation
|
|
8
|
+
*/
|
|
9
|
+
export declare class ScopeBuilderImpl implements ScopeBuilder {
|
|
10
|
+
private constraint;
|
|
11
|
+
visible(): ScopeBuilder;
|
|
12
|
+
touchable(): ScopeBuilder;
|
|
13
|
+
carried(): ScopeBuilder;
|
|
14
|
+
nearby(): ScopeBuilder;
|
|
15
|
+
matching(constraint: PropertyConstraint | FunctionConstraint): ScopeBuilder;
|
|
16
|
+
kind(kind: string): ScopeBuilder;
|
|
17
|
+
orExplicitly(entityIds: string[]): ScopeBuilder;
|
|
18
|
+
orRule(ruleId: string): ScopeBuilder;
|
|
19
|
+
hasTrait(traitType: string): ScopeBuilder;
|
|
20
|
+
build(): ScopeConstraint;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a new scope builder
|
|
24
|
+
*/
|
|
25
|
+
export declare function scope(): ScopeBuilder;
|
|
26
|
+
//# sourceMappingURL=scope-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-builder.d.ts","sourceRoot":"","sources":["../../src/grammar/scope-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAG3B;;GAEG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACnD,OAAO,CAAC,UAAU,CAMhB;IAEF,OAAO,IAAI,YAAY;IAKvB,SAAS,IAAI,YAAY;IAKzB,OAAO,IAAI,YAAY;IAKvB,MAAM,IAAI,YAAY;IAKtB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,kBAAkB,GAAG,YAAY;IAK3E,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY;IAKhC,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,YAAY;IAK/C,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAKpC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY;IAKzC,KAAK,IAAI,eAAe;CAGzB;AAED;;GAEG;AACH,wBAAgB,KAAK,IAAI,YAAY,CAEpC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Scope Builder Implementation
|
|
4
|
+
* @description Concrete implementation of the scope builder interface
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ScopeBuilderImpl = void 0;
|
|
8
|
+
exports.scope = scope;
|
|
9
|
+
/**
|
|
10
|
+
* Concrete scope builder implementation
|
|
11
|
+
*/
|
|
12
|
+
class ScopeBuilderImpl {
|
|
13
|
+
constraint = {
|
|
14
|
+
base: 'all',
|
|
15
|
+
filters: [],
|
|
16
|
+
traitFilters: [],
|
|
17
|
+
explicitEntities: [],
|
|
18
|
+
includeRules: []
|
|
19
|
+
};
|
|
20
|
+
visible() {
|
|
21
|
+
this.constraint.base = 'visible';
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
touchable() {
|
|
25
|
+
this.constraint.base = 'touchable';
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
carried() {
|
|
29
|
+
this.constraint.base = 'carried';
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
nearby() {
|
|
33
|
+
this.constraint.base = 'nearby';
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
matching(constraint) {
|
|
37
|
+
this.constraint.filters.push(constraint);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
kind(kind) {
|
|
41
|
+
this.constraint.filters.push({ kind });
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
orExplicitly(entityIds) {
|
|
45
|
+
this.constraint.explicitEntities.push(...entityIds);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
orRule(ruleId) {
|
|
49
|
+
this.constraint.includeRules.push(ruleId);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
hasTrait(traitType) {
|
|
53
|
+
this.constraint.traitFilters.push(traitType);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
build() {
|
|
57
|
+
return { ...this.constraint };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.ScopeBuilderImpl = ScopeBuilderImpl;
|
|
61
|
+
/**
|
|
62
|
+
* Create a new scope builder
|
|
63
|
+
*/
|
|
64
|
+
function scope() {
|
|
65
|
+
return new ScopeBuilderImpl();
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=scope-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-builder.js","sourceRoot":"","sources":["../../src/grammar/scope-builder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA2EH,sBAEC;AAnED;;GAEG;AACH,MAAa,gBAAgB;IACnB,UAAU,GAAoB;QACpC,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,EAAE;QACX,YAAY,EAAE,EAAE;QAChB,gBAAgB,EAAE,EAAE;QACpB,YAAY,EAAE,EAAE;KACjB,CAAC;IAEF,OAAO;QACL,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,SAAS,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,SAAS;QACP,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,WAAW,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,SAAS,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,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