From 5d4586387c6b7405cd45e43f04c984583cd76bb3 Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Sat, 22 Apr 2023 22:47:10 +0100 Subject: [PATCH] Fix for Jira bug I7-2334 --- docs/building-module/2-is.html | 5 ++ docs/building-module/P-wtmd.html | 2 +- docs/core-module/1-wtc.html | 2 +- docs/core-module/2-pwst.html | 25 ++++++++ inform7/Figures/timings-diagnostics.txt | 63 ++++++++++--------- .../Test Problems/PM_InterSchemaErrors.txt | 4 ++ .../_Results_Ideal/PM_InterSchemaErrors.txt | 13 ++++ .../Chapter 2/Problems With Source Text.w | 24 +++++++ .../building-module/Chapter 2/Inter Schemas.w | 5 ++ .../Preliminaries/What This Module Does.w | 2 +- 10 files changed, 111 insertions(+), 34 deletions(-) create mode 100644 inform7/Tests/Test Problems/PM_InterSchemaErrors.txt create mode 100644 inform7/Tests/Test Problems/_Results_Ideal/PM_InterSchemaErrors.txt diff --git a/docs/building-module/2-is.html b/docs/building-module/2-is.html index a1f547915..50a075944 100644 --- a/docs/building-module/2-is.html +++ b/docs/building-module/2-is.html @@ -750,12 +750,17 @@ which, of course, it usually isn't.
 void InterSchemas::internal_error_on_schema_errors(inter_schema *sch) {
     if (LinkedLists::len(sch->parsing_errors) > 0) {
+        #ifdef CORE_MODULE
+        SourceProblems::inter_schema_errors(sch);
+        #endif
+        #ifndef CORE_MODULE
         WRITE_TO(STDERR, "Parsing error(s) in the internal schema '%S':\n",
             sch->converted_from);
         schema_parsing_error *err;
         LOOP_OVER_LINKED_LIST(err, schema_parsing_error, sch->parsing_errors)
             WRITE_TO(STDERR, "- %S\n", err->message);
         internal_error("malformed schema");
+        #endif
     }
 }
 
diff --git a/docs/building-module/P-wtmd.html b/docs/building-module/P-wtmd.html index ab77c8afd..282ca5e22 100644 --- a/docs/building-module/P-wtmd.html +++ b/docs/building-module/P-wtmd.html @@ -301,7 +301,7 @@ hierarchy: these functions are always called in matching ways.

§8. The pipeline module makes heavy use of the Produce API. Surprising, -inform7 calls it in only a few places — but in fact that it is because +inform7 calls it in only a few places — but in fact that is because it provides still another middleware layer on top. See Emit (in runtime). But it's really only a very thin layer, allowing the caller not to have to pass the I argument to every call (because it will always be the Inter tree diff --git a/docs/core-module/1-wtc.html b/docs/core-module/1-wtc.html index 29e824e2a..4256e73a0 100644 --- a/docs/core-module/1-wtc.html +++ b/docs/core-module/1-wtc.html @@ -246,7 +246,7 @@ rough stages. Twenty is plenty. return inform7_task->project->as_copy->edition; } -parse_node_tree *Task::syntax_tree(void) { +parse_node_tree *Task::syntax_tree(void) { return latest_syntax_tree; } diff --git a/docs/core-module/2-pwst.html b/docs/core-module/2-pwst.html index 1f1154f11..52dd2b64b 100644 --- a/docs/core-module/2-pwst.html +++ b/docs/core-module/2-pwst.html @@ -650,6 +650,31 @@ group. Problems::quote_stream(N, name); } +

§2. These are errors generated by the building module, but which we want to +tidy up and present in the usual Inform 7 way. +

+ +
+void SourceProblems::inter_schema_errors(inter_schema *sch) {
+    Problems::quote_source(1, current_sentence);
+    Problems::quote_stream(2, sch->converted_from);
+    StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_InterSchemaErrors));
+    Problems::issue_problem_segment(
+        "In the sentence %1, you use a fragment of code written in Inform 6 "
+        "syntax which seems to be malformed in some way. I delegate all that "
+        "work to a lesser compiler: I gave it '%2' to compile, and it came "
+        "back with this: ");
+    schema_parsing_error *err;
+    int c = 1;
+    LOOP_OVER_LINKED_LIST(err, schema_parsing_error, sch->parsing_errors) {
+        Problems::quote_stream(1, err->message);
+        Problems::quote_number(2, &c);
+        Problems::issue_problem_segment("%P%2. %1 ");
+        c++;
+    }
+    Problems::issue_problem_end();
+}
+
diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt index 3c26590a8..c26f852ca 100644 --- a/inform7/Figures/timings-diagnostics.txt +++ b/inform7/Figures/timings-diagnostics.txt @@ -1,32 +1,33 @@ 100.0% in inform7 run - 70.7% in compilation to Inter - 49.8% in //Sequence::undertake_queued_tasks// - 4.9% in //MajorNodes::pre_pass// - 3.5% in //MajorNodes::pass_1// - 1.8% in //ImperativeDefinitions::assess_all// - 1.6% in //RTPhrasebook::compile_entries// - 1.4% in //RTKindConstructors::compile// - 1.0% in //Sequence::lint_inter// - 0.6% in //MajorNodes::pass_2// - 0.6% in //Sequence::undertake_queued_tasks// - 0.6% in //World::stage_V// - 0.4% in //ImperativeDefinitions::compile_first_block// - 0.4% in //Sequence::undertake_queued_tasks// - 0.2% in //CompletionModule::compile// - 0.2% in //InferenceSubjects::emit_all// - 0.2% in //RTKindConstructors::compile_permissions// - 0.2% in //Task::make_built_in_kind_constructors// - 2.9% not specifically accounted for - 25.9% in running Inter pipeline - 10.1% in step 14/15: generate inform6 -> auto.inf - 5.7% in step 5/15: load-binary-kits - 5.3% in step 6/15: make-synoptic-module - 1.8% in step 9/15: make-identifiers-unique - 0.4% in step 12/15: eliminate-redundant-operations - 0.4% in step 4/15: compile-splats - 0.4% in step 7/15: shorten-wiring - 0.2% in step 11/15: eliminate-redundant-labels - 0.2% in step 8/15: detect-indirect-calls - 1.2% not specifically accounted for - 3.0% in supervisor - 0.3% not specifically accounted for + 70.5% in compilation to Inter + 50.3% in //Sequence::undertake_queued_tasks// + 4.6% in //MajorNodes::pre_pass// + 3.3% in //MajorNodes::pass_1// + 1.7% in //ImperativeDefinitions::assess_all// + 1.5% in //RTPhrasebook::compile_entries// + 1.3% in //RTKindConstructors::compile// + 1.1% in //Sequence::lint_inter// + 0.5% in //MajorNodes::pass_2// + 0.5% in //Sequence::undertake_queued_tasks// + 0.5% in //World::stage_V// + 0.3% in //ImperativeDefinitions::compile_first_block// + 0.3% in //Sequence::undertake_queued_tasks// + 0.1% in //Closures::compile_closures// + 0.1% in //CompletionModule::compile// + 0.1% in //InferenceSubjects::emit_all// + 0.1% in //RTKindConstructors::compile_permissions// + 0.1% in //Task::make_built_in_kind_constructors// + 2.8% not specifically accounted for + 26.1% in running Inter pipeline + 9.7% in step 14/15: generate inform6 -> auto.inf + 5.8% in step 5/15: load-binary-kits + 5.4% in step 6/15: make-synoptic-module + 1.7% in step 9/15: make-identifiers-unique + 0.3% in step 12/15: eliminate-redundant-operations + 0.3% in step 4/15: compile-splats + 0.3% in step 7/15: shorten-wiring + 0.3% in step 8/15: detect-indirect-calls + 0.1% in step 11/15: eliminate-redundant-labels + 1.5% not specifically accounted for + 2.9% in supervisor + 0.4% not specifically accounted for diff --git a/inform7/Tests/Test Problems/PM_InterSchemaErrors.txt b/inform7/Tests/Test Problems/PM_InterSchemaErrors.txt new file mode 100644 index 000000000..cc7637484 --- /dev/null +++ b/inform7/Tests/Test Problems/PM_InterSchemaErrors.txt @@ -0,0 +1,4 @@ +Laboratory is a room. + +Definition: an object is foo rather than bar if I6 condition "(" + says so (it is broken). diff --git a/inform7/Tests/Test Problems/_Results_Ideal/PM_InterSchemaErrors.txt b/inform7/Tests/Test Problems/_Results_Ideal/PM_InterSchemaErrors.txt new file mode 100644 index 000000000..269b00e52 --- /dev/null +++ b/inform7/Tests/Test Problems/_Results_Ideal/PM_InterSchemaErrors.txt @@ -0,0 +1,13 @@ +Inform 7 v10.2.0 has started. +I've now read your source text, which is 21 words long. +I've also read Basic Inform by Graham Nelson, which is 7792 words long. +I've also read English Language by Graham Nelson, which is 2330 words long. +I've also read Standard Rules by Graham Nelson, which is 34311 words long. +Problem__ PM_InterSchemaErrors + >--> In the sentence 'an object is foo rather than bar if I6 condition + "("says so (it is broken)' (source text, line 3), you use a fragment of + code written in Inform 6 syntax which seems to be malformed in some way. I + delegate all that work to a lesser compiler: I gave it '(()' to compile, + and it came back with this: 1. unexpected '(' 2. unexpected '(' 3. + unexpected ')' +Inform 7 has finished. diff --git a/inform7/core-module/Chapter 2/Problems With Source Text.w b/inform7/core-module/Chapter 2/Problems With Source Text.w index abc77d2de..5d3a962bc 100644 --- a/inform7/core-module/Chapter 2/Problems With Source Text.w +++ b/inform7/core-module/Chapter 2/Problems With Source Text.w @@ -593,3 +593,27 @@ void SourceProblems::quote_genre(int N, copy_error *CE) { if (Str::eq(name, I"extensionbundle")) name = I"extension"; Problems::quote_stream(N, name); } + +@ These are errors generated by the //building// module, but which we want to +tidy up and present in the usual Inform 7 way. + += +void SourceProblems::inter_schema_errors(inter_schema *sch) { + Problems::quote_source(1, current_sentence); + Problems::quote_stream(2, sch->converted_from); + StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_InterSchemaErrors)); + Problems::issue_problem_segment( + "In the sentence %1, you use a fragment of code written in Inform 6 " + "syntax which seems to be malformed in some way. I delegate all that " + "work to a lesser compiler: I gave it '%2' to compile, and it came " + "back with this: "); + schema_parsing_error *err; + int c = 1; + LOOP_OVER_LINKED_LIST(err, schema_parsing_error, sch->parsing_errors) { + Problems::quote_stream(1, err->message); + Problems::quote_number(2, &c); + Problems::issue_problem_segment("%P%2. %1 "); + c++; + } + Problems::issue_problem_end(); +} diff --git a/inter/building-module/Chapter 2/Inter Schemas.w b/inter/building-module/Chapter 2/Inter Schemas.w index 946f6182d..1715b03d6 100644 --- a/inter/building-module/Chapter 2/Inter Schemas.w +++ b/inter/building-module/Chapter 2/Inter Schemas.w @@ -658,11 +658,16 @@ void InterSchemas::throw_error(inter_schema_node *at, text_stream *message) { = void InterSchemas::internal_error_on_schema_errors(inter_schema *sch) { if (LinkedLists::len(sch->parsing_errors) > 0) { + #ifdef CORE_MODULE + SourceProblems::inter_schema_errors(sch); + #endif + #ifndef CORE_MODULE WRITE_TO(STDERR, "Parsing error(s) in the internal schema '%S':\n", sch->converted_from); schema_parsing_error *err; LOOP_OVER_LINKED_LIST(err, schema_parsing_error, sch->parsing_errors) WRITE_TO(STDERR, "- %S\n", err->message); internal_error("malformed schema"); + #endif } } diff --git a/inter/building-module/Preliminaries/What This Module Does.w b/inter/building-module/Preliminaries/What This Module Does.w index 1ddd6ba1e..940e6d916 100644 --- a/inter/building-module/Preliminaries/What This Module Does.w +++ b/inter/building-module/Preliminaries/What This Module Does.w @@ -228,7 +228,7 @@ Note the use of //Produce::down// and //Produce::up// to step up and down the hierarchy: these functions are always called in matching ways. @ The //pipeline// module makes heavy use of the Produce API. Surprising, -//inform7// calls it in only a few places -- but in fact that it is because +//inform7// calls it in only a few places -- but in fact that is because it provides still another middleware layer on top. See //runtime: Emit//. But it's really only a very thin layer, allowing the caller not to have to pass the |I| argument to every call (because it will always be the Inter tree