From 8d9283124995c5675dd5acfb5fa306d114ea7909 Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Tue, 25 Apr 2023 10:37:50 +0100 Subject: [PATCH] Improved error reporting on kit and insertion code --- README.md | 2 +- build.txt | 4 +- docs/bytecode-module/1-tiv.html | 6 +- docs/bytecode-module/2-in.html | 6 +- docs/bytecode-module/3-ie.html | 2 +- docs/bytecode-module/4-tic.html | 64 +++++++++--- docs/bytecode-module/5-tsc.html | 45 +++++++-- docs/core-module/1-wtc.html | 4 +- docs/core-module/2-pwst.html | 93 ++++++++++++++++++ docs/pipeline-module/2-pe.html | 52 +++++----- docs/pipeline-module/3-css.html | 13 +++ docs/pipeline-module/3-ps.html | 84 ++++++++++++---- docs/problems-module/2-pl1.html | 35 ++++++- docs/problems-module/2-pl2.html | 78 ++++++++++----- docs/runtime-module/2-emt.html | 11 ++- docs/supervisor-module/3-is.html | 10 +- docs/supervisor-module/6-st.html | 16 ++- docs/words-module/3-lxr.html | 4 + .../supervisor-module/Chapter 3/Inter Skill.w | 10 +- .../supervisor-module/Chapter 6/Source Text.w | 16 ++- inform7/Figures/memory-diagnostics.txt | 16 +-- inform7/Figures/timings-diagnostics.txt | 56 +++++------ .../BasicInformExtrasKit/kit_metadata.json | 2 +- .../Inter/BasicInformKit/kit_metadata.json | 2 +- .../Inter/CommandParserKit/kit_metadata.json | 2 +- .../Internal/Inter/DialogueKit/arch-16.interb | Bin 112240 -> 112240 bytes .../Inter/DialogueKit/arch-16d.interb | Bin 112261 -> 112261 bytes .../Internal/Inter/DialogueKit/arch-32.interb | Bin 112404 -> 112404 bytes .../Inter/DialogueKit/arch-32d.interb | Bin 112425 -> 112425 bytes .../Inter/EnglishLanguageKit/arch-16.interb | Bin 20753 -> 20753 bytes .../Inter/EnglishLanguageKit/arch-16d.interb | Bin 20774 -> 20774 bytes .../Inter/EnglishLanguageKit/arch-32.interb | Bin 20759 -> 20759 bytes .../Inter/EnglishLanguageKit/arch-32d.interb | Bin 20780 -> 20780 bytes .../EnglishLanguageKit/kit_metadata.json | 2 +- .../Inter/WorldModelKit/kit_metadata.json | 2 +- .../Chapter 2/Problems With Source Text.w | 92 +++++++++++++++++ inform7/runtime-module/Chapter 2/Emit.w | 11 ++- .../Invalid/_Results_Ideal/inversion.txt | 2 +- .../Chapter 1/The Inter Version.w | 5 +- .../Chapter 4/The Insert Construct.w | 62 +++++++++--- .../Chapter 5/The Splat Construct.w | 45 +++++++-- .../Chapter 2/Pipeline Errors.w | 42 ++++---- .../Chapter 3/Compile Splats Stage.w | 13 +++ .../Chapter 3/Parsing Stages.w | 53 +++++++++- .../Chapter 2/Problems, Level 1.w | 25 +++++ .../Chapter 2/Problems, Level 2.w | 31 +++++- services/words-module/Chapter 3/Lexer.w | 4 + 47 files changed, 824 insertions(+), 198 deletions(-) diff --git a/README.md b/README.md index a6edab434..1cbd09bb8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Inform 7 -[Version](notes/versioning.md): 10.2.0-beta+6W36 'Krypton' (23 April 2023) +[Version](notes/versioning.md): 10.2.0-beta+6W37 'Krypton' (25 April 2023) ## About Inform diff --git a/build.txt b/build.txt index b42abe7dc..69d40f175 100644 --- a/build.txt +++ b/build.txt @@ -1,3 +1,3 @@ Prerelease: beta -Build Date: 23 April 2023 -Build Number: 6W36 +Build Date: 25 April 2023 +Build Number: 6W37 diff --git a/docs/bytecode-module/1-tiv.html b/docs/bytecode-module/1-tiv.html index 5cb01a73c..087e7cd89 100644 --- a/docs/bytecode-module/1-tiv.html +++ b/docs/bytecode-module/1-tiv.html @@ -121,12 +121,16 @@ represent new data structures with custom kind constructors from Neptune files in Inform kits.

+

5.0.0 (24 April 2023) added (further) new fields to SPLAT_IST instructions, to +record their provenance and so make better error reporting possible. +

+

§3. Anyway, the implementation, such as it is:

 semantic_version_number InterVersion::current(void) {
-    semantic_version_number V = VersionNumbers::from_text(I"4.0.0");
+    semantic_version_number V = VersionNumbers::from_text(I"5.0.0");
     if (VersionNumbers::is_null(V)) internal_error("malformed version number");
     return V;
 }
diff --git a/docs/bytecode-module/2-in.html b/docs/bytecode-module/2-in.html
index abfdfc0ca..320ad9fc6 100644
--- a/docs/bytecode-module/2-in.html
+++ b/docs/bytecode-module/2-in.html
@@ -190,7 +190,7 @@ call those creator functions, not these.
     return P;
 }
 
-inter_tree_node *Inode::new_with_2_data_fields(inter_bookmark *IBM, int S,
+inter_tree_node *Inode::new_with_2_data_fields(inter_bookmark *IBM, int S,
     inter_ti V1, inter_ti V2, inter_error_location *eloc, inter_ti level) {
     inter_tree *I = InterBookmark::tree(IBM);
     inter_tree_node *P = Inode::new_node(InterTree::warehouse(I), I, 4,
@@ -215,7 +215,7 @@ call those creator functions, not these.
     return P;
 }
 
-inter_tree_node *Inode::new_with_4_data_fields(inter_bookmark *IBM, int S,
+inter_tree_node *Inode::new_with_4_data_fields(inter_bookmark *IBM, int S,
     inter_ti V1, inter_ti V2, inter_ti V3, inter_ti V4, inter_error_location *eloc,
     inter_ti level) {
     inter_tree *I = InterBookmark::tree(IBM);
@@ -246,7 +246,7 @@ call those creator functions, not these.
     return P;
 }
 
-inter_tree_node *Inode::new_with_6_data_fields(inter_bookmark *IBM, int S,
+inter_tree_node *Inode::new_with_6_data_fields(inter_bookmark *IBM, int S,
     inter_ti V1, inter_ti V2, inter_ti V3, inter_ti V4, inter_ti V5, inter_ti V6,
     inter_error_location *eloc, inter_ti level) {
     inter_tree *I = InterBookmark::tree(IBM);
diff --git a/docs/bytecode-module/3-ie.html b/docs/bytecode-module/3-ie.html
index 78aa2a37f..03dbe057c 100644
--- a/docs/bytecode-module/3-ie.html
+++ b/docs/bytecode-module/3-ie.html
@@ -71,7 +71,7 @@ where an error has occurred, in reading in Inter either from a text or binary fi
     size_t error_offset;
 } inter_error_location;
 
- +

§2. These two possibilities have two creators. Note that neither of these requires any memory to be allocated, so they return quickly and cannot cause memory leaks. So it's no problem to manufacture an inter_error_location for each location diff --git a/docs/bytecode-module/4-tic.html b/docs/bytecode-module/4-tic.html index cc2090515..2a1df780d 100644 --- a/docs/bytecode-module/4-tic.html +++ b/docs/bytecode-module/4-tic.html @@ -59,7 +59,7 @@ function togglePopup(material_id) {

Defining the insert construct.

-
+

§1. Definition. For what this does and why it is used, see Data Packages in Textual Inter (in inter). But please use it as little as possible: in an ideal world it would be abolished. @@ -68,8 +68,8 @@ But please use it as little as possible: in an ideal world it would be abolished

 void InsertInstruction::define_construct(void) {
     inter_construct *IC = InterInstruction::create_construct(INSERT_IST, I"insert");
-    InterInstruction::specify_syntax(IC, I"insert TEXT TEXT");
-    InterInstruction::data_extent_always(IC, 2);
+    InterInstruction::specify_syntax(IC, I"insert TEXT TEXT TEXT NUMBER");
+    InterInstruction::data_extent_always(IC, 4);
     InterInstruction::permit(IC, INSIDE_PLAIN_PACKAGE_ICUP);
     METHOD_ADD(IC, CONSTRUCT_READ_MTID, InsertInstruction::read);
     METHOD_ADD(IC, CONSTRUCT_TRANSPOSE_MTID, InsertInstruction::transpose);
@@ -82,21 +82,30 @@ compulsory words — see Inter Nodes
 
 
define TEXT_INSERT_IFLD (DATA_IFLD + 0)
-define REPLACING_IFLD (DATA_IFLD + 1)
+define REPLACING_INSERT_IFLD (DATA_IFLD + 1)
+define PROVENANCEFILE_INSERT_IFLD (DATA_IFLD + 2)
+define PROVENANCELINE_INSERT_IFLD (DATA_IFLD + 3)
 
 inter_error_message *InsertInstruction::new(inter_bookmark *IBM,
-    text_stream *text, text_stream *replacing, inter_ti level,
-    struct inter_error_location *eloc) {
+    text_stream *text, text_stream *replacing,
+    filename *file, inter_ti line_number,
+    inter_ti level, struct inter_error_location *eloc) {
+    TEMPORARY_TEXT(file_as_text)
+    if (file) WRITE_TO(file_as_text, "%f", file);
     inter_warehouse *warehouse = InterBookmark::warehouse(IBM);
     inter_package *pack = InterBookmark::package(IBM);
     inter_ti ID = InterWarehouse::create_text(warehouse, pack);
     Str::copy(InterWarehouse::get_text(warehouse, ID), text);
     inter_ti RID = InterWarehouse::create_text(warehouse, pack);
     Str::copy(InterWarehouse::get_text(warehouse, RID), replacing);
-    inter_tree_node *P = Inode::new_with_2_data_fields(IBM, INSERT_IST,
-        /* TEXT_INSERT_IFLD: */ ID,
-        /* REPLACING_IFLD: */ RID,
+    inter_ti FID = InterWarehouse::create_text(warehouse, pack);
+    Str::copy(InterWarehouse::get_text(warehouse, FID), file_as_text);
+    inter_tree_node *P = Inode::new_with_4_data_fields(IBM, INSERT_IST,
+        /* TEXT_INSERT_IFLD: */           ID,
+        /* REPLACING_INSERT_IFLD: */      RID,
+        /* PROVENANCEFILE_INSERT_IFLD: */ FID,
+        /* PROVENANCELINE_INSERT_IFLD: */ line_number,
         eloc, level);
     inter_error_message *E = VerifyingInter::instruction(pack, P); if (E) return E;
     NodePlacement::move_to_moving_bookmark(P, IBM);
@@ -116,7 +125,9 @@ compulsory words — see Inter Nodes    inter_package *owner, inter_error_message **E) {
     *E = VerifyingInter::text_field(owner, P, TEXT_INSERT_IFLD);
     if (*E) return;
-    *E = VerifyingInter::text_field(owner, P, REPLACING_IFLD);
+    *E = VerifyingInter::text_field(owner, P, REPLACING_INSERT_IFLD);
+    if (*E) return;
+    *E = VerifyingInter::text_field(owner, P, PROVENANCEFILE_INSERT_IFLD);
     if (*E) return;
 }
 
@@ -127,15 +138,27 @@ compulsory words — see Inter Nodes inter_error_location *eloc, inter_error_message **E) { text_stream *rq = ilp->mr.exp[0]; text_stream *repq = ilp->mr.exp[1]; + text_stream *fn = ilp->mr.exp[2]; + text_stream *lc = ilp->mr.exp[3]; TEMPORARY_TEXT(raw) TEMPORARY_TEXT(replacing) + TEMPORARY_TEXT(file_as_text) *E = TextualInter::parse_literal_text(raw, rq, 0, Str::len(rq), eloc); if (*E == NULL) *E = TextualInter::parse_literal_text(replacing, repq, 0, Str::len(repq), eloc); if (*E == NULL) - *E = InsertInstruction::new(IBM, raw, replacing, (inter_ti) ilp->indent_level, eloc); + *E = TextualInter::parse_literal_text(file_as_text, fn, 0, Str::len(fn), eloc); + if (*E == NULL) { + filename *F = NULL; + if (Str::len(file_as_text) > 0) F = Filenames::from_text(file_as_text); + inter_ti line_number = 0; + if (Str::len(lc) > 0) line_number = (inter_ti) Str::atoi(lc, 0); + *E = InsertInstruction::new(IBM, raw, replacing, F, line_number, + (inter_ti) ilp->indent_level, eloc); + } DISCARD_TEXT(raw) DISCARD_TEXT(replacing) + DISCARD_TEXT(file_as_text) }

§5. Writing to textual Inter syntax.

@@ -148,9 +171,12 @@ compulsory words — see Inter Nodes TextualInter::write_text(OUT, insertion); WRITE(" "); TextualInter::write_text(OUT, replacing); + WRITE(" "); + TextualInter::write_text(OUT, InsertInstruction::file_provenance(P)); + WRITE(" %d", InsertInstruction::line_provenance(P)); } -

§6. Access function.

+

§6. Access functions.

 text_stream *InsertInstruction::insertion(inter_tree_node *P) {
@@ -162,7 +188,19 @@ compulsory words — see Inter Nodestext_stream *InsertInstruction::replacing(inter_tree_node *P) {
     if (P == NULL) return NULL;
     if (Inode::isnt(P, INSERT_IST)) return NULL;
-    return Inode::ID_to_text(P, P->W.instruction[REPLACING_IFLD]);
+    return Inode::ID_to_text(P, P->W.instruction[REPLACING_INSERT_IFLD]);
+}
+
+text_stream *InsertInstruction::file_provenance(inter_tree_node *P) {
+    if (P == NULL) return NULL;
+    if (Inode::isnt(P, INSERT_IST)) return NULL;
+    return Inode::ID_to_text(P, P->W.instruction[PROVENANCEFILE_INSERT_IFLD]);
+}
+
+inter_ti InsertInstruction::line_provenance(inter_tree_node *P) {
+    if (P == NULL) return 0;
+    if (Inode::isnt(P, INSERT_IST)) return 0;
+    return P->W.instruction[PROVENANCELINE_INSERT_IFLD];
 }