@lokascript/framework 2.10.0 → 2.11.1
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 +0 -2
- package/dist/api/create-dsl.d.ts +4 -2
- package/dist/api/create-dsl.d.ts.map +1 -1
- package/dist/api/index.js +18 -6
- package/dist/api/index.js.map +1 -1
- package/dist/index.cjs +18 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/__tests__/api-surface.test.ts +35 -0
- package/src/aot/registry-bridge.test.ts +5 -5
- package/src/api/create-dsl.test.ts +87 -5
- package/src/api/create-dsl.ts +42 -16
- package/src/api/domain-registry.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3029,14 +3029,26 @@ var MultilingualDSLImpl = class {
|
|
|
3029
3029
|
}
|
|
3030
3030
|
translate(input, fromLanguage, toLanguage) {
|
|
3031
3031
|
if ((0, import_intent3.isExplicitSyntax)(input)) return input;
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3032
|
+
let node;
|
|
3033
|
+
try {
|
|
3034
|
+
node = this.parseWithConfidence(input, fromLanguage).node;
|
|
3035
|
+
} catch (parseError) {
|
|
3036
|
+
if (this.hasGrammarProfile(fromLanguage) && this.hasGrammarProfile(toLanguage)) {
|
|
3037
|
+
return this.transformer.transform(input, fromLanguage, toLanguage);
|
|
3037
3038
|
}
|
|
3039
|
+
throw parseError;
|
|
3040
|
+
}
|
|
3041
|
+
const rendered = this.registry.getSupportedLanguages().includes(toLanguage) ? this.render(node, toLanguage) : null;
|
|
3042
|
+
if (rendered != null) return rendered;
|
|
3043
|
+
if (this.hasGrammarProfile(fromLanguage) && this.hasGrammarProfile(toLanguage)) {
|
|
3044
|
+
return this.transformer.transform(input, fromLanguage, toLanguage);
|
|
3038
3045
|
}
|
|
3039
|
-
|
|
3046
|
+
throw new Error(
|
|
3047
|
+
`translate() could not render action "${node.action}" in language "${toLanguage}": no custom renderer, domain renderer, or schema pattern covers it, and no grammar profile is configured for the transformer fallback. Either add "${toLanguage}" to the DSL's languages/renderer, or set 'grammarProfile' on its LanguageConfig in createMultilingualDSL() (parse/validate/compile do not need it).`
|
|
3048
|
+
);
|
|
3049
|
+
}
|
|
3050
|
+
hasGrammarProfile(language) {
|
|
3051
|
+
return this.profileProvider.getProfile(language) != null;
|
|
3040
3052
|
}
|
|
3041
3053
|
compile(input, language) {
|
|
3042
3054
|
if (!this.codeGenerator) {
|