From b3b5d52426de5c818210185320d9471d7d653c95 Mon Sep 17 00:00:00 2001
From: Graham Nelson §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;
}
+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");
}
+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:
-