@lokascript/framework 2.0.0
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/LICENSE +20 -0
- package/README.md +142 -0
- package/dist/aot/aot-orchestrator.d.ts +75 -0
- package/dist/aot/aot-orchestrator.d.ts.map +1 -0
- package/dist/aot/domain-scanner.d.ts +27 -0
- package/dist/aot/domain-scanner.d.ts.map +1 -0
- package/dist/aot/index.d.ts +8 -0
- package/dist/aot/index.d.ts.map +1 -0
- package/dist/aot/types.d.ts +103 -0
- package/dist/aot/types.d.ts.map +1 -0
- package/dist/api/create-dsl.d.ts +91 -0
- package/dist/api/create-dsl.d.ts.map +1 -0
- package/dist/api/dispatcher.d.ts +108 -0
- package/dist/api/dispatcher.d.ts.map +1 -0
- package/dist/api/domain-registry.d.ts +152 -0
- package/dist/api/domain-registry.d.ts.map +1 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +2082 -0
- package/dist/api/index.js.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +2674 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/logger.d.ts +32 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/pattern-matching/index.d.ts +6 -0
- package/dist/core/pattern-matching/index.d.ts.map +1 -0
- package/dist/core/pattern-matching/index.js +1239 -0
- package/dist/core/pattern-matching/index.js.map +1 -0
- package/dist/core/pattern-matching/pattern-matcher.d.ts +239 -0
- package/dist/core/pattern-matching/pattern-matcher.d.ts.map +1 -0
- package/dist/core/pattern-matching/utils/index.d.ts +6 -0
- package/dist/core/pattern-matching/utils/index.d.ts.map +1 -0
- package/dist/core/pattern-matching/utils/possessive-keywords.d.ts +38 -0
- package/dist/core/pattern-matching/utils/possessive-keywords.d.ts.map +1 -0
- package/dist/core/pattern-matching/utils/type-validation.d.ts +63 -0
- package/dist/core/pattern-matching/utils/type-validation.d.ts.map +1 -0
- package/dist/core/tokenization/base-tokenizer.d.ts +344 -0
- package/dist/core/tokenization/base-tokenizer.d.ts.map +1 -0
- package/dist/core/tokenization/char-classifiers.d.ts +56 -0
- package/dist/core/tokenization/char-classifiers.d.ts.map +1 -0
- package/dist/core/tokenization/default-extractors.d.ts +48 -0
- package/dist/core/tokenization/default-extractors.d.ts.map +1 -0
- package/dist/core/tokenization/extractors/index.d.ts +9 -0
- package/dist/core/tokenization/extractors/index.d.ts.map +1 -0
- package/dist/core/tokenization/extractors/operator.d.ts +23 -0
- package/dist/core/tokenization/extractors/operator.d.ts.map +1 -0
- package/dist/core/tokenization/extractors/punctuation.d.ts +22 -0
- package/dist/core/tokenization/extractors/punctuation.d.ts.map +1 -0
- package/dist/core/tokenization/extractors.d.ts +61 -0
- package/dist/core/tokenization/extractors.d.ts.map +1 -0
- package/dist/core/tokenization/index.d.ts +11 -0
- package/dist/core/tokenization/index.d.ts.map +1 -0
- package/dist/core/tokenization/index.js +1345 -0
- package/dist/core/tokenization/index.js.map +1 -0
- package/dist/core/tokenization/morphology/index.d.ts +5 -0
- package/dist/core/tokenization/morphology/index.d.ts.map +1 -0
- package/dist/core/tokenization/morphology/types.d.ts +110 -0
- package/dist/core/tokenization/morphology/types.d.ts.map +1 -0
- package/dist/core/tokenization/token-utils.d.ts +111 -0
- package/dist/core/tokenization/token-utils.d.ts.map +1 -0
- package/dist/core/types.d.ts +382 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +108 -0
- package/dist/core/types.js.map +1 -0
- package/dist/generation/diagnostics.d.ts +120 -0
- package/dist/generation/diagnostics.d.ts.map +1 -0
- package/dist/generation/index.d.ts +7 -0
- package/dist/generation/index.d.ts.map +1 -0
- package/dist/generation/index.js +339 -0
- package/dist/generation/index.js.map +1 -0
- package/dist/generation/pattern-generator.d.ts +48 -0
- package/dist/generation/pattern-generator.d.ts.map +1 -0
- package/dist/generation/renderer.d.ts +115 -0
- package/dist/generation/renderer.d.ts.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 +391 -0
- package/dist/grammar/index.js.map +1 -0
- package/dist/grammar/transformer.d.ts +56 -0
- package/dist/grammar/transformer.d.ts.map +1 -0
- package/dist/grammar/types.d.ts +236 -0
- package/dist/grammar/types.d.ts.map +1 -0
- package/dist/index.cjs +4454 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4336 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/dictionary.d.ts +82 -0
- package/dist/interfaces/dictionary.d.ts.map +1 -0
- package/dist/interfaces/index.d.ts +10 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/profile-provider.d.ts +67 -0
- package/dist/interfaces/profile-provider.d.ts.map +1 -0
- package/dist/interfaces/value-extractor.d.ts +168 -0
- package/dist/interfaces/value-extractor.d.ts.map +1 -0
- package/dist/multilingual/index.d.ts +8 -0
- package/dist/multilingual/index.d.ts.map +1 -0
- package/dist/multilingual/index.js +1 -0
- package/dist/multilingual/index.js.map +1 -0
- package/dist/parsing/index.d.ts +8 -0
- package/dist/parsing/index.d.ts.map +1 -0
- package/dist/parsing/index.js +1415 -0
- package/dist/parsing/index.js.map +1 -0
- package/dist/parsing/multi-statement.d.ts +265 -0
- package/dist/parsing/multi-statement.d.ts.map +1 -0
- package/dist/schema/command-schema.d.ts +78 -0
- package/dist/schema/command-schema.d.ts.map +1 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +25 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/test-setup.d.ts +9 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/testing/index.d.ts +50 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +16969 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +122 -0
- package/src/__test__/fixtures/sql-dsl.ts +232 -0
- package/src/__test__/sql-integration.test.ts +189 -0
- package/src/__test__/test-utils.ts +260 -0
- package/src/aot/aot-orchestrator.test.ts +413 -0
- package/src/aot/aot-orchestrator.ts +238 -0
- package/src/aot/domain-scanner.ts +178 -0
- package/src/aot/index.ts +8 -0
- package/src/aot/types.ts +124 -0
- package/src/api/create-dsl.ts +367 -0
- package/src/api/dispatcher.test.ts +336 -0
- package/src/api/dispatcher.ts +222 -0
- package/src/api/domain-registry.test.ts +336 -0
- package/src/api/domain-registry.ts +500 -0
- package/src/api/index.ts +7 -0
- package/src/core/index.ts +7 -0
- package/src/core/logger.ts +130 -0
- package/src/core/pattern-matching/index.ts +6 -0
- package/src/core/pattern-matching/pattern-matcher.test.ts +900 -0
- package/src/core/pattern-matching/pattern-matcher.ts +1548 -0
- package/src/core/pattern-matching/pattern-matcher.ts.backup +1267 -0
- package/src/core/pattern-matching/utils/index.ts +6 -0
- package/src/core/pattern-matching/utils/possessive-keywords.ts +55 -0
- package/src/core/pattern-matching/utils/type-validation.test.ts +316 -0
- package/src/core/pattern-matching/utils/type-validation.ts +134 -0
- package/src/core/tokenization/base-tokenizer.ts +916 -0
- package/src/core/tokenization/char-classifiers.ts +79 -0
- package/src/core/tokenization/create-simple-tokenizer.test.ts +260 -0
- package/src/core/tokenization/default-extractors.ts +69 -0
- package/src/core/tokenization/extractors/index.ts +9 -0
- package/src/core/tokenization/extractors/operator.ts +75 -0
- package/src/core/tokenization/extractors/punctuation.ts +39 -0
- package/src/core/tokenization/extractors.ts +452 -0
- package/src/core/tokenization/index.ts +11 -0
- package/src/core/tokenization/morphology/index.ts +5 -0
- package/src/core/tokenization/morphology/types.ts +211 -0
- package/src/core/tokenization/token-utils.ts +252 -0
- package/src/core/types.ts +589 -0
- package/src/generation/diagnostics.test.ts +171 -0
- package/src/generation/diagnostics.ts +239 -0
- package/src/generation/index.ts +7 -0
- package/src/generation/pattern-generator.test.ts +430 -0
- package/src/generation/pattern-generator.ts +315 -0
- package/src/generation/renderer.test.ts +266 -0
- package/src/generation/renderer.ts +244 -0
- package/src/grammar/index.ts +12 -0
- package/src/grammar/transformer.ts +159 -0
- package/src/grammar/types.ts +630 -0
- package/src/index.ts +157 -0
- package/src/interfaces/dictionary.ts +123 -0
- package/src/interfaces/index.ts +10 -0
- package/src/interfaces/profile-provider.ts +88 -0
- package/src/interfaces/value-extractor.ts +435 -0
- package/src/multilingual/index.ts +9 -0
- package/src/parsing/index.ts +27 -0
- package/src/parsing/multi-statement.test.ts +480 -0
- package/src/parsing/multi-statement.ts +648 -0
- package/src/schema/command-schema.ts +118 -0
- package/src/schema/index.ts +5 -0
- package/src/test-setup.ts +45 -0
- package/src/testing/index.ts +137 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dictionary Interface - Keyword Translation
|
|
3
|
+
*
|
|
4
|
+
* Provides keyword translations between languages.
|
|
5
|
+
* DSLs implement this to provide their domain-specific translations.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Dictionary provides keyword translations between languages.
|
|
9
|
+
*/
|
|
10
|
+
export interface Dictionary {
|
|
11
|
+
/**
|
|
12
|
+
* Look up canonical form from localized keyword.
|
|
13
|
+
*
|
|
14
|
+
* @param localizedWord - Word in target language (e.g., 'トグル', 'alternar')
|
|
15
|
+
* @param language - Language code
|
|
16
|
+
* @returns Canonical form (e.g., 'toggle') or undefined
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* dictionary.lookup('トグル', 'ja') // → 'toggle'
|
|
20
|
+
* dictionary.lookup('alternar', 'es') // → 'toggle'
|
|
21
|
+
*/
|
|
22
|
+
lookup(localizedWord: string, language: string): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Translate canonical keyword to target language.
|
|
25
|
+
*
|
|
26
|
+
* @param canonical - Canonical form (e.g., 'toggle')
|
|
27
|
+
* @param targetLanguage - Target language code
|
|
28
|
+
* @returns Localized form or undefined
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* dictionary.translate('toggle', 'ja') // → 'トグル'
|
|
32
|
+
* dictionary.translate('toggle', 'es') // → 'alternar'
|
|
33
|
+
*/
|
|
34
|
+
translate(canonical: string, targetLanguage: string): string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Get all translations of a word across all supported languages.
|
|
37
|
+
*
|
|
38
|
+
* @param word - Word to translate
|
|
39
|
+
* @param sourceLanguage - Source language
|
|
40
|
+
* @returns Map of language code to translation
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* dictionary.getAllTranslations('toggle', 'en')
|
|
44
|
+
* // → { ja: 'トグル', es: 'alternar', ko: '토글', ... }
|
|
45
|
+
*/
|
|
46
|
+
getAllTranslations(word: string, sourceLanguage: string): Record<string, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Optional: Find what category a word belongs to.
|
|
49
|
+
* Useful for organizing translations by domain (commands, modifiers, events, etc.).
|
|
50
|
+
*/
|
|
51
|
+
getCategory?(word: string, language: string): string | undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Simple in-memory dictionary implementation.
|
|
55
|
+
* Suitable for small DSLs or prototyping.
|
|
56
|
+
*/
|
|
57
|
+
export declare class InMemoryDictionary implements Dictionary {
|
|
58
|
+
private translations;
|
|
59
|
+
/**
|
|
60
|
+
* @param translations - Map of language code to canonical→localized mappings
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* new InMemoryDictionary({
|
|
64
|
+
* en: { select: 'select', insert: 'insert' },
|
|
65
|
+
* es: { select: 'seleccionar', insert: 'insertar' },
|
|
66
|
+
* ja: { select: '選択', insert: '挿入' }
|
|
67
|
+
* })
|
|
68
|
+
*/
|
|
69
|
+
constructor(translations: Record<string, Record<string, string>>);
|
|
70
|
+
lookup(word: string, language: string): string | undefined;
|
|
71
|
+
translate(canonical: string, targetLanguage: string): string | undefined;
|
|
72
|
+
getAllTranslations(word: string, sourceLanguage: string): Record<string, string>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Null dictionary - no translations (useful for single-language DSLs).
|
|
76
|
+
*/
|
|
77
|
+
export declare class NullDictionary implements Dictionary {
|
|
78
|
+
lookup(word: string, _language: string): string | undefined;
|
|
79
|
+
translate(canonical: string, _targetLanguage: string): string | undefined;
|
|
80
|
+
getAllTranslations(word: string, _sourceLanguage: string): Record<string, string>;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=dictionary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../src/interfaces/dictionary.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAEpE;;;;;;;;;;OAUG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAEzE;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjF;;;OAGG;IACH,WAAW,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAClE;AAED;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,UAAU;IAWvC,OAAO,CAAC,YAAY;IAVhC;;;;;;;;;OASG;gBACiB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAExE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAc1D,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIxE,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAajF;AAED;;GAEG;AACH,qBAAa,cAAe,YAAW,UAAU;IAC/C,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI3D,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIzE,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAGlF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core interfaces for dependency injection
|
|
3
|
+
*
|
|
4
|
+
* These interfaces define pluggable components that DSLs can implement
|
|
5
|
+
* to customize framework behavior.
|
|
6
|
+
*/
|
|
7
|
+
export * from './dictionary';
|
|
8
|
+
export * from './profile-provider';
|
|
9
|
+
export * from './value-extractor';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile Provider Interface - Language Profile Access
|
|
3
|
+
*
|
|
4
|
+
* Provides language profiles for grammar transformation.
|
|
5
|
+
* DSLs implement this to provide their domain-specific profiles.
|
|
6
|
+
*/
|
|
7
|
+
import type { LanguageProfile } from '../grammar';
|
|
8
|
+
/**
|
|
9
|
+
* Provides language profiles for transformation.
|
|
10
|
+
*/
|
|
11
|
+
export interface ProfileProvider {
|
|
12
|
+
/**
|
|
13
|
+
* Get language profile by code.
|
|
14
|
+
*
|
|
15
|
+
* @param language - ISO 639-1 code (e.g., 'en', 'ja', 'es')
|
|
16
|
+
* @returns Language profile or undefined if not supported
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const profile = provider.getProfile('ja');
|
|
20
|
+
* console.log(profile.wordOrder); // 'SOV'
|
|
21
|
+
*/
|
|
22
|
+
getProfile(language: string): LanguageProfile | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Get all supported language codes.
|
|
25
|
+
*
|
|
26
|
+
* @returns Array of ISO 639-1 codes
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* provider.getSupportedLanguages() // → ['en', 'ja', 'es', 'ko']
|
|
30
|
+
*/
|
|
31
|
+
getSupportedLanguages(): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Check if a language is supported.
|
|
34
|
+
*
|
|
35
|
+
* @param language - Language code to check
|
|
36
|
+
* @returns True if language is supported
|
|
37
|
+
*/
|
|
38
|
+
hasLanguage(language: string): boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Simple in-memory profile provider.
|
|
42
|
+
*/
|
|
43
|
+
export declare class InMemoryProfileProvider implements ProfileProvider {
|
|
44
|
+
private profiles;
|
|
45
|
+
/**
|
|
46
|
+
* @param profiles - Map of language code to profile
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* new InMemoryProfileProvider({
|
|
50
|
+
* en: { code: 'en', wordOrder: 'SVO', ... },
|
|
51
|
+
* ja: { code: 'ja', wordOrder: 'SOV', ... }
|
|
52
|
+
* })
|
|
53
|
+
*/
|
|
54
|
+
constructor(profiles: Record<string, LanguageProfile>);
|
|
55
|
+
getProfile(language: string): LanguageProfile | undefined;
|
|
56
|
+
getSupportedLanguages(): string[];
|
|
57
|
+
hasLanguage(language: string): boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Null profile provider - for DSLs that don't need grammar transformation.
|
|
61
|
+
*/
|
|
62
|
+
export declare class NullProfileProvider implements ProfileProvider {
|
|
63
|
+
getProfile(_language: string): LanguageProfile | undefined;
|
|
64
|
+
getSupportedLanguages(): string[];
|
|
65
|
+
hasLanguage(_language: string): boolean;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=profile-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-provider.d.ts","sourceRoot":"","sources":["../../src/interfaces/profile-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;OASG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAAC;IAE1D;;;;;;;OAOG;IACH,qBAAqB,IAAI,MAAM,EAAE,CAAC;IAElC;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CACxC;AAED;;GAEG;AACH,qBAAa,uBAAwB,YAAW,eAAe;IAUjD,OAAO,CAAC,QAAQ;IAT5B;;;;;;;;OAQG;gBACiB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAE7D,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIzD,qBAAqB,IAAI,MAAM,EAAE;IAIjC,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAGvC;AAED;;GAEG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IACzD,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAI1D,qBAAqB,IAAI,MAAM,EAAE;IAIjC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAGxC"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value Extractor Interface - Pluggable Tokenization
|
|
3
|
+
*
|
|
4
|
+
* Extracts typed values from input strings.
|
|
5
|
+
* DSLs can provide custom extractors for their domain-specific syntax.
|
|
6
|
+
*
|
|
7
|
+
* Includes the ContextAwareExtractor extension for extractors that need
|
|
8
|
+
* access to tokenizer state (keyword maps, morphological normalizers, etc.).
|
|
9
|
+
*/
|
|
10
|
+
import type { MorphologicalNormalizer } from '../core/tokenization/morphology/types';
|
|
11
|
+
/**
|
|
12
|
+
* Keyword entry for tokenizer - maps native word to normalized English form.
|
|
13
|
+
* Re-exported here so ContextAwareExtractor consumers can use it without
|
|
14
|
+
* depending on the base-tokenizer module directly.
|
|
15
|
+
*/
|
|
16
|
+
export interface KeywordEntry {
|
|
17
|
+
readonly native: string;
|
|
18
|
+
readonly normalized: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Extraction result with value and consumed length.
|
|
22
|
+
*/
|
|
23
|
+
export interface ExtractionResult {
|
|
24
|
+
/** The extracted value */
|
|
25
|
+
readonly value: string;
|
|
26
|
+
/** Number of characters consumed */
|
|
27
|
+
readonly length: number;
|
|
28
|
+
/** Optional metadata about the extraction */
|
|
29
|
+
readonly metadata?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Value extractor - identifies and extracts typed values from input.
|
|
33
|
+
*/
|
|
34
|
+
export interface ValueExtractor {
|
|
35
|
+
/** Name of this extractor (for debugging) */
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/**
|
|
38
|
+
* Check if this extractor can handle input at position.
|
|
39
|
+
*
|
|
40
|
+
* @param input - Full input string
|
|
41
|
+
* @param position - Current position
|
|
42
|
+
* @returns True if this extractor should try
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // CSS selector extractor
|
|
46
|
+
* canExtract('#button', 0) // → true (starts with #)
|
|
47
|
+
* canExtract('button', 0) // → false
|
|
48
|
+
*/
|
|
49
|
+
canExtract(input: string, position: number): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Extract value from input at position.
|
|
52
|
+
*
|
|
53
|
+
* @param input - Full input string
|
|
54
|
+
* @param position - Start position
|
|
55
|
+
* @returns Extraction result or null if extraction failed
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* extract('#button', 0) // → { value: '#button', length: 7 }
|
|
59
|
+
* extract('button', 0) // → null (can't extract CSS selector)
|
|
60
|
+
*/
|
|
61
|
+
extract(input: string, position: number): ExtractionResult | null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* String literal extractor - handles quoted strings.
|
|
65
|
+
*/
|
|
66
|
+
export declare class StringLiteralExtractor implements ValueExtractor {
|
|
67
|
+
readonly name = "string-literal";
|
|
68
|
+
canExtract(input: string, position: number): boolean;
|
|
69
|
+
extract(input: string, position: number): ExtractionResult | null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Number extractor - handles integers and floats.
|
|
73
|
+
*/
|
|
74
|
+
export declare class NumberExtractor implements ValueExtractor {
|
|
75
|
+
readonly name = "number";
|
|
76
|
+
canExtract(input: string, position: number): boolean;
|
|
77
|
+
extract(input: string, position: number): ExtractionResult | null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Identifier extractor - handles variable/property names.
|
|
81
|
+
*/
|
|
82
|
+
export declare class IdentifierExtractor implements ValueExtractor {
|
|
83
|
+
readonly name = "identifier";
|
|
84
|
+
canExtract(input: string, position: number): boolean;
|
|
85
|
+
extract(input: string, position: number): ExtractionResult | null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Unicode identifier extractor - handles non-Latin scripts.
|
|
89
|
+
*
|
|
90
|
+
* Matches contiguous runs of Unicode letters, numbers, and combining marks
|
|
91
|
+
* that aren't ASCII (ASCII identifiers are handled by IdentifierExtractor).
|
|
92
|
+
* Essential for DSLs supporting CJK, Arabic, Cyrillic, Devanagari, etc.
|
|
93
|
+
*/
|
|
94
|
+
export declare class UnicodeIdentifierExtractor implements ValueExtractor {
|
|
95
|
+
readonly name = "unicode-identifier";
|
|
96
|
+
canExtract(input: string, position: number): boolean;
|
|
97
|
+
extract(input: string, position: number): ExtractionResult | null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Whitespace extractor - handles spaces, tabs, newlines.
|
|
101
|
+
*/
|
|
102
|
+
export declare class WhitespaceExtractor implements ValueExtractor {
|
|
103
|
+
readonly name = "whitespace";
|
|
104
|
+
canExtract(input: string, position: number): boolean;
|
|
105
|
+
extract(input: string, position: number): ExtractionResult | null;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Tokenizer context provided to context-aware extractors.
|
|
109
|
+
* Gives extractors access to tokenizer state without tight coupling.
|
|
110
|
+
*/
|
|
111
|
+
export interface TokenizerContext {
|
|
112
|
+
/** ISO 639-1 language code */
|
|
113
|
+
readonly language: string;
|
|
114
|
+
/** Text direction */
|
|
115
|
+
readonly direction: 'ltr' | 'rtl';
|
|
116
|
+
/**
|
|
117
|
+
* Look up a keyword by its native form.
|
|
118
|
+
* Returns keyword entry with normalized form, or undefined if not found.
|
|
119
|
+
*/
|
|
120
|
+
lookupKeyword(native: string): KeywordEntry | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Check if a word is a known keyword.
|
|
123
|
+
*/
|
|
124
|
+
isKeyword(native: string): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Check if a known keyword starts at the given position.
|
|
127
|
+
* Useful for word boundary detection in non-space languages.
|
|
128
|
+
*/
|
|
129
|
+
isKeywordStart(input: string, position: number): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Optional morphological normalizer for this language.
|
|
132
|
+
*/
|
|
133
|
+
readonly normalizer?: MorphologicalNormalizer;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Context-aware extractor - has access to tokenizer state.
|
|
137
|
+
*
|
|
138
|
+
* Use this for extractors that need:
|
|
139
|
+
* - Keyword lookup (for normalization)
|
|
140
|
+
* - Morphological analysis (for conjugation handling)
|
|
141
|
+
* - Language-specific rules
|
|
142
|
+
*
|
|
143
|
+
* For stateless extractors (strings, numbers, operators), use ValueExtractor.
|
|
144
|
+
*/
|
|
145
|
+
export interface ContextAwareExtractor extends ValueExtractor {
|
|
146
|
+
/**
|
|
147
|
+
* Set the tokenizer context.
|
|
148
|
+
* Called once by the tokenizer during registration.
|
|
149
|
+
*/
|
|
150
|
+
setContext(context: TokenizerContext): void;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Type guard to check if an extractor is context-aware.
|
|
154
|
+
*/
|
|
155
|
+
export declare function isContextAwareExtractor(extractor: ValueExtractor | ContextAwareExtractor): extractor is ContextAwareExtractor;
|
|
156
|
+
/**
|
|
157
|
+
* Create a TokenizerContext from a tokenizer instance.
|
|
158
|
+
* Works with any object that exposes the required methods.
|
|
159
|
+
*/
|
|
160
|
+
export declare function createTokenizerContext(tokenizer: {
|
|
161
|
+
language: string;
|
|
162
|
+
direction: 'ltr' | 'rtl';
|
|
163
|
+
lookupKeyword(native: string): KeywordEntry | undefined;
|
|
164
|
+
isKeyword(native: string): boolean;
|
|
165
|
+
isKeywordStart(input: string, position: number): boolean;
|
|
166
|
+
normalizer?: MorphologicalNormalizer;
|
|
167
|
+
}): TokenizerContext;
|
|
168
|
+
//# sourceMappingURL=value-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"value-extractor.d.ts","sourceRoot":"","sources":["../../src/interfaces/value-extractor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAMrF;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AA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wBAAgB,uBAAuB,CACrC,SAAS,EAAE,cAAc,GAAG,qBAAqB,GAChD,SAAS,IAAI,qBAAqB,CAEpC;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;IACzB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;IACxD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IACzD,UAAU,CAAC,EAAE,uBAAuB,CAAC;CACtC,GAAG,gBAAgB,CAcnB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multilingual support - language profiles and templates
|
|
3
|
+
*
|
|
4
|
+
* TODO: Extract language profile templates from semantic package
|
|
5
|
+
* For now, this module is a placeholder for future language profile utilities.
|
|
6
|
+
*/
|
|
7
|
+
export type { LanguageProfile, WordOrder, AdpositionType, MorphologyType } from '../grammar';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/multilingual/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsing infrastructure
|
|
3
|
+
*/
|
|
4
|
+
export type { SemanticNode, TokenStream, LanguageTokenizer } from '../core/types';
|
|
5
|
+
export { PatternMatcher } from '../core/pattern-matching';
|
|
6
|
+
export { createMultiStatementParser, accumulateBlocks } from './multi-statement';
|
|
7
|
+
export type { MultiStatementParser, MultiStatementConfig, MultiStatementResult, SplitConfig, KeywordConfig, KeywordMap, WordOrderHint, ContinuationConfig, StatementPreprocessor, PreprocessorContext, ParsedStatement, StatementError, BlockConfig, BlockResult, StatementBlock, } from './multi-statement';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parsing/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACjF,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,WAAW,EACX,WAAW,EACX,cAAc,GACf,MAAM,mBAAmB,CAAC"}
|