From b3b5d52426de5c818210185320d9471d7d653c95 Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Sat, 4 Feb 2023 23:30:25 +0000 Subject: [PATCH] Extension directories and natural language bundles --- README.md | 2 +- build.txt | 4 +- docs/core-module/2-up.html | 36 ++++ docs/inflections-module/3-dcl.html | 43 +++-- docs/inflections-module/3-vc.html | 6 +- docs/inflections-module/P-htitm.html | 7 +- docs/runtime-module/5-cnj.html | 2 +- docs/supervisor-module/2-ce.html | 2 +- docs/supervisor-module/2-cps.html | 2 +- docs/supervisor-module/4-ebm.html | 8 +- docs/supervisor-module/4-em.html | 2 +- docs/supervisor-module/5-ls.html | 4 +- docs/supervisor-module/5-ps2.html | 154 +++++++++++++----- .../Chapter 4/Extension Bundle Manager.w | 8 +- .../Chapter 4/Extension Manager.w | 2 +- .../Chapter 5/Language Services.w | 2 - .../Chapter 5/Project Services.w | 126 ++++++++++---- inform7/Figures/memory-diagnostics.txt | 18 +- inform7/Figures/timings-diagnostics.txt | 21 ++- .../BasicInformExtrasKit/kit_metadata.json | 2 +- .../Inter/BasicInformKit/kit_metadata.json | 2 +- .../Inter/CommandParserKit/kit_metadata.json | 2 +- .../EnglishLanguageKit/kit_metadata.json | 2 +- .../Inter/WorldModelKit/kit_metadata.json | 2 +- .../core-module/Chapter 2/Using Problems.w | 36 ++++ .../runtime-module/Chapter 5/Conjugations.w | 2 +- .../Chapter 3/Declensions.w | 43 +++-- .../Chapter 3/Verb Conjugation.w | 6 +- .../How To Include This Module.w | 8 +- 29 files changed, 409 insertions(+), 145 deletions(-) diff --git a/README.md b/README.md index f6021eee8..1c2770591 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Inform 7 -[Version](notes/versioning.md): 10.2.0-beta+6W20 'Krypton' (2 February 2023) +[Version](notes/versioning.md): 10.2.0-beta+6W21 'Krypton' (4 February 2023) ## About Inform diff --git a/build.txt b/build.txt index 810167e72..1af8b7300 100644 --- a/build.txt +++ b/build.txt @@ -1,3 +1,3 @@ Prerelease: beta -Build Date: 2 February 2023 -Build Number: 6W20 +Build Date: 4 February 2023 +Build Number: 6W21 diff --git a/docs/core-module/2-up.html b/docs/core-module/2-up.html index b108f8f53..d4d7308c3 100644 --- a/docs/core-module/2-up.html +++ b/docs/core-module/2-up.html @@ -385,6 +385,42 @@ a message which diagnoses the problem rather better. "in the Penalty Zone, say \"An alarm sounds.\")"); } +

§7.

+ +
define PREFORM_ERROR_INFLECTIONS_CALLBACK UsingProblems::inflections_problem
+
+
+void UsingProblems::inflections_problem(nonterminal *nt, inform_language *nl, text_stream *err) {
+    if (nl) Problems::quote_wording(1, nl->instance_name);
+    Problems::quote_stream(2, err);
+    text_stream *NT = Str::new();
+    if (nt) WRITE_TO(NT, "%V", nt->nonterminal_id);
+    LOOP_THROUGH_TEXT(pos, NT) {
+        if (Str::get(pos) == '<') Str::put(pos, '\'');
+        if (Str::get(pos) == '>') Str::put(pos, '\'');
+    }
+    Problems::quote_stream(3, NT);
+
+    Problems::issue_problem_begin(NULL, "preform-problem");
+    Problems::issue_problem_segment(
+        "An error occurred with the Preform syntax used to specify the grammar "
+        "of source text. If this occurs with English, that's a bug in the compiler, "
+        "and should be reported. But if it occurs with languages other than English, "
+        "there's an issue with the language definition, which should be reported "
+        "to its maintainer. At any rate, this compilation can't go further. ");
+    if (nt) {
+        Problems::issue_problem_segment(
+            "%PThe nonterminal causing problems is %3. ");
+    }
+    if (nl) {
+        Problems::issue_problem_segment(
+            "%PThe natural language affected is '%1'. ");
+    }
+    Problems::issue_problem_segment(
+        "%PThe problem as reported by Preform is: %2.");
+    Problems::issue_problem_end();
+}
+
diff --git a/docs/inflections-module/3-dcl.html b/docs/inflections-module/3-dcl.html index 5c3349d6d..24604040c 100644 --- a/docs/inflections-module/3-dcl.html +++ b/docs/inflections-module/3-dcl.html @@ -106,11 +106,11 @@ taken care of by what are less elegantly called int c = 0; for (production *pr = pl->first_pr; pr; pr = pr->next_pr) c++; if (c >= MAX_GRAMMATICAL_CASES) - internal_error("<grammatical-case-names> lists too many cases"); + Declensions::error(nt, nl, I"too many cases"); return c; } } - internal_error("<grammatical-case-names> not provided for this language"); + Declensions::error(nt, nl, I"not provided for this language"); return -1; } @@ -129,7 +129,7 @@ taken care of by what are less elegantly called if ((pr->first_pt == NULL) || (pr->first_pt->ptoken_category != FIXED_WORD_PTC) || (pr->first_pt->next_pt != NULL)) - internal_error("<grammatical-case-names> too complex"); + Declensions::error(nt, D->within_language, I"too complex"); if (c > 0) WRITE(", "); WRITE("%w: %W %W", Vocabulary::get_exemplar(pr->first_pt->ve_pt, TRUE), AD->wording_cased[c], D->wording_cased[c]); @@ -140,7 +140,7 @@ taken care of by what are less elegantly called return; } } - internal_error("<grammatical-case-names> not provided for this language"); + Declensions::error(nt, D->within_language, I"not provided for this language"); }

§4. And this function extracts the right form for a given case c: @@ -197,14 +197,16 @@ we will say that so does any inflected form of it: nl = DefaultLanguage::get(nl); declension D; D.within_language = nl; + int count = 0; for (production_list *pl = nt->first_pl; pl; pl = pl->next_pl) { if ((pl->definition_language == NULL) || (pl->definition_language == nl)) { + count++; for (production *pr = pl->first_pr; pr; pr = pr->next_pr) { if ((pr->first_pt == NULL) || (pr->first_pt->ptoken_category != FIXED_WORD_PTC) || (pr->first_pt->next_pt == NULL) || (pr->first_pt->next_pt->ptoken_category != NONTERMINAL_PTC)) - internal_error("line in <noun-declension> malformed"); + Declensions::error(nt, nl, I"line malformed"); wchar_t *gender_letter = Vocabulary::get_exemplar(pr->first_pt->ve_pt, FALSE); if ((gender_letter[0] == '*') || ((gender_letter[0] == 'm') && (gen == MASCULINE_GENDER)) || @@ -214,7 +216,10 @@ we will say that so does any inflected form of it: } } } - internal_error("no declension table terminated"); + if (count == 0) Declensions::error(nt, nl, + I"noun declensions seem not to be provided for this language"); + else Declensions::error(nt, nl, + I"noun declension table exists but was unterminated"); return D; } @@ -229,7 +234,7 @@ we will say that so does any inflected form of it: } else { if ((pr->first_pt->next_pt->next_pt->ptoken_category != NONTERMINAL_PTC) || (pr->first_pt->next_pt->next_pt->next_pt != NULL)) - internal_error("this line must end with two nonterminals"); + Declensions::error(nt, nl, I"line must end with two nonterminals"); nonterminal *tnt = pr->first_pt->next_pt->next_pt->nt_pt; D = Declensions::decline_from_groups(W, nl, gnt, tnt, gen, num, &found); } @@ -255,7 +260,8 @@ we will say that so does any inflected form of it: int c = 0, nc = Declensions::no_cases(nl); for (ptoken *pt = pr->first_pt->next_pt; pt; pt = pt->next_pt) { if (pt->ptoken_category != FIXED_WORD_PTC) - internal_error("NTs are not allowed in irregular decs"); + Declensions::error(gnt, nl, + I"nonterminals are not allowed in irregular declensions"); if (((num == SINGULAR_NUMBER) && (c < nc)) || ((num == PLURAL_NUMBER) && (c >= nc))) { TEMPORARY_TEXT(stem) TEMPORARY_TEXT(result) @@ -269,8 +275,10 @@ we will say that so does any inflected form of it: } c++; } - if (c < 2*nc) internal_error("too few cases in irregular ded"); - if (c > 2*nc) internal_error("too many cases in irregular dec"); + if (c < 2*nc) Declensions::error(gnt, nl, + I"too few cases in irregular declension"); + if (c > 2*nc) Declensions::error(gnt, nl, + I"too many cases in irregular declension"); return D; } } @@ -380,6 +388,21 @@ consists of a single word giving the rewriting instruction to use. return l; } +

§11.

+ +
+void Declensions::error(nonterminal *nt, NATURAL_LANGUAGE_WORDS_TYPE *nl, text_stream *err) {
+    #ifdef PREFORM_ERROR_INFLECTIONS_CALLBACK
+    PREFORM_ERROR_INFLECTIONS_CALLBACK(nt, nl, err);
+    #endif
+    #ifndef PREFORM_ERROR_INFLECTIONS_CALLBACK
+    WRITE_TO(STDERR, "Declension error in Preform syntax ");
+    if (nt) WRITE_TO(STDERR, "in the nonterminal '%V'", nt->nonterminal_id);
+    WRITE_TO(STDERR, ": %S\n", err);
+    internal_error("halted with Preform syntax error");
+    #endif
+}
+
diff --git a/docs/inflections-module/3-vc.html b/docs/inflections-module/3-vc.html index 5f37d1aa3..708e9c2fe 100644 --- a/docs/inflections-module/3-vc.html +++ b/docs/inflections-module/3-vc.html @@ -81,7 +81,7 @@ English it looks wasteful, since so many forms are the same, but for French #ifdef LINGUISTICS_MODULE struct verb *vc_conjugates; #endif - #ifdef VC_COMPILATION_LINGUISTICS_CALLBACK + #ifdef VC_COMPILATION_INFLECTIONS_CALLBACK struct verb_conjugation_compilation_data compilation_data; #endif int auxiliary_only; used only as an auxiliary, e.g. the "have" in "I have gone" @@ -271,8 +271,8 @@ anybody else try this one on.) vc->defined_in = nl; vc->auxiliary_only = avo_flag; vc->instance_of_verb = (niv_flag)?FALSE:TRUE; - #ifdef VC_COMPILATION_LINGUISTICS_CALLBACK - VC_COMPILATION_LINGUISTICS_CALLBACK(vc); + #ifdef VC_COMPILATION_INFLECTIONS_CALLBACK + VC_COMPILATION_INFLECTIONS_CALLBACK(vc); #endif Start by blanking out all the passive and active slots6.3.1; diff --git a/docs/inflections-module/P-htitm.html b/docs/inflections-module/P-htitm.html index c1f23056d..d8510ace4 100644 --- a/docs/inflections-module/P-htitm.html +++ b/docs/inflections-module/P-htitm.html @@ -90,11 +90,14 @@ normally calling the module, but then the module calls the parent back to ask for data or action.

-

This module has only one callbacks and it is optional: +

This module has only two callbacks and both are optional:

-