From 0bc8db46e223348a76cee5adb165a1c73ba506e2 Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Sat, 24 Jul 2021 18:16:56 +0100 Subject: [PATCH] Further index tidying --- docs/index-module/2-fi.html | 84 ++-- docs/index-module/2-ir.html | 246 ++++------ docs/index-module/2-iu.html | 72 ++- docs/index-module/2-lcl.html | 9 +- docs/index-module/2-lxc.html | 9 +- docs/index-module/3-ae.html | 6 +- docs/index-module/3-ae2.html | 3 +- docs/index-module/3-be.html | 6 +- docs/index-module/3-ce.html | 2 +- docs/index-module/3-ce2.html | 448 ++++++++---------- docs/index-module/3-ce3.html | 298 ++++++------ docs/index-module/3-ce4.html | 6 +- docs/index-module/3-ee.html | 6 +- docs/index-module/3-fe.html | 9 +- docs/index-module/3-ge2.html | 93 ++-- docs/index-module/3-ie.html | 42 +- docs/index-module/3-le.html | 2 +- docs/index-module/3-me.html | 10 +- docs/index-module/3-pe.html | 67 +-- docs/index-module/3-pe2.html | 58 +-- docs/index-module/3-re.html | 3 +- docs/index-module/3-rfse.html | 2 +- docs/index-module/3-te.html | 9 +- docs/index-module/3-te2.html | 56 +-- docs/index-module/3-ve.html | 10 +- docs/index-module/3-ve2.html | 5 +- docs/index-module/4-rhm.html | 2 +- inform7/Figures/memory-diagnostics.txt | 4 +- inform7/Figures/timings-diagnostics.txt | 14 +- inform7/Internal/Languages/English/Index.txt | 55 +++ .../_Results_Ideal/Index-Chart.txt | 47 +- inter/bytecode-module/Chapter 2/Inter Trees.w | 20 + inter/index-module/Chapter 2/Faux Instances.w | 84 ++-- inter/index-module/Chapter 2/Index Rules.w | 228 +++------ .../index-module/Chapter 2/Index Utilities.w | 27 ++ inter/index-module/Chapter 2/Lexicon.w | 7 +- inter/index-module/Chapter 2/Localisation.w | 5 +- .../Chapter 3/Alphabetic Element.w | 4 +- .../Chapter 3/Arithmetic Element.w | 3 +- .../Chapter 3/Behaviour Element.w | 6 +- inter/index-module/Chapter 3/Chart Element.w | 290 +++++------- .../index-module/Chapter 3/Commands Element.w | 279 ++++++----- .../index-module/Chapter 3/Contents Element.w | 6 +- inter/index-module/Chapter 3/Events Element.w | 6 +- .../index-module/Chapter 3/Figures Element.w | 9 +- .../index-module/Chapter 3/Grouped Element.w | 87 ++-- .../index-module/Chapter 3/Innards Element.w | 32 +- .../Chapter 3/Phrasebook Element.w | 67 +-- inter/index-module/Chapter 3/Plot Element.w | 52 +- .../Chapter 3/Relations Element.w | 3 +- inter/index-module/Chapter 3/Tables Element.w | 3 +- inter/index-module/Chapter 3/Tokens Element.w | 54 +-- inter/index-module/Chapter 3/Values Element.w | 6 +- inter/index-module/Chapter 3/Verbs Element.w | 3 +- 54 files changed, 1328 insertions(+), 1636 deletions(-) diff --git a/docs/index-module/2-fi.html b/docs/index-module/2-fi.html index 6586777dd..3ffb4f2f3 100644 --- a/docs/index-module/2-fi.html +++ b/docs/index-module/2-fi.html @@ -405,52 +405,46 @@ and only if needed.
 void FauxInstances::decode_hints(faux_instance_set *faux_set, inter_tree *I, int pass) {
     inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/mapping_hints");
-    inter_symbol *wanted = PackageTypes::get(I, I"_mapping_hint");
-    inter_tree_node *D = Inter::Packages::definition(pack);
-    LOOP_THROUGH_INTER_CHILDREN(C, D) {
-        if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-            inter_package *entry = Inter::Package::defined_by_frame(C);
-            if (Inter::Packages::type(entry) == wanted) {
-                faux_instance *from = FauxInstances::xref(faux_set, entry, I"^from");
-                faux_instance *to = FauxInstances::xref(faux_set, entry, I"^to");
-                faux_instance *dir = FauxInstances::xref(faux_set, entry, I"^dir");
-                faux_instance *as_dir = FauxInstances::xref(faux_set, entry, I"^as_dir");
-                if ((dir) && (as_dir)) {
-                    if (pass == 1) Decode a hint mapping one direction as if another10.1;
-                    continue;
-                }
-                if ((from) && (dir)) {
-                    if (pass == 1) Decode a hint mapping one room in a specific direction from another10.2;
-                    continue;
-                }
-                text_stream *name = Metadata::read_optional_textual(entry, I"^name");
-                if (Str::len(name) > 0) {
-                    int scope_level = (int) Metadata::read_optional_numeric(entry, I"^scope_level");
-                    faux_instance *scope_I = FauxInstances::xref(faux_set, entry, I"^scope_instance");
-                    text_stream *text_val = Metadata::read_optional_textual(entry, I"^text");
-                    int int_val = (int) Metadata::read_optional_numeric(entry, I"^number");
-                    if (scope_level != 1000000) {
-                        if (pass == 2) Decode a hint setting EPS map parameters relating to levels10.4;
-                    } else {
-                        if (pass == 1) Decode a hint setting EPS map parameters10.3;
-                    }
-                    continue;
-                }
-                text_stream *annotation = Metadata::read_optional_textual(entry, I"^annotation");
-                if (Str::len(annotation) > 0) {
-                    if (pass == 1) {
-                        rubric_holder *rh = CREATE(rubric_holder);
-                        rh->annotation = annotation;
-                        rh->point_size = (int) Metadata::read_optional_numeric(entry, I"^point_size");
-                        rh->font = Metadata::read_optional_textual(entry, I"^font");
-                        rh->colour = Metadata::read_optional_textual(entry, I"^colour");
-                        rh->at_offset = (int) Metadata::read_optional_numeric(entry, I"^offset");
-                        rh->offset_from = FauxInstances::xref(faux_set, entry, I"^offset_from");
-                        ADD_TO_LINKED_LIST(rh, rubric_holder, faux_set->rubrics);
-                    }
-                    continue;
-                }
+    inter_package *hint_pack;
+    LOOP_THROUGH_SUBPACKAGES(hint_pack, pack, I"_mapping_hint") {
+        faux_instance *from = FauxInstances::xref(faux_set, hint_pack, I"^from");
+        faux_instance *to = FauxInstances::xref(faux_set, hint_pack, I"^to");
+        faux_instance *dir = FauxInstances::xref(faux_set, hint_pack, I"^dir");
+        faux_instance *as_dir = FauxInstances::xref(faux_set, hint_pack, I"^as_dir");
+        if ((dir) && (as_dir)) {
+            if (pass == 1) Decode a hint mapping one direction as if another10.1;
+            continue;
+        }
+        if ((from) && (dir)) {
+            if (pass == 1) Decode a hint mapping one room in a specific direction from another10.2;
+            continue;
+        }
+        text_stream *name = Metadata::read_optional_textual(hint_pack, I"^name");
+        if (Str::len(name) > 0) {
+            int scope_level = (int) Metadata::read_optional_numeric(hint_pack, I"^scope_level");
+            faux_instance *scope_I = FauxInstances::xref(faux_set, hint_pack, I"^scope_instance");
+            text_stream *text_val = Metadata::read_optional_textual(hint_pack, I"^text");
+            int int_val = (int) Metadata::read_optional_numeric(hint_pack, I"^number");
+            if (scope_level != 1000000) {
+                if (pass == 2) Decode a hint setting EPS map parameters relating to levels10.4;
+            } else {
+                if (pass == 1) Decode a hint setting EPS map parameters10.3;
             }
+            continue;
+        }
+        text_stream *annotation = Metadata::read_optional_textual(hint_pack, I"^annotation");
+        if (Str::len(annotation) > 0) {
+            if (pass == 1) {
+                rubric_holder *rh = CREATE(rubric_holder);
+                rh->annotation = annotation;
+                rh->point_size = (int) Metadata::read_optional_numeric(hint_pack, I"^point_size");
+                rh->font = Metadata::read_optional_textual(hint_pack, I"^font");
+                rh->colour = Metadata::read_optional_textual(hint_pack, I"^colour");
+                rh->at_offset = (int) Metadata::read_optional_numeric(hint_pack, I"^offset");
+                rh->offset_from = FauxInstances::xref(faux_set, hint_pack, I"^offset_from");
+                ADD_TO_LINKED_LIST(rh, rubric_holder, faux_set->rubrics);
+            }
+            continue;
         }
     }
 }
diff --git a/docs/index-module/2-ir.html b/docs/index-module/2-ir.html
index 90ad3d217..8e12ddf45 100644
--- a/docs/index-module/2-ir.html
+++ b/docs/index-module/2-ir.html
@@ -159,17 +159,11 @@ with ^action an
     if (rule_pack == NULL) return FALSE;
     if (rc.action_context) {
         int passes = FALSE;
-        inter_symbol *wanted = PackageTypes::get(I, I"_relevant_action");
-        inter_tree_node *D = Inter::Packages::definition(rule_pack);
-        LOOP_THROUGH_INTER_CHILDREN(C, D) {
-            if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-                inter_package *rel_pack = Inter::Package::defined_by_frame(C);
-                if (Inter::Packages::type(rel_pack) == wanted) {
-                    inter_symbol *act_ds = Metadata::read_symbol(rel_pack, I"^action");
-                    if (Inter::Packages::container(act_ds->definition) == rc.action_context)
-                        passes = TRUE;
-                }
-            }
+        inter_package *rel_pack;
+        LOOP_THROUGH_SUBPACKAGES(rel_pack, rule_pack, I"_relevant_action") {
+            inter_symbol *act_ds = Metadata::read_symbol(rel_pack, I"^action");
+            if (Inter::Packages::container(act_ds->definition) == rc.action_context)
+                passes = TRUE;
         }
         if (passes == FALSE) return FALSE;
     }
@@ -189,16 +183,10 @@ no rules which fit rc<
 
 int IndexRules::is_contextually_empty(inter_tree *I, inter_package *rb_pack, rule_context rc) {
     if (rb_pack) {
-        inter_symbol *wanted = PackageTypes::get(I, I"_rulebook_entry");
-        inter_tree_node *D = Inter::Packages::definition(rb_pack);
-        LOOP_THROUGH_INTER_CHILDREN(C, D) {
-            if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-                inter_package *entry = Inter::Package::defined_by_frame(C);
-                if (Inter::Packages::type(entry) == wanted)
-                    if (IndexRules::phrase_fits_rule_context(I, entry, rc))
-                        return FALSE;
-            }
-        }
+        inter_package *entry;
+        LOOP_THROUGH_SUBPACKAGES(entry, rb_pack, I"_rulebook_entry")
+            if (IndexRules::phrase_fits_rule_context(I, entry, rc))
+                return FALSE;
     }
     return TRUE;
 }
@@ -208,24 +196,12 @@ no rules which fit rc<
 
 
 int IndexRules::is_empty(inter_tree *I, inter_package *rb_pack) {
-    if ((rb_pack) && (IndexRules::no_rules(I, rb_pack) > 0)) return FALSE;
+    if ((rb_pack) && (IndexRules::no_rules(rb_pack) > 0)) return FALSE;
     return TRUE;
 }
 
-int IndexRules::no_rules(inter_tree *I, inter_package *rb_pack) {
-    int N = 0;
-    if (rb_pack) {
-        inter_symbol *wanted = PackageTypes::get(I, I"_rulebook_entry");
-        inter_tree_node *D = Inter::Packages::definition(rb_pack);
-        LOOP_THROUGH_INTER_CHILDREN(C, D) {
-            if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-                inter_package *entry = Inter::Package::defined_by_frame(C);
-                if (Inter::Packages::type(entry) == wanted)
-                    N++;
-            }
-        }
-    }
-    return N;
+int IndexRules::no_rules(inter_package *rb_pack) {
+    return InterTree::no_subpackages(rb_pack, I"_rulebook_entry");
 }
 

§8. Links between rules in rulebook listings. A notation is used to show how rulebook sorting affected the placement of @@ -252,7 +228,7 @@ switched off:

 int RS_unique_xtra_no = 77777;
-int IndexRules::extra_ID(void) {
+int IndexRules::extra_ID(void) {
     return RS_unique_xtra_no++;
 }
 
@@ -272,21 +248,21 @@ switched off: string_position start = Str::start(textual_name); Str::put(start, Characters::tolower(Str::get(start))); - int n = IndexRules::no_rules(inv->of_tree, rb_pack); + int n = IndexRules::no_rules(rb_pack); if (place_in_expandable_box) { int expand_id = IndexRules::extra_ID(); HTML::open_indented_p(OUT, indent+1, "tight"); - IndexUtilities::extra_link(OUT, expand_id); + IndexUtilities::extra_link(OUT, expand_id); if (n == 0) HTML::begin_colour(OUT, I"808080"); WRITE("%S", textual_name); Add links and such to the titling10.2; WRITE(" (%d rule%s)", n, (n==1)?"":"s"); if (n == 0) HTML::end_colour(OUT); HTML_CLOSE("p"); - IndexUtilities::extra_div_open(OUT, expand_id, indent+1, RULEBOOK_BOX_COLOUR); + IndexUtilities::extra_div_open(OUT, expand_id, indent+1, RULEBOOK_BOX_COLOUR); Index the contents of the rulebook box10.1; - IndexUtilities::extra_div_close(OUT, RULEBOOK_BOX_COLOUR); + IndexUtilities::extra_div_close(OUT, RULEBOOK_BOX_COLOUR); } else { HTML::open_indented_p(OUT, indent, ""); HTML::open_coloured_box(OUT, RULEBOOK_BOX_COLOUR, ROUND_BOX_TOP+ROUND_BOX_BOTTOM); @@ -332,8 +308,7 @@ switched off:
     if (Str::len(doc_link) > 0) IndexUtilities::DocReferences::link(OUT, doc_link);
     WRITE(" ... %S", Metadata::read_optional_textual(rb_pack, I"^focus"));
-    int at = (int) Metadata::read_optional_numeric(rb_pack, I"^at");
-    if (at > 0) IndexUtilities::link(OUT, at);
+    IndexUtilities::link_package(OUT, rb_pack);
 

§11. Two ways to list a rulebook. Firstly, the whole contents: @@ -380,24 +355,18 @@ switched off: if (IndexRules::is_contextually_empty(I, rb_pack, rc)) suppress_outcome = TRUE; } inter_package *prev = NULL; - inter_symbol *wanted = PackageTypes::get(I, I"_rulebook_entry"); - inter_tree_node *D = Inter::Packages::definition(rb_pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - if (IndexRules::phrase_fits_rule_context(I, entry, rc)) { - if (count++ == 0) HTML::open_indented_p(OUT, 2, "indent"); - else WRITE("<br>"); - if ((Str::len(billing) > 0) && (IndexRules::showing_links())) - Show a linkage icon13.1; - WRITE("%S", billing); - WRITE("&nbsp;&nbsp;&nbsp;&nbsp;"); - *resp_count += IndexRules::index_rule(OUT, I, entry, rb_pack, rc, LD); - } - prev = entry; - } + inter_package *entry; + LOOP_THROUGH_SUBPACKAGES(entry, rb_pack, I"_rulebook_entry") { + if (IndexRules::phrase_fits_rule_context(I, entry, rc)) { + if (count++ == 0) HTML::open_indented_p(OUT, 2, "indent"); + else WRITE("<br>"); + if ((Str::len(billing) > 0) && (IndexRules::showing_links())) + Show a linkage icon13.1; + WRITE("%S", billing); + WRITE("&nbsp;&nbsp;&nbsp;&nbsp;"); + *resp_count += IndexRules::index_rule(OUT, I, entry, rb_pack, rc, LD); } + prev = entry; } if (count > 0) HTML_CLOSE("p"); if (suppress_outcome == FALSE) IndexRules::index_outcomes(OUT, I, rb_pack, LD); @@ -493,19 +462,10 @@ of adjacent rules in a listing: inter_symbol *R_symbol = Metadata::read_optional_symbol(R, I"^rule"); if (R_symbol) { - int c = 0; - inter_symbol *wanted = PackageTypes::get(I, I"_response"); - inter_tree_node *D = Inter::Packages::definition(R); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) - c++; - } - } + int c = InterTree::no_subpackages(R, I"_response"); if (c > 0) { WRITE("&nbsp;&nbsp;"); - IndexUtilities::extra_link_with(OUT, response_box_id, "responses"); + IndexUtilities::extra_link_with(OUT, response_box_id, "responses"); WRITE("%d", c); } } @@ -518,20 +478,14 @@ of adjacent rules in a listing: inter_symbol *R_symbol = Metadata::read_optional_symbol(R, I"^rule"); if (R_symbol) { int c = 0; - inter_symbol *wanted = PackageTypes::get(I, I"_response"); - inter_tree_node *D = Inter::Packages::definition(R); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - if (c == 0) IndexUtilities::extra_div_open_nested(OUT, response_box_id, 2); - else HTML_TAG("br"); - IndexRules::index_response(OUT, R, entry, LD); - c++; - } - } + inter_package *resp_pack; + LOOP_THROUGH_SUBPACKAGES(resp_pack, R, I"_response") { + if (c == 0) IndexUtilities::extra_div_open_nested(OUT, response_box_id, 2); + else HTML_TAG("br"); + IndexRules::index_response(OUT, R, resp_pack, LD); + c++; } - if (c > 0) IndexUtilities::extra_div_close_nested(OUT); + if (c > 0) IndexUtilities::extra_div_close_nested(OUT); no_responses_indexed = c; }

@@ -547,8 +501,7 @@ of adjacent rules in a listing:

-    int at = (int) Metadata::read_optional_numeric(R, I"^at");
-    if (at > 0) IndexUtilities::link(OUT, at);
+    IndexUtilities::link_package(OUT, R);
 
  • This code is used in §14.

§14.6. Index the small type rule numbering14.6 = @@ -570,18 +523,11 @@ of adjacent rules in a listing:

     inter_symbol *R_symbol = Metadata::read_optional_symbol(R, I"^rule");
     if (R_symbol) {
-        inter_symbol *wanted = PackageTypes::get(I, I"_applicability_condition");
-        inter_tree_node *D = Inter::Packages::definition(R);
-        LOOP_THROUGH_INTER_CHILDREN(C, D) {
-            if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-                inter_package *entry = Inter::Package::defined_by_frame(C);
-                if (Inter::Packages::type(entry) == wanted) {
-                    HTML_TAG("br");
-                    int at = (int) Metadata::read_optional_numeric(entry, I"^at");
-                    if (at > 0) IndexUtilities::link(OUT, at);
-                    WRITE("&nbsp;%S", Metadata::read_textual(entry, I"^index_text"));
-                }
-            }
+        inter_package *ac_pack;
+        LOOP_THROUGH_SUBPACKAGES(ac_pack, R, I"_applicability_condition") {
+            HTML_TAG("br");
+            IndexUtilities::link_package(OUT, ac_pack);
+            WRITE("&nbsp;%S", Metadata::read_textual(ac_pack, I"^index_text"));
         }
     }
 
@@ -627,31 +573,25 @@ text to assert a change:
 void IndexRules::index_outcomes(OUTPUT_STREAM, inter_tree *I, inter_package *rb_pack,
     localisation_dictionary *LD) {
-    inter_symbol *wanted = PackageTypes::get(I, I"_rulebook_outcome");
-    inter_tree_node *D = Inter::Packages::definition(rb_pack);
-    LOOP_THROUGH_INTER_CHILDREN(C, D) {
-        if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-            inter_package *entry = Inter::Package::defined_by_frame(C);
-            if (Inter::Packages::type(entry) == wanted) {
-                HTML::open_indented_p(OUT, 2, "hanging");
-                WRITE("<i>");
-                Localisation::write_0(OUT, LD, I"Index.Elements.RS.Outcome");
-                WRITE("</i>&nbsp;&nbsp;");
-                int is_def = (int) Metadata::read_optional_numeric(entry, I"^is_default");
-                if (is_def) WRITE("<b>");
-                WRITE("%S", Metadata::read_optional_textual(entry, I"^text"));
-                if (is_def) WRITE("</b> (default)");
-                WRITE(" - <i>");
-                if (Metadata::read_optional_numeric(entry, I"^succeeds"))
-                    Localisation::write_0(OUT, LD, I"Index.Elements.RS.Success");
-                else if (Metadata::read_optional_numeric(entry, I"^fails"))
-                    Localisation::write_0(OUT, LD, I"Index.Elements.RS.Failure");
-                else
-                    Localisation::write_0(OUT, LD, I"Index.Elements.RS.NoOutcome");
-                WRITE("</i>");
-                HTML_CLOSE("p");
-            }
-        }
+    inter_package *ro_pack;
+    LOOP_THROUGH_SUBPACKAGES(ro_pack, rb_pack, I"_rulebook_outcome") {
+        HTML::open_indented_p(OUT, 2, "hanging");
+        WRITE("<i>");
+        Localisation::write_0(OUT, LD, I"Index.Elements.RS.Outcome");
+        WRITE("</i>&nbsp;&nbsp;");
+        int is_def = (int) Metadata::read_optional_numeric(ro_pack, I"^is_default");
+        if (is_def) WRITE("<b>");
+        WRITE("%S", Metadata::read_optional_textual(ro_pack, I"^text"));
+        if (is_def) WRITE("</b> (default)");
+        WRITE(" - <i>");
+        if (Metadata::read_optional_numeric(ro_pack, I"^succeeds"))
+            Localisation::write_0(OUT, LD, I"Index.Elements.RS.Success");
+        else if (Metadata::read_optional_numeric(ro_pack, I"^fails"))
+            Localisation::write_0(OUT, LD, I"Index.Elements.RS.Failure");
+        else
+            Localisation::write_0(OUT, LD, I"Index.Elements.RS.NoOutcome");
+        WRITE("</i>");
+        HTML_CLOSE("p");
     }
 
     if (Metadata::read_optional_numeric(rb_pack, I"^default_succeeds")) {
@@ -672,21 +612,14 @@ text to assert a change:
 
 void IndexRules::rb_index_placements(OUTPUT_STREAM, inter_tree *I, inter_package *rb_pack,
     localisation_dictionary *LD) {
-    inter_symbol *wanted = PackageTypes::get(I, I"_rulebook_placement");
-    inter_tree_node *D = Inter::Packages::definition(rb_pack);
-    LOOP_THROUGH_INTER_CHILDREN(C, D) {
-        if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-            inter_package *entry = Inter::Package::defined_by_frame(C);
-            if (Inter::Packages::type(entry) == wanted) {
-                WRITE("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
-                HTML_OPEN_WITH("span", "class=\"smaller\"");
-                WRITE("<i>NB:</i> %S", Metadata::read_optional_textual(entry, I"^text"));
-                int at = (int) Metadata::read_optional_numeric(entry, I"^at");
-                if (at > 0) IndexUtilities::link(OUT, at);
-                HTML_CLOSE("span");
-                HTML_TAG("br");
-            }
-        }
+    inter_package *rp_pack;
+    LOOP_THROUGH_SUBPACKAGES(rp_pack, rb_pack, I"_rulebook_placement") {
+        WRITE("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
+        HTML_OPEN_WITH("span", "class=\"smaller\"");
+        WRITE("<i>NB:</i> %S", Metadata::read_optional_textual(rp_pack, I"^text"));
+        IndexUtilities::link_package(OUT, rp_pack);
+        HTML_CLOSE("span");
+        HTML_TAG("br");
     }
 }
 
@@ -699,7 +632,6 @@ of an activity are part of a single construct:
 void IndexRules::activity_box(OUTPUT_STREAM, inter_tree *I, inter_package *av_pack,
     int indent, localisation_dictionary *LD) {
-    text_stream *doc_link = Metadata::read_optional_textual(av_pack, I"^documentation");
     int expand_id = IndexRules::extra_ID();
 
     inter_symbol *before_s = Metadata::read_symbol(av_pack, I"^before_rulebook");
@@ -709,9 +641,9 @@ of an activity are part of a single construct:
     inter_package *for_pack = Inter::Packages::container(for_s->definition);
     inter_package *after_pack = Inter::Packages::container(after_s->definition);
 
-    int n = IndexRules::no_rules(I, before_pack) +
-            IndexRules::no_rules(I, for_pack) +
-            IndexRules::no_rules(I, after_pack);
+    int n = IndexRules::no_rules(before_pack) +
+            IndexRules::no_rules(for_pack) +
+            IndexRules::no_rules(after_pack);
 
     TEMPORARY_TEXT(textual_name)
     text_stream *name = Metadata::read_optional_textual(av_pack, I"^name");
@@ -721,7 +653,7 @@ of an activity are part of a single construct:
     Str::put(start, Characters::tolower(Str::get(start)));
 
     HTML::open_indented_p(OUT, indent+1, "tight");
-    IndexUtilities::extra_link(OUT, expand_id);
+    IndexUtilities::extra_link(OUT, expand_id);
     if (n == 0) HTML::begin_colour(OUT, I"808080");
     WRITE("%S", textual_name);
     Write the titling line of an activity rules box17.1;
@@ -729,7 +661,7 @@ of an activity are part of a single construct:
     if (n == 0) HTML::end_colour(OUT);
     HTML_CLOSE("p");
 
-    IndexUtilities::extra_div_open(OUT, expand_id, indent+1, ACTIVITY_BOX_COLOUR);
+    IndexUtilities::extra_div_open(OUT, expand_id, indent+1, ACTIVITY_BOX_COLOUR);
 
     HTML::begin_html_table(OUT, NULL, TRUE, 0, 4, 0, 0, 0);
     HTML::first_html_column(OUT, 0);
@@ -767,33 +699,25 @@ of an activity are part of a single construct:
     IndexRules::rulebook_list(OUT, I, for_pack, I"for", IndexRules::no_rule_context(), LD);
     IndexRules::rulebook_list(OUT, I, after_pack, I"after", IndexRules::no_rule_context(), LD);
 
-    inter_symbol *wanted = PackageTypes::get(I, I"_activity_xref");
-    inter_tree_node *D = Inter::Packages::definition(av_pack);
-    LOOP_THROUGH_INTER_CHILDREN(C, D) {
-        if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-            inter_package *entry = Inter::Package::defined_by_frame(C);
-            if (Inter::Packages::type(entry) == wanted) {
-                HTML::open_indented_p(OUT, 2, "tight");
-                WRITE("NB: %S", Metadata::read_optional_textual(entry, I"^text"));
-                int at = (int) Metadata::read_optional_numeric(entry, I"^at");
-                if (at > 0) IndexUtilities::link(OUT, at);
-                HTML_CLOSE("p");
-            }
-        }
+    inter_package *xref_pack;
+    LOOP_THROUGH_SUBPACKAGES(xref_pack, av_pack, I"_activity_xref") {
+        HTML::open_indented_p(OUT, 2, "tight");
+        WRITE("NB: %S", Metadata::read_optional_textual(xref_pack, I"^text"));
+        IndexUtilities::link_package(OUT, xref_pack);
+        HTML_CLOSE("p");
     }
 
-    IndexUtilities::extra_div_close(OUT, ACTIVITY_BOX_COLOUR);
+    IndexUtilities::extra_div_close(OUT, ACTIVITY_BOX_COLOUR);
 }
 

§17.1. Write the titling line of an activity rules box17.1 =

-    if (Str::len(doc_link) > 0) IndexUtilities::DocReferences::link(OUT, doc_link);
+    IndexUtilities::link_to_documentation(OUT, av_pack);
     WRITE(" ... ");
     Localisation::write_0(OUT, LD, I"Index.Elements.RS.Activity");
-    int at = (int) Metadata::read_optional_numeric(av_pack, I"^at");
-    if (at > 0) IndexUtilities::link(OUT, at);
+    IndexUtilities::link_package(OUT, av_pack);
 
  • This code is used in §17 (twice).
-

§9. The "definition area" for content is usually a heading inside an extension; +

§10. The "definition area" for content is usually a heading inside an extension; see the Phrasebook element for examples of how this comes out.

-void IndexUtilities::show_definition_area(OUTPUT_STREAM, inter_package *heading_pack,
+void IndexUtilities::show_definition_area(OUTPUT_STREAM, inter_package *heading_pack,
     int show_if_unhyphenated) {
     inter_ti parts = Metadata::read_optional_numeric(heading_pack, I"^parts");
     if ((parts == 1) && (show_if_unhyphenated == FALSE)) return;
@@ -319,6 +335,18 @@ see the Phrasebook element for examples of how this comes out.
     HTML_TAG("br");
 }
 
+

§11. Here pack is the Inter package for a kind constructor. +

+ +
+void IndexUtilities::kind_name(OUTPUT_STREAM, inter_package *pack, int plural,
+    int with_links) {
+    if (pack == NULL) return;
+    text_stream *key = (plural)?I"^index_plural":I"^index_singular";
+    WRITE("%S", Metadata::read_optional_textual(pack, key));
+    if (with_links) IndexUtilities::link_package(OUT, pack);
+}
+
diff --git a/docs/index-module/2-lcl.html b/docs/index-module/2-lcl.html index 44a5c9ad9..ad71ecf8b 100644 --- a/docs/index-module/2-lcl.html +++ b/docs/index-module/2-lcl.html @@ -288,8 +288,11 @@ with everything under the first line being italicised. For example: How this project might be filed in a library catalogue.|About the Library Card<LCARDS>; About IFIDs<IFIDS> +

Note that a valid documentation reference must begin with an upper-case letter. +

+
-void Localisation::write_0(OUTPUT_STREAM, localisation_dictionary *D, text_stream *key) {
+void Localisation::write_0(OUTPUT_STREAM, localisation_dictionary *D, text_stream *key) {
     text_stream *vals[10];
     Vacate the vals5.1;
     Localisation::write_general(OUT, D, key, vals);
@@ -346,7 +349,9 @@ with everything under the first line being italicised. For example:
                 i++;
                 while ((i<Str::len(prototype)) && (Str::get_at(prototype, i) != '>'))
                     PUT_TO(link, Str::get_at(prototype, i++));
-                IndexUtilities::DocReferences::link(OUT, link);
+                if (Characters::isupper(Str::get_at(link, 0)))
+                    IndexUtilities::DocReferences::link(OUT, link);
+                else WRITE("<%S>", link);
                 DISCARD_TEXT(link)
                 break;
             }
diff --git a/docs/index-module/2-lxc.html b/docs/index-module/2-lxc.html
index 831bc9532..b016e460d 100644
--- a/docs/index-module/2-lxc.html
+++ b/docs/index-module/2-lxc.html
@@ -406,15 +406,12 @@ source text: so any single link would be potentially misleading.
 
 
     switch(lex->part_of_speech) {
-        case COMMON_NOUN_TLEXE: {
-            text_stream *ref =
-                Metadata::read_optional_textual(lex->lex_package, I"^documentation");
-            if (Str::len(ref) > 0) IndexUtilities::DocReferences::link(OUT, ref);
+        case COMMON_NOUN_TLEXE:
+            IndexUtilities::link_to_documentation(OUT, lex->lex_package);
             break;
-        }
         case VERB_TLEXE:
         case PREP_TLEXE:
-            IndexUtilities::below_link_numbered(OUT, 10000+verb_count++);
+            IndexUtilities::below_link_numbered(OUT, 10000+verb_count++);
             break;
     }
     if ((lex->part_of_speech != ADJECTIVAL_PHRASE_TLEXE) && (lex->link_to > 0))
diff --git a/docs/index-module/3-ae.html b/docs/index-module/3-ae.html
index b53f594e0..8df092921 100644
--- a/docs/index-module/3-ae.html
+++ b/docs/index-module/3-ae.html
@@ -118,7 +118,7 @@ function togglePopup(material_id) {
     if (oow) HTML::begin_colour(OUT, I"800000");
     WRITE("%S", Metadata::read_optional_textual(an_pack, I"^name"));
     if (oow) HTML::end_colour(OUT);
-    IndexUtilities::detail_link(OUT, "A", i, TRUE);
+    IndexUtilities::detail_link(OUT, "A", i, TRUE);
     if (requires_light) AlphabeticElement::note(OUT, I"Light", LD);
 
@@ -132,7 +132,7 @@ function togglePopup(material_id) { if (noun_access == REQUIRES_ACCESS) AlphabeticElement::note(OUT, I"Touchable", LD); if (noun_access == REQUIRES_POSSESSION) AlphabeticElement::note(OUT, I"Carried", LD); WRITE("<b>"); - ChartElement::index_kind(OUT, Inter::Packages::container(noun_kind->definition), FALSE, FALSE); + IndexUtilities::kind_name(OUT, Inter::Packages::container(noun_kind->definition), FALSE, FALSE); WRITE("</b>"); }
@@ -147,7 +147,7 @@ function togglePopup(material_id) { if (second_access == REQUIRES_ACCESS) AlphabeticElement::note(OUT, I"Touchable", LD); if (second_access == REQUIRES_POSSESSION) AlphabeticElement::note(OUT, I"Carried", LD); WRITE("<b>"); - ChartElement::index_kind(OUT, Inter::Packages::container(second_kind->definition), FALSE, FALSE); + IndexUtilities::kind_name(OUT, Inter::Packages::container(second_kind->definition), FALSE, FALSE); WRITE("</b>"); } diff --git a/docs/index-module/3-ae2.html b/docs/index-module/3-ae2.html index 33da4807a..2bc274450 100644 --- a/docs/index-module/3-ae2.html +++ b/docs/index-module/3-ae2.html @@ -171,8 +171,7 @@ text, sorted into kind order of left and then right operand. inter_package *pack = Inter::Package::defined_by_frame(inv->multiplication_rule_nodes->list[i].node); HTML::first_html_column(OUT, 0); - int at = (int) Metadata::read_optional_numeric(pack, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); + IndexUtilities::link_package(OUT, pack); HTML::next_html_column(OUT, 0); WRITE("%S", Metadata::read_optional_textual(pack, I"^left_operand")); HTML::begin_colour(OUT, I"808080"); diff --git a/docs/index-module/3-be.html b/docs/index-module/3-be.html index 3fd20af5d..f455765f1 100644 --- a/docs/index-module/3-be.html +++ b/docs/index-module/3-be.html @@ -92,9 +92,8 @@ function togglePopup(material_id) { inter_package *pack = Inter::Package::defined_by_frame(inv->named_action_pattern_nodes->list[i].node); text_stream *name = Metadata::read_optional_textual(pack, I"^name"); - int at = (int) Metadata::read_optional_numeric(pack, I"^at"); HTML_OPEN("p"); WRITE("<b>%S</b>", name); - IndexUtilities::link(OUT, at); + IndexUtilities::link_package(OUT, pack); HTML_TAG("br"); WRITE("&nbsp;&nbsp;<i>"); Localisation::write_0(OUT, LD, I"Index.Elements.Bh.Defined"); @@ -108,8 +107,7 @@ function togglePopup(material_id) { text_stream *text = Metadata::read_optional_textual(entry, I"^text"); HTML_TAG("br"); WRITE("&nbsp;&nbsp;&nbsp;&nbsp;%S", text); - int at = (int) Metadata::read_optional_numeric(entry, I"^at"); - IndexUtilities::link(OUT, at); + IndexUtilities::link_package(OUT, entry); } } } diff --git a/docs/index-module/3-ce.html b/docs/index-module/3-ce.html index 3d5dfbd94..bde62d32d 100644 --- a/docs/index-module/3-ce.html +++ b/docs/index-module/3-ce.html @@ -83,7 +83,7 @@ simplified form of the iFiction record, without the XML overhead. inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/bibliographic"); HTML_OPEN("p"); - IndexUtilities::anchor(OUT, I"LCARD"); + IndexUtilities::anchor(OUT, I"LCARD"); HTML::begin_html_table(OUT, "*bg_images/indexcard.png", FALSE, 0, 3, 3, 0, 0); CardElement::Library_Card_entry(OUT, "Story title", pack, I"^title", I"Untitled"); CardElement::Library_Card_entry(OUT, "Story author", pack, I"^author", I"Anonymous"); diff --git a/docs/index-module/3-ce2.html b/docs/index-module/3-ce2.html index e325ecd40..7e8610b74 100644 --- a/docs/index-module/3-ce2.html +++ b/docs/index-module/3-ce2.html @@ -72,28 +72,33 @@ function togglePopup(material_id) {

To write the Chart element (Ch) in the index.

-
+
-

§1.

+

§1. This is a table of kinds of value, followed by a set of descriptions of each, +and it is quite dense with information. +

-void ChartElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
+void ChartElement::render(OUTPUT_STREAM, localisation_dictionary *D) {
     inter_tree *I = InterpretIndex::get_tree();
     tree_inventory *inv = Synoptic::inv(I);
     TreeLists::sort(inv->kind_nodes, Synoptic::module_order);
     TreeLists::sort(inv->instance_nodes, Synoptic::module_order);
-    ChartElement::index_kinds(OUT, inv, 1);
-    ChartElement::index_kinds(OUT, inv, 2);
+    HTML::begin_wide_html_table(OUT);
+    int pass = 1;
+    Add a dotty row to the chart of kinds1.3;
+    Add a titling row to the chart of kinds1.2;
+    Add a dotty row to the chart of kinds1.3;
+    Add the rubric below the chart of kinds1.4;
+    Run through the kinds in priority order1.1;
+    Add a dotty row to the chart of kinds1.3;
+    HTML::end_html_table(OUT);
+    pass = 2;
+    Run through the kinds in priority order1.1;
+    Explain about covariance and contravariance1.5;
 }
 
-

§2. Indexing the kinds. The Kinds page of the index opens with a table summarising the hierarchy of -kinds, and then follows with details. This routine is called twice, once -with pass equal to 1, when it has to fill in the hierarchy of kinds listed -under "value" in the key chart at the top of the Kinds index; and then -again lower down, with pass equal to 2, when it gives more detail. -

- -

Not all of the built-in kinds are indexed on the Kinds page. The ones +

§1.1. Not all of the built-in kinds are indexed on the Kinds page. The ones omitted are of no help to end users, and would only clutter up the table with misleading entries. Remaining kinds are grouped together in "priority" order, a device to enable the quasinumerical kinds to stick @@ -103,105 +108,73 @@ higher up, but kinds with priority 0 do not appear in the index at all.

define LOWEST_INDEX_PRIORITY 100
 
-
-void ChartElement::index_kinds(OUTPUT_STREAM, tree_inventory *inv, int pass) {
-    int priority;
-    if (pass == 1) {
-        HTML_OPEN("p"); HTML_CLOSE("p");
-        HTML::begin_wide_html_table(OUT);
-        Add a dotty row to the chart of kinds2.4;
-        Add a titling row to the chart of kinds2.2;
-        Add a dotty row to the chart of kinds2.4;
-        Add the rubric below the chart of kinds2.6;
-    }
+

Run through the kinds in priority order1.1 = +

- for (priority = 1; priority <= LOWEST_INDEX_PRIORITY; priority++) { +
+    for (int priority = 1; priority <= LOWEST_INDEX_PRIORITY; priority++) {
         for (int i=0; i<TreeLists::len(inv->kind_nodes); i++) {
             inter_package *pack = Inter::Package::defined_by_frame(inv->kind_nodes->list[i].node);
             if ((Metadata::read_optional_numeric(pack, I"^is_base")) &&
                 (Metadata::read_optional_numeric(pack, I"^is_subkind_of_object") == 0) &&
                 (priority == (int) Metadata::read_optional_numeric(pack, I"^index_priority"))) {
                 if ((priority == 8) || (Metadata::read_optional_numeric(pack, I"^is_definite"))) {
-                    switch (pass) {
-                        case 1: Write table row for this kind2.5; break;
-                        case 2: {
-                            Write heading for the detailed index entry for this kind2.7;
-                            HTML::open_indented_p(OUT, 1, "tight");
-                            Index kinds of kinds matched by this kind2.9;
-                            Index explanatory text supplied for a kind2.11;
-                            Index literal patterns which can specify this kind2.8;
-                            Index possible values of an enumerated kind2.10;
-                            HTML_CLOSE("p");
-                            break;
-                        }
-                    }
-                    if (Str::eq(Metadata::read_textual(pack, I"^printed_name"), I"object"))
-                        Recurse to index subkinds of object2.1;
+                    Index this kind package1.1.2;
                 }
             }
         }
         if ((priority == 1) || (priority == 6) || (priority == 7)) {
             if (pass == 1) {
-                Add a dotty row to the chart of kinds2.4;
+                Add a dotty row to the chart of kinds1.3;
                 if (priority == 7) {
-                    Add a second titling row to the chart of kinds2.3;
-                    Add a dotty row to the chart of kinds2.4;
+                    Add a second titling row to the chart of kinds1.1.1;
+                    Add a dotty row to the chart of kinds1.3;
                 }
             } else HTML_TAG("hr");
         }
     }
-
-    if (pass == 1) {
-        Add a dotty row to the chart of kinds2.4;
-        HTML::end_html_table(OUT);
-    } else {
-        Explain about covariance and contravariance2.12;
-    }
-}
 
-

§2.1. Recurse to index subkinds of object2.1 = +

+

§1.2. An atypical row:

-
-    ChartElement::index_subkinds(OUT, inv, pack, 2, pass);
-
- -

§2.2. An atypical row: -

- -

Add a titling row to the chart of kinds2.2 = +

Add a titling row to the chart of kinds1.2 =

     HTML::first_html_column_nowrap(OUT, 0, "#e0e0e0");
-    WRITE("<b>basic kinds</b>");
-    ChartElement::index_kind_col_head(OUT, "default value", "default");
-    ChartElement::index_kind_col_head(OUT, "repeat", "repeat");
-    ChartElement::index_kind_col_head(OUT, "props", "props");
-    ChartElement::index_kind_col_head(OUT, "under", "under");
+    WRITE("<b>");
+    Localisation::write_0(OUT, D, I"Index.Elements.Ch.BasicKinds");
+    WRITE("</b>");
+    ChartElement::index_kind_col_head(OUT, I"Index.Elements.Ch.DefaultColumn", "default", D);
+    ChartElement::index_kind_col_head(OUT, I"Index.Elements.Ch.RepeatColumn", "repeat", D);
+    ChartElement::index_kind_col_head(OUT, I"Index.Elements.Ch.PropsColumn", "props", D);
+    ChartElement::index_kind_col_head(OUT, I"Index.Elements.Ch.UnderColumn", "under", D);
     HTML::end_html_row(OUT);
 
- -

§2.3. And another: +

+

§1.1.1. And another:

-

Add a second titling row to the chart of kinds2.3 = +

Add a second titling row to the chart of kinds1.1.1 =

     HTML::first_html_column_nowrap(OUT, 0, "#e0e0e0");
-    WRITE("<b>making new kinds from old</b>");
-    ChartElement::index_kind_col_head(OUT, "default value", "default");
-    ChartElement::index_kind_col_head(OUT, "", NULL);
-    ChartElement::index_kind_col_head(OUT, "", NULL);
-    ChartElement::index_kind_col_head(OUT, "", NULL);
+    WRITE("<b>");
+    Localisation::write_0(OUT, D, I"Index.Elements.Ch.NewKinds");
+    WRITE("</b>");
+    ChartElement::index_kind_col_head(OUT, I"Index.Elements.Ch.DefaultColumn", "default", D);
+    ChartElement::index_kind_col_head(OUT, NULL, NULL, D);
+    ChartElement::index_kind_col_head(OUT, NULL, NULL, D);
+    ChartElement::index_kind_col_head(OUT, NULL, NULL, D);
     HTML::end_html_row(OUT);
 
- -

§2.4. A dotty row: +

+

§1.3. A dotty row:

-

Add a dotty row to the chart of kinds2.4 = +

Add a dotty row to the chart of kinds1.3 =

@@ -210,96 +183,90 @@ higher up, but kinds with priority 0 do not appear in the index at all.
     HTML_CLOSE("td");
     HTML_CLOSE("tr");
 
- -

§2.5. And then a typical row: -

- -

Write table row for this kind2.5 = -

- -
-    char *repeat = "cross", *props = "cross", *under = "cross";
-    int shaded = FALSE;
-    if (Metadata::read_optional_numeric(pack, I"^shaded_in_index")) shaded = TRUE;
-    if (Metadata::read_optional_numeric(pack, I"^finite_domain")) repeat = "tick";
-    if (Metadata::read_optional_numeric(pack, I"^has_properties")) props = "tick";
-    if (Metadata::read_optional_numeric(pack, I"^understandable")) under = "tick";
-    if (priority == 8) { repeat = NULL; props = NULL; under = NULL; }
-    ChartElement::begin_chart_row(OUT);
-    ChartElement::index_kind_name_cell(OUT, shaded, pack);
-    ChartElement::end_chart_row(OUT, shaded, pack, repeat, props, under);
-
- -

§2.6. Note the named anchors here, which must match those linked from the titling +

+

§1.4. Note the named IDs here, which must match those linked from the titling row.

-

Add the rubric below the chart of kinds2.6 = +

Add the rubric below the chart of kinds1.4 =

     HTML_OPEN_WITH("tr", "style=\"display:none\" id=\"default\"");
     HTML_OPEN_WITH("td", "colspan=\"5\"");
-    WRITE("The <b>default value</b> is used when we make something like "
-        "a variable but don't tell Inform what its value is. For instance, if "
-        "we write 'Zero hour is a time that varies', but don't tell Inform "
-        "anything specific like 'Zero hour is 11:21 PM.', then Inform uses "
-        "the value in the table above to decide what it will be. "
-        "The same applies if we create a property (for instance, 'A person "
-        "has a number called lucky number.'). Kinds of value not included "
-        "in the table cannot be used in variables and properties.");
+    Localisation::write_0(OUT, D, I"Index.Elements.Ch.DefaultGloss");
     HTML_TAG("hr");
     HTML_CLOSE("td");
     HTML_CLOSE("tr");
     HTML_OPEN_WITH("tr", "style=\"display:none\" id=\"repeat\"");
     HTML_OPEN_WITH("td", "colspan=\"5\"");
-    WRITE("A tick for <b>repeat</b> means that it's possible to "
-        "repeat through values of this kind. For instance, 'repeat with T "
-        "running through times:' is allowed, but 'repeat with N running "
-        "through numbers:' is not - there are too many numbers for this to "
-        "make sense. A tick here also means it's possible to form lists such "
-        "as 'list of rulebooks', or to count the 'number of scenes'.");
+    Localisation::write_0(OUT, D, I"Index.Elements.Ch.RepeatGloss");
     HTML_TAG("hr");
     HTML_CLOSE("td");
     HTML_CLOSE("tr");
     HTML_OPEN_WITH("tr", "style=\"display:none\" id=\"props\"");
     HTML_OPEN_WITH("td", "colspan=\"5\"");
-    WRITE("A tick for <b>props</b> means that values of this "
-        "kind can have properties. For instance, 'A scene can be thrilling or "
-        "dull.' makes an either/or property of a scene, but 'A number can be "
-        "nice or nasty.' is not allowed because it would cost too much storage "
-        "space. (Of course 'Definition:' can always be used to make adjectives "
-        "applying to numbers; it's only properties which have storage "
-        "worries.)");
+    Localisation::write_0(OUT, D, I"Index.Elements.Ch.PropsGloss");
     HTML_TAG("hr");
     HTML_CLOSE("td");
     HTML_CLOSE("tr");
     HTML_OPEN_WITH("tr", "style=\"display:none\" id=\"under\"");
     HTML_OPEN_WITH("td", "colspan=\"5\"");
-    WRITE("A tick for <b>under</b> means that it's possible "
-        "to understand values of this kind. For instance, 'Understand \"award "
-        "[number]\" as awarding.' might be allowed, if awarding were an action "
-        "applying to a number, but 'Understand \"run [rule]\" as rule-running.' "
-        "is not allowed - there are so many rules with such long names that "
-        "Inform doesn't add them to its vocabulary during play.");
+    Localisation::write_0(OUT, D, I"Index.Elements.Ch.UnderGloss");
     HTML_TAG("hr");
     HTML_CLOSE("td");
     HTML_CLOSE("tr");
 
- -

§2.7. The detailed entry lower down the page begins with: +

+

§1.1.2. So, the actual content, which is presented as a row of the table in pass 1, +or as paragraph of text in pass 2:

-

Write heading for the detailed index entry for this kind2.7 = +

Index this kind package1.1.2 = +

+ +
+    switch (pass) {
+        case 1: {
+            char *repeat = "cross", *props = "cross", *under = "cross";
+            int shaded = FALSE;
+            if (Metadata::read_optional_numeric(pack, I"^shaded_in_index")) shaded = TRUE;
+            if (Metadata::read_optional_numeric(pack, I"^finite_domain")) repeat = "tick";
+            if (Metadata::read_optional_numeric(pack, I"^has_properties")) props = "tick";
+            if (Metadata::read_optional_numeric(pack, I"^understandable")) under = "tick";
+            if (priority == 8) { repeat = NULL; props = NULL; under = NULL; }
+            ChartElement::begin_chart_row(OUT);
+            ChartElement::index_kind_name_cell(OUT, shaded, pack);
+            ChartElement::end_chart_row(OUT, shaded, pack, repeat, props, under);
+            break;
+        }
+        case 2: {
+            Write heading for the detailed index entry for this kind1.1.2.1;
+            HTML::open_indented_p(OUT, 1, "tight");
+            Index kinds of kinds matched by this kind1.1.2.3;
+            Index explanatory text supplied for a kind1.1.2.5;
+            Index literal patterns which can specify this kind1.1.2.2;
+            Index possible values of an enumerated kind1.1.2.4;
+            HTML_CLOSE("p");
+            break;
+        }
+    }
+    if (Str::eq(Metadata::read_textual(pack, I"^printed_name"), I"object"))
+        ChartElement::index_subkinds(OUT, inv, pack, 2, pass, D);
+
+ +

§1.1.2.1. Write heading for the detailed index entry for this kind1.1.2.1 =

     HTML::open_indented_p(OUT, 1, "halftight");
-    IndexUtilities::anchor_numbered(OUT, i);  ...the anchor to which the grey icon in the table led
-    WRITE("<b>"); ChartElement::index_kind(OUT, pack, FALSE, TRUE); WRITE("</b>");
-    WRITE(" (<i>plural</i> "); ChartElement::index_kind(OUT, pack, TRUE, FALSE); WRITE(")");
-    text_stream *doc_ref = Metadata::read_optional_textual(pack, I"^documentation");
-    if (Str::len(doc_ref) > 0) IndexUtilities::DocReferences::link(OUT, doc_ref);  blue help icon, if any
+    IndexUtilities::anchor_numbered(OUT, i);  ...the anchor to which the grey icon in the table led
+    WRITE("<b>"); IndexUtilities::kind_name(OUT, pack, FALSE, TRUE); WRITE("</b>");
+    WRITE(" (<i>");
+    Localisation::write_0(OUT, D, I"Index.Elements.Ch.Plural");
+    WRITE("</i> ");
+    IndexUtilities::kind_name(OUT, pack, TRUE, FALSE); WRITE(")");
+    IndexUtilities::link_to_documentation(OUT, pack);
     HTML_CLOSE("p");
     text_stream *variance =  Metadata::read_optional_textual(pack, I"^variance");
     if (Str::len(variance) > 0) {
@@ -312,8 +279,8 @@ row.
         HTML_CLOSE("p");
     }
 
- -

§2.8. Index literal patterns which can specify this kind2.8 = +

+

§1.1.2.2. Index literal patterns which can specify this kind1.1.2.2 =

@@ -323,71 +290,63 @@ row.
         HTML_TAG("br");
     }
 
- -

§2.9. Index kinds of kinds matched by this kind2.9 = +

+

§1.1.2.3. Index kinds of kinds matched by this kind1.1.2.3 =

     int f = FALSE;
     WRITE("<i>Matches:</i> ");
-    inter_symbol *wanted = PackageTypes::get(inv->of_tree, I"_conformance");
-    inter_tree_node *D = Inter::Packages::definition(pack);
-    LOOP_THROUGH_INTER_CHILDREN(C, D) {
-        if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-            inter_package *entry = Inter::Package::defined_by_frame(C);
-            if (Inter::Packages::type(entry) == wanted) {
-                inter_symbol *xref = Metadata::read_optional_symbol(entry, I"^conformed_to");
-                inter_package *other = Inter::Packages::container(xref->definition);
-                if (f) WRITE(", ");
-                ChartElement::index_kind(OUT, other, FALSE, TRUE);
-                f = TRUE;
-            }
-        }
+    inter_package *conf_pack;
+    LOOP_THROUGH_SUBPACKAGES(conf_pack, pack, I"_conformance") {
+        inter_symbol *xref = Metadata::read_optional_symbol(conf_pack, I"^conformed_to");
+        inter_package *other = Inter::Packages::container(xref->definition);
+        if (f) WRITE(", ");
+        IndexUtilities::kind_name(OUT, other, FALSE, TRUE);
+        f = TRUE;
     }
     HTML_TAG("br");
 
- -

§2.10. Index possible values of an enumerated kind2.10 = +

+

§1.1.2.4. Index possible values of an enumerated kind1.1.2.4 =

     if (Str::ne(Metadata::read_textual(pack, I"^printed_name"), I"object"))
         if (Metadata::read_optional_numeric(pack, I"^instance_count") > 0)
-            ChartElement::index_instances(OUT, inv, pack, 1);
+            ChartElement::index_instances(OUT, inv, pack, 1);
 
- -

§2.11. Index explanatory text supplied for a kind2.11 = +

+

§1.1.2.5. Index explanatory text supplied for a kind1.1.2.5 =

-    ChartElement::index_inferences(OUT, pack, FALSE);
+    ChartElement::index_inferences(OUT, pack, FALSE);
 
- -

§2.12. Explain about covariance and contravariance2.12 = +

+

§1.5. Explain about covariance and contravariance1.5 =

     HTML_OPEN("p");
     HTML_TAG_WITH("a", "name=contra");
     HTML_OPEN_WITH("span", "class=\"smaller\"");
-    WRITE("<b>Covariance</b> means that if K is a kind of L, then something "
-        "you make from K can be used as the same thing made from L. For example, "
-        "a list of doors can be used as a list of things, because 'list of K' is "
-        "covariant. <b>Contravariance</b> means it works the other way round. "
-        "For example, an activity on things can be used as an activity on doors, "
-        "but not vice versa, because 'activity of K' is contravariant.");
+    Localisation::write_0(OUT, D, I"Index.Elements.Ch.CovarianceGloss");
     HTML_CLOSE("span");
     HTML_CLOSE("p");
 
- -

§3. Kind table construction. First, here's the table cell for the heading at the top of a column: the +

+

§2. Kind table construction. First, here's the table cell for the heading at the top of a column: the link is to the part of the rubric explaining what goes into the column.

-void ChartElement::index_kind_col_head(OUTPUT_STREAM, char *name, char *anchor) {
+void ChartElement::index_kind_col_head(OUTPUT_STREAM, text_stream *key, char *anchor,
+    localisation_dictionary *D) {
     HTML::next_html_column_nowrap(OUT, 0);
-    WRITE("<i>%s</i>&nbsp;", name);
+    WRITE("<i>");
+    if (Str::len(key) > 0) Localisation::write_0(OUT, D, key);
+    WRITE("</i>&nbsp;");
     if (anchor) {
         HTML_OPEN_WITH("a", "href=\"#\" onClick=\"showBasic('%s');\"", anchor);
         HTML_TAG_WITH("img", "border=0 src=inform:/doc_images/shelp.png");
@@ -395,55 +354,48 @@ link is to the part of the rubric explaining what goes into the column.
     }
 }
 
-

§4. Once we're past the heading row, each row is made in two parts: first this +

§3. Once we're past the heading row, each row is made in two parts: first this is called —

 int striper = FALSE;
-void ChartElement::begin_chart_row(OUTPUT_STREAM) {
+void ChartElement::begin_chart_row(OUTPUT_STREAM) {
     char *col = NULL;
     if (striper) col = "#f0f0ff";
     striper = striper?FALSE:TRUE;
     HTML::first_html_column_nowrap(OUT, 0, col);
 }
 
-

§5. That leads us into the cell for the name of the kind. The following -routine is used for the kind rows, but not for the kinds-of-object -rows; the cell for those is filled in a different way in "Index -Physical World". -

- -

It's convenient to return the shadedness: a row is shaded if it's for -a kind which can have enumerated values but doesn't at the moment — -for instance, the sound effects row is shaded if there are none. +

§4. It's convenient to return the shadedness: a row is shaded if it's for a kind +which can have enumerated values but doesn't at the moment — for instance, the +sound effects row is shaded if there are none.

-int ChartElement::index_kind_name_cell(OUTPUT_STREAM, int shaded, inter_package *pack) {
+int ChartElement::index_kind_name_cell(OUTPUT_STREAM, int shaded, inter_package *pack) {
     if (shaded) HTML::begin_colour(OUT, I"808080");
-    ChartElement::index_kind(OUT, pack, FALSE, TRUE);
+    IndexUtilities::kind_name(OUT, pack, FALSE, TRUE);
     if (Metadata::read_optional_numeric(pack, I"^is_quasinumerical")) {
         WRITE("&nbsp;");
         HTML_OPEN_WITH("a", "href=\"Kinds.html?segment2\"");
         HTML_TAG_WITH("img", "border=0 src=inform:/doc_images/calc1.png");
         HTML_CLOSE("a");
     }
-    text_stream *doc_ref = Metadata::read_optional_textual(pack, I"^documentation");
-    if (Str::len(doc_ref) > 0) IndexUtilities::DocReferences::link(OUT, doc_ref);
+    IndexUtilities::link_to_documentation(OUT, pack);
     int i = (int) Metadata::read_optional_numeric(pack, I"^instance_count");
     if (i >= 1) WRITE(" [%d]", i);
-    IndexUtilities::below_link_numbered(OUT, pack->allocation_id);
+    IndexUtilities::below_link_numbered(OUT, pack->allocation_id);
     if (shaded) HTML::end_colour(OUT);
     return shaded;
 }
 
-

§6. Finally we close the name cell, add the remaining cells, and close out the +

§5. Finally we close the name cell, add the remaining cells, and close out the whole row.

-void ChartElement::end_chart_row(OUTPUT_STREAM, int shaded, inter_package *pack,
+void ChartElement::end_chart_row(OUTPUT_STREAM, int shaded, inter_package *pack,
     char *tick1, char *tick2, char *tick3) {
     if (tick1) HTML::next_html_column(OUT, 0);
     else HTML::next_html_column_spanning(OUT, 0, 4);
@@ -470,71 +422,61 @@ whole row.
     HTML::end_html_row(OUT);
 }
 
-

§7. Indexing kind names.

- -
-void ChartElement::index_kind(OUTPUT_STREAM, inter_package *pack, int plural, int with_links) {
-    if (pack == NULL) return;
-    text_stream *key = (plural)?I"^index_plural":I"^index_singular";
-    WRITE("%S", Metadata::read_optional_textual(pack, key));
-    if (with_links) {
-        int at = (int) Metadata::read_optional_numeric(pack, I"^at");
-        if (at > 0) IndexUtilities::link(OUT, at);
-    }
-}
-
-

§8.

+

§6. Recursing through subkinds. The following limitation exists just to catch errors. +

define MAX_OBJECT_INDEX_DEPTH 10000
 
-void ChartElement::index_subkinds(OUTPUT_STREAM, tree_inventory *inv, inter_package *pack, int depth, int pass) {
+void ChartElement::index_subkinds(OUTPUT_STREAM, tree_inventory *inv, inter_package *pack,
+    int depth, int pass, localisation_dictionary *D) {
     for (int j=0; j<TreeLists::len(inv->kind_nodes); j++) {
         inter_package *inner_pack = Inter::Package::defined_by_frame(inv->kind_nodes->list[j].node);
         if ((Metadata::read_optional_numeric(inner_pack, I"^is_base")) &&
             (Metadata::read_optional_numeric(inner_pack, I"^is_subkind_of_object"))) {
             inter_symbol *super_weak = Metadata::read_optional_symbol(inner_pack, I"^superkind");
             if ((super_weak) && (Inter::Packages::container(super_weak->definition) == pack))
-                ChartElement::index_object_kind(OUT, inv, inner_pack, depth, pass);
+                ChartElement::index_object_kind(OUT, inv, inner_pack, depth, pass, D);
         }
     }
 }
 
-void ChartElement::index_object_kind(OUTPUT_STREAM, tree_inventory *inv, inter_package *pack, int depth, int pass) {
+void ChartElement::index_object_kind(OUTPUT_STREAM, tree_inventory *inv,
+    inter_package *pack, int depth, int pass, localisation_dictionary *D) {
     if (depth == MAX_OBJECT_INDEX_DEPTH) internal_error("MAX_OBJECT_INDEX_DEPTH exceeded");
     inter_symbol *class_s = Metadata::read_optional_symbol(pack, I"^object_class");
     if (class_s == NULL) internal_error("no class for object kind");
     text_stream *anchor = class_s->symbol_name;
 
     int shaded = FALSE;
-    Begin the object citation line8.1;
-    Index the name part of the object citation8.3;
-    Index the link icons part of the object citation8.4;
-    End the object citation line8.2;
-    if (pass == 2) Add a subsidiary paragraph of details about this object8.5;
-    ChartElement::index_subkinds(OUT, inv, pack, depth+1, pass);
+    Begin the object citation line6.1;
+    Index the name part of the object citation6.3;
+    Index the link icons part of the object citation6.4;
+    End the object citation line6.2;
+    if (pass == 2) Add a subsidiary paragraph of details about this object6.5;
+    ChartElement::index_subkinds(OUT, inv, pack, depth+1, pass, D);
 }
 
-

§8.1. Begin the object citation line8.1 = +

§6.1. Begin the object citation line6.1 =

-    if (pass == 1) ChartElement::begin_chart_row(OUT);
+    if (pass == 1) ChartElement::begin_chart_row(OUT);
     if (pass == 2) {
         HTML::open_indented_p(OUT, depth, "halftight");
-        IndexUtilities::anchor(OUT, anchor);
+        IndexUtilities::anchor(OUT, anchor);
     }
 
- -

§8.2. End the object citation line8.2 = +

+

§6.2. End the object citation line6.2 =

-    if (pass == 1) ChartElement::end_chart_row(OUT, shaded, pack, "tick", "tick", "tick");
+    if (pass == 1) ChartElement::end_chart_row(OUT, shaded, pack, "tick", "tick", "tick");
     if (pass == 2) HTML_CLOSE("p");
 
- -

§8.3. Index the name part of the object citation8.3 = +

+

§6.3. Index the name part of the object citation6.3 =

@@ -542,78 +484,78 @@ whole row.
         int c = (int) Metadata::read_optional_numeric(pack, I"^instance_count");
         if ((c == 0) && (pass == 1)) shaded = TRUE;
         if (shaded) HTML::begin_colour(OUT, I"808080");
-        Quote the name of the object being indexed8.3.1;
+        Quote the name of the object being indexed6.3.1;
         if (shaded) HTML::end_colour(OUT);
         if ((pass == 1) && (c > 0)) WRITE(" [%d]", c);
     } else {
-        Quote the name of the object being indexed8.3.1;
+        Quote the name of the object being indexed6.3.1;
     }
 
- -

§8.3.1. Quote the name of the object being indexed8.3.1 = +

+

§6.3.1. Quote the name of the object being indexed6.3.1 =

     if (pass == 2) WRITE("<b>");
-    ChartElement::index_kind(OUT, pack, FALSE, FALSE);
+    IndexUtilities::kind_name(OUT, pack, FALSE, FALSE);
     if (pass == 2) WRITE("</b>");
     if (pass == 2) {
-        WRITE(" (<i>plural</i> "); ChartElement::index_kind(OUT, pack, TRUE, FALSE);
+        WRITE(" (<i>");
+        Localisation::write_0(OUT, D, I"Index.Elements.Ch.Plural");
+        WRITE("</i> ");
+        IndexUtilities::kind_name(OUT, pack, TRUE, FALSE);
         WRITE(")");
     }
 
- -

§8.4. Index the link icons part of the object citation8.4 = +

+

§6.4. Index the link icons part of the object citation6.4 =

-    int at = (int) Metadata::read_optional_numeric(pack, I"^at");
-    if (at > 0) IndexUtilities::link(OUT, at);
-    text_stream *doc_ref = Metadata::read_optional_textual(pack, I"^documentation");
-    if (Str::len(doc_ref) > 0) IndexUtilities::DocReferences::link(OUT, doc_ref);
-    if (pass == 1) IndexUtilities::below_link(OUT, anchor);
+    IndexUtilities::link_package(OUT, pack);
+    IndexUtilities::link_to_documentation(OUT, pack);
+    if (pass == 1) IndexUtilities::below_link(OUT, anchor);
 
- -

§8.5. Add a subsidiary paragraph of details about this object8.5 = +

+

§6.5. Add a subsidiary paragraph of details about this object6.5 =

     HTML::open_indented_p(OUT, depth, "tight");
-    ChartElement::index_inferences(OUT, pack, TRUE);
+    ChartElement::index_inferences(OUT, pack, TRUE);
     HTML_CLOSE("p");
-    ChartElement::index_instances(OUT, inv, pack, depth);
+    ChartElement::index_instances(OUT, inv, pack, depth);
 
- -

§9.

+ +

§7.

-int ii_xtras = 900000;
-
-void ChartElement::index_instances(OUTPUT_STREAM, tree_inventory *inv, inter_package *pack, int depth) {
+void ChartElement::index_instances(OUTPUT_STREAM, tree_inventory *inv, inter_package *pack,
+    int depth) {
     HTML::open_indented_p(OUT, depth, "tight");
     int c = (int) Metadata::read_optional_numeric(pack, I"^instance_count");
     if (c >= 10) {
-        int xtra = ii_xtras++;
-        IndexUtilities::extra_link(OUT, xtra);
+        int xtra = IndexRules::extra_ID();
+        IndexUtilities::extra_link(OUT, xtra);
         HTML::begin_colour(OUT, I"808080");
         WRITE("%d ", c);
-        ChartElement::index_kind(OUT, pack, TRUE, FALSE);
+        IndexUtilities::kind_name(OUT, pack, TRUE, FALSE);
         HTML::end_colour(OUT);
         HTML_CLOSE("p");
-        IndexUtilities::extra_div_open(OUT, xtra, depth+1, "e0e0e0");
-        Itemise the instances9.1;
-        IndexUtilities::extra_div_close(OUT, "e0e0e0");
+        IndexUtilities::extra_div_open(OUT, xtra, depth+1, "e0e0e0");
+        Itemise the instances7.1;
+        IndexUtilities::extra_div_close(OUT, "e0e0e0");
     } else {
-        Itemise the instances9.1;
+        Itemise the instances7.1;
         HTML_CLOSE("p");
     }
 }
 
-

§9.1. Itemise the instances9.1 = +

§7.1. Itemise the instances7.1 =

-    c = 0;
+    int c = 0;
     for (int i=0; i<TreeLists::len(inv->instance_nodes); i++) {
         inter_package *I_pack = Inter::Package::defined_by_frame(inv->instance_nodes->list[i].node);
         inter_symbol *strong_kind_ID = Metadata::read_optional_symbol(I_pack, I"^kind_xref");
@@ -622,16 +564,16 @@ whole row.
             HTML::begin_colour(OUT, I"808080");
             WRITE("%S", Metadata::read_optional_textual(I_pack, I"^name"));
             HTML::end_colour(OUT);
-            int at = (int) Metadata::read_optional_numeric(I_pack, I"^at");
-            if (at > 0) IndexUtilities::link(OUT, at);
+            IndexUtilities::link_package(OUT, I_pack);
         }
     }
 
- -

§10.

+ +

§8. Here pack can be either an instance or a kind package. +

-void ChartElement::index_inferences(OUTPUT_STREAM, inter_package *pack, int brief) {
+void ChartElement::index_inferences(OUTPUT_STREAM, inter_package *pack, int brief) {
     text_stream *explanation = Metadata::read_optional_textual(pack, I"^specification");
     if (Str::len(explanation) > 0) {
         WRITE("%S", explanation);
diff --git a/docs/index-module/3-ce3.html b/docs/index-module/3-ce3.html
index 0a281ec39..75a651a47 100644
--- a/docs/index-module/3-ce3.html
+++ b/docs/index-module/3-ce3.html
@@ -72,7 +72,7 @@ function togglePopup(material_id) {
     
 

To write the Commands element (Cm) in the index.

-
+

§1.

@@ -80,106 +80,51 @@ function togglePopup(material_id) { void CommandsElement::render(OUTPUT_STREAM, localisation_dictionary *LD) { inter_tree *I = InterpretIndex::get_tree(); - command_index_entry *vie, *vie2, *last_vie2, *list_start = NULL; - int head_letter; + linked_list *entries = NEW_LINKED_LIST(command_index_entry); + Create the entries for the command list1.1; + linked_list *sorted = CommandsElement::sort(entries); - inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/grammar"); - inter_symbol *wanted = PackageTypes::get(I, I"_command_grammar"); - inter_tree_node *D = Inter::Packages::definition(pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - if ((Metadata::read_optional_numeric(entry, I"^is_command")) && - (CommandsElement::no_lines(I, entry) > 0)) { - text_stream *main_command = Metadata::read_optional_textual(entry, I"^command"); - if (Str::len(main_command) == 0) main_command = I"0"; - CommandsElement::vie_new_from(main_command, entry, NORMAL_COMMAND); - inter_symbol *wanted_i = PackageTypes::get(I, I"_cg_alias"); - LOOP_THROUGH_INTER_CHILDREN(B, C) { - if (B->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *alias = Inter::Package::defined_by_frame(B); - if (Inter::Packages::type(alias) == wanted_i) { - text_stream *alias_command = Metadata::read_textual(alias, I"^alias"); - CommandsElement::vie_new_from(alias_command, entry, ALIAS_COMMAND); - } - } - } - } - } - } - } - - CommandsElement::direction_verb(); - - LOOP_OVER(vie, command_index_entry) { - if (list_start == NULL) { list_start = vie; continue; } - vie2 = list_start; - last_vie2 = NULL; - while (vie2 && (Str::cmp(vie->command_headword, vie2->command_headword) > 0)) { - last_vie2 = vie2; - vie2 = vie2->next_alphabetically; - } - if (last_vie2 == NULL) { - vie->next_alphabetically = list_start; list_start = vie; - } else { - last_vie2->next_alphabetically = vie; vie->next_alphabetically = vie2; - } - } - - for (vie = list_start, head_letter = 0; vie; vie = vie->next_alphabetically) { - if (Str::get_first_char(vie->command_headword) != head_letter) { + wchar_t head_letter = 0; + command_index_entry *cie; + LOOP_OVER_LINKED_LIST(cie, command_index_entry, sorted) { + if (Str::get_first_char(cie->command_headword) != head_letter) { if (head_letter) HTML_TAG("br"); - head_letter = Str::get_first_char(vie->command_headword); - } - inter_package *cg = vie->cg_indexed; - switch (vie->nature) { - case NORMAL_COMMAND: - CommandsElement::index_normal(OUT, I, cg, vie->command_headword); - break; - case ALIAS_COMMAND: - CommandsElement::index_alias(OUT, I, cg, vie->command_headword); - break; - case OUT_OF_WORLD_COMMAND: - HTML::begin_colour(OUT, I"800000"); - WRITE("&quot;%S&quot;, <i>a command for controlling play</i>", - vie->command_headword); - HTML::end_colour(OUT); - HTML_TAG("br"); - break; - case TESTING_COMMAND: - HTML::begin_colour(OUT, I"800000"); - WRITE("&quot;%S&quot;, <i>a testing command not available " - "in the final game</i>", - vie->command_headword); - HTML::end_colour(OUT); - HTML_TAG("br"); - break; - case BARE_DIRECTION_COMMAND: - WRITE("&quot;[direction]&quot; - <i>going</i>"); - HTML_TAG("br"); - break; + head_letter = Str::get_first_char(cie->command_headword); } + Render an index entry from the sorted list1.5; } } - -int CommandsElement::no_lines(inter_tree *I, inter_package *cg) { - int N = 0; - inter_symbol *wanted = PackageTypes::get(I, I"_cg_line"); - inter_tree_node *D = Inter::Packages::definition(cg); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) N++; - } - } - return N; -}
-

§2. The following modest structure is used for the indexing of command verbs, -and is too deeply boring to comment upon. These are the headwords of commands -which can be typed at run-time, like QUIT or INVENTORY. For indexing purposes, -we divide these headwords into five "natures": +

§1.1. Create the entries for the command list1.1 = +

+ +
+    inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/grammar");
+    inter_package *entry;
+    LOOP_THROUGH_SUBPACKAGES(entry, pack, I"_command_grammar")
+        if ((Metadata::read_optional_numeric(entry, I"^is_command")) &&
+            (InterTree::no_subpackages(entry, I"_cg_line") > 0))
+            Create entry for this command1.1.1;
+    CommandsElement::make_direction_entry(entries);
+
+ +

§1.1.1. Create entry for this command1.1.1 = +

+ +
+    text_stream *main_command = Metadata::read_optional_textual(entry, I"^command");
+    if (Str::len(main_command) == 0) main_command = I"0";
+    CommandsElement::make_entry(main_command, entry, NORMAL_COMMAND, entries);
+    inter_package *alias;
+    LOOP_THROUGH_SUBPACKAGES(alias, entry, I"_cg_alias") {
+        text_stream *alias_command = Metadata::read_textual(alias, I"^alias");
+        CommandsElement::make_entry(alias_command, entry, ALIAS_COMMAND, entries);
+    }
+
+ +

§1.2. Entries in the list correspond to the headwords of commands which can be typed +at runtime, like QUIT or INVENTORY. For indexing purposes, we divide these headwords +as follows:

define NORMAL_COMMAND 1
@@ -200,86 +145,147 @@ we divide these headwords into five "natures":
 command_index_entry *sorted_command_index = NULL;  in alphabetical order of text
 
-

§3.

+

§1.3.

-void CommandsElement::test_verb(text_stream *t) {
-    command_index_entry *vie;
-    vie = CREATE(command_index_entry);
-    vie->command_headword = Str::duplicate(t);
-    vie->nature = TESTING_COMMAND;
-    vie->cg_indexed = NULL;
-    vie->next_alphabetically = NULL;
+void CommandsElement::make_test_entry(text_stream *t, linked_list *entries) {
+    command_index_entry *cie;
+    cie = CREATE(command_index_entry);
+    cie->command_headword = Str::duplicate(t);
+    cie->nature = TESTING_COMMAND;
+    cie->cg_indexed = NULL;
+    cie->next_alphabetically = NULL;
+    ADD_TO_LINKED_LIST(cie, command_index_entry, entries);
 }
 
-command_index_entry *CommandsElement::vie_new_from(text_stream *headword, inter_package *cg, int nature) {
-    command_index_entry *vie = CREATE(command_index_entry);
-    vie->command_headword = Str::duplicate(headword);
-    vie->nature = nature;
-    vie->cg_indexed = cg;
-    vie->next_alphabetically = NULL;
-    return vie;
+void CommandsElement::make_entry(text_stream *headword, inter_package *cg_pack,
+    int nature, linked_list *entries) {
+    command_index_entry *cie = CREATE(command_index_entry);
+    cie->command_headword = Str::duplicate(headword);
+    cie->nature = nature;
+    cie->cg_indexed = cg_pack;
+    cie->next_alphabetically = NULL;
+    ADD_TO_LINKED_LIST(cie, command_index_entry, entries);
 }
 
-void CommandsElement::direction_verb(void) {
-    command_index_entry *vie = CREATE(command_index_entry);
-    vie->command_headword = I"0";
-    vie->nature = BARE_DIRECTION_COMMAND;
-    vie->cg_indexed = NULL;
-    vie->next_alphabetically = NULL;
+void CommandsElement::make_direction_entry(linked_list *entries) {
+    command_index_entry *cie = CREATE(command_index_entry);
+    cie->command_headword = I"0";
+    cie->nature = BARE_DIRECTION_COMMAND;
+    cie->cg_indexed = NULL;
+    cie->next_alphabetically = NULL;
+    ADD_TO_LINKED_LIST(cie, command_index_entry, entries);
 }
 
-

§4. Indexing by grammar. This is the more obvious form of indexing: we show the grammar lines which -make up an individual CGL. (For instance, this is used in the Actions index -to show the grammar for an individual command word, by calling the routine -below for that command word's CG.) Such an index list is done in sorted -order, so that the order of appearance in the index corresponds to the -order of parsing — this is what the reader of the index is interested in. +

§1.4.

+ +
+linked_list *CommandsElement::sort(linked_list *entries) {
+    command_index_entry *cie, *list_start = NULL;
+    LOOP_OVER_LINKED_LIST(cie, command_index_entry, entries) {
+        if (list_start == NULL) { list_start = cie; continue; }
+        command_index_entry *cie2 = list_start, *last_cie2 = NULL;
+        while (cie2 && (Str::cmp(cie->command_headword, cie2->command_headword) > 0)) {
+            last_cie2 = cie2;
+            cie2 = cie2->next_alphabetically;
+        }
+        if (last_cie2 == NULL) {
+            cie->next_alphabetically = list_start; list_start = cie;
+        } else {
+            last_cie2->next_alphabetically = cie; cie->next_alphabetically = cie2;
+        }
+    }
+    linked_list *sorted = NEW_LINKED_LIST(command_index_entry);
+    for (command_index_entry *cie = list_start; cie; cie = cie->next_alphabetically)
+        ADD_TO_LINKED_LIST(cie, command_index_entry, sorted);
+    return sorted;
+}
+
+

§1.5. With those lengthy digressions done, back to the actual indexing: +

+ +

Render an index entry from the sorted list1.5 =

-void CommandsElement::index_normal(OUTPUT_STREAM, inter_tree *I, inter_package *cg, text_stream *headword) {
-    inter_symbol *wanted = PackageTypes::get(I, I"_cg_line");
-    inter_tree_node *D = Inter::Packages::definition(cg);
-    LOOP_THROUGH_INTER_CHILDREN(C, D) {
-        if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-            inter_package *entry = Inter::Package::defined_by_frame(C);
-            if (Inter::Packages::type(entry) == wanted)
-                CommandsElement::cgl_index_normal(OUT, entry, headword);
-        }
+    inter_package *cg_pack = cie->cg_indexed;
+    switch (cie->nature) {
+        case NORMAL_COMMAND:
+            CommandsElement::index_normal(OUT, I, cg_pack, cie->command_headword, LD);
+            break;
+        case ALIAS_COMMAND:
+            CommandsElement::index_alias(OUT, I, cg_pack, cie->command_headword, LD);
+            break;
+        case OUT_OF_WORLD_COMMAND:
+            HTML::begin_colour(OUT, I"800000");
+            WRITE("&quot;%S&quot;, <i>", cie->command_headword);
+            Localisation::write_0(OUT, LD, I"Index.Elements.Cm.Command");
+            WRITE("</i>");
+            HTML::end_colour(OUT);
+            HTML_TAG("br");
+            break;
+        case TESTING_COMMAND:
+            HTML::begin_colour(OUT, I"800000");
+            WRITE("&quot;%S&quot;, <i>", cie->command_headword);
+            Localisation::write_0(OUT, LD, I"Index.Elements.Cm.TestingCommand");
+            WRITE("</i>");
+            HTML::end_colour(OUT);
+            HTML_TAG("br");
+            break;
+        case BARE_DIRECTION_COMMAND:
+            WRITE("&quot;[direction]&quot; - <i>");
+            Localisation::write_0(OUT, LD, I"Index.Elements.Cm.DirectionCommand");
+            WRITE("</i>");
+            HTML_TAG("br");
+            break;
     }
+
+ +

§2. Indexing grammar lines.

+ +
+void CommandsElement::index_normal(OUTPUT_STREAM, inter_tree *I, inter_package *cg_pack,
+    text_stream *headword, localisation_dictionary *LD) {
+    inter_package *entry;
+    LOOP_THROUGH_SUBPACKAGES(entry, cg_pack, I"_cg_line")
+        CommandsElement::index_grammar_line(OUT, entry, headword, LD);
 }
 
-void CommandsElement::cgl_index_normal(OUTPUT_STREAM, inter_package *cgl, text_stream *headword) {
+void CommandsElement::index_alias(OUTPUT_STREAM, inter_tree *I, inter_package *cg_pack,
+    text_stream *headword, localisation_dictionary *LD) {
+    WRITE("&quot;%S&quot;, <i>", headword);
+    Localisation::write_0(OUT, LD, I"Index.Elements.Cm.Alias");
+    WRITE("</i> &quot;%S&quot;", Metadata::read_textual(cg_pack, I"^command"));
+    IndexUtilities::link_package(OUT, cg_pack);
+    HTML_TAG("br");
+}
+
+void CommandsElement::index_grammar_line(OUTPUT_STREAM, inter_package *cgl,
+    text_stream *headword, localisation_dictionary *LD) {
     inter_symbol *an_s = Metadata::read_optional_symbol(cgl, I"^action");
     if (an_s == NULL) return;
     inter_package *an = Inter::Packages::container(an_s->definition);
     int oow = (int) Metadata::read_optional_numeric(an, I"^out_of_world");
-    if (Str::len(headword) > 0) IndexUtilities::anchor(OUT, headword);
+    if (Str::len(headword) > 0) IndexUtilities::anchor(OUT, headword);
     if (oow) HTML::begin_colour(OUT, I"800000");
     WRITE("&quot;");
     TokensElement::verb_definition(OUT, Metadata::read_optional_textual(cgl, I"^text"),
         headword, EMPTY_WORDING);
     WRITE("&quot;");
-    int at = (int) Metadata::read_optional_numeric(cgl, I"^at");
-    if (at > 0) IndexUtilities::link(OUT, at);
+    IndexUtilities::link_package(OUT, cgl);
 
     WRITE(" - <i>%S", Metadata::read_textual(an, I"^name"));
-    IndexUtilities::detail_link(OUT, "A", (int) Metadata::read_numeric(an, I"action_id"), TRUE);
-    if (Metadata::read_optional_numeric(cgl, I"^reversed"))
-        WRITE(" <i>reversed</i>");
+    IndexUtilities::detail_link(OUT, "A",
+        (int) Metadata::read_numeric(an, I"action_id"), TRUE);
+    if (Metadata::read_optional_numeric(cgl, I"^reversed")) {
+        WRITE(" <i>");
+        Localisation::write_0(OUT, LD, I"Index.Elements.Cm.Reversed");
+        WRITE("</i>");
+    }
     WRITE("</i>");
     if (oow) HTML::end_colour(OUT);
     HTML_TAG("br");
 }
-
-void CommandsElement::index_alias(OUTPUT_STREAM, inter_tree *I, inter_package *cg, text_stream *headword) {
-    WRITE("&quot;%S&quot;, <i>same as</i> &quot;%S&quot;",
-        headword, Metadata::read_textual(cg, I"^command"));
-    int at = (int) Metadata::read_optional_numeric(cg, I"^at");
-    if (at > 0) IndexUtilities::link(OUT, at);
-    HTML_TAG("br");
-}
 

§1.1. Show the virtual machine compiled for1.1 =

-    IndexUtilities::anchor(OUT, I"STORYFILE");
+    IndexUtilities::anchor(OUT, I"STORYFILE");
     HTML_OPEN("p"); WRITE("Story file format: ");
     inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/basics");
     text_stream *VM = Metadata::read_optional_textual(pack, I"^virtual_machine");
@@ -174,27 +174,21 @@ function togglePopup(material_id) {
     WRITE("Debugging log:");
     HTML_CLOSE("p");
     HTML_OPEN("p");
-    inter_symbol *wanted = PackageTypes::get(I, I"_debugging_aspect");
     inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/basics");
-    inter_tree_node *D = Inter::Packages::definition(pack);
-    LOOP_THROUGH_INTER_CHILDREN(C, D) {
-        if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-            inter_package *entry = Inter::Package::defined_by_frame(C);
-            if (Inter::Packages::type(entry) == wanted) {
-                TEMPORARY_TEXT(is)
-                WRITE_TO(is, "Include %S in the debugging log.",
-                    Metadata::read_textual(entry, I"^name"));
-                PasteButtons::paste_text(OUT, is);
-                WRITE("&nbsp;%S&nbsp;", is);
-                DISCARD_TEXT(is)
-                if (Metadata::read_optional_numeric(entry, I"^used")) {
-                    HTML_TAG_WITH("img", "border=0 src=inform:/doc_images/tick.png");
-                } else {
-                    HTML_TAG_WITH("img", "border=0 src=inform:/doc_images/cross.png");
-                }
-                HTML_TAG("br");
-            }
+    inter_package *aspect_pack;
+    LOOP_THROUGH_SUBPACKAGES(aspect_pack, pack, I"_debugging_aspect") {
+        TEMPORARY_TEXT(is)
+        WRITE_TO(is, "Include %S in the debugging log.",
+            Metadata::read_textual(aspect_pack, I"^name"));
+        PasteButtons::paste_text(OUT, is);
+        WRITE("&nbsp;%S&nbsp;", is);
+        DISCARD_TEXT(is)
+        if (Metadata::read_optional_numeric(aspect_pack, I"^used")) {
+            HTML_TAG_WITH("img", "border=0 src=inform:/doc_images/tick.png");
+        } else {
+            HTML_TAG_WITH("img", "border=0 src=inform:/doc_images/cross.png");
         }
+        HTML_TAG("br");
     }
     HTML_CLOSE("p");
 
diff --git a/docs/index-module/3-le.html b/docs/index-module/3-le.html index 9b7a15df5..f45bab8e5 100644 --- a/docs/index-module/3-le.html +++ b/docs/index-module/3-le.html @@ -76,7 +76,7 @@ function togglePopup(material_id) {
 void LexiconElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
-    IndexUtilities::anchor(OUT, I"LEXICON");
+    IndexUtilities::anchor(OUT, I"LEXICON");
     HTML_OPEN("p");
     HTML_OPEN_WITH("span", "class=\"smaller\"");
     WRITE("For instance, the description 'an unlocked door' is made "
diff --git a/docs/index-module/3-me.html b/docs/index-module/3-me.html
index 95c84921f..b7861f40e 100644
--- a/docs/index-module/3-me.html
+++ b/docs/index-module/3-me.html
@@ -89,7 +89,7 @@ function togglePopup(material_id) {
         PL::HTMLMap::add_region_key(OUT);
         MapElement::index_backdrop_further(OUT, NULL, 0, FALSE, 1);
 
-        IndexUtilities::anchor(OUT, I"MDETAILS");
+        IndexUtilities::anchor(OUT, I"MDETAILS");
         int unruly = FALSE;
         Mark parts, directions and kinds as ineligible for listing in the World index1.1;
         Give room details within each region in turn in the World index1.2;
@@ -216,19 +216,19 @@ will be things which are offstage (and their contents and any parts thereof):
     Begin the object citation line2.1;
     int xtra = -1;
     if (I) xtra = xtras_count++;
-    if (xtra >= 0) IndexUtilities::extra_link(OUT, xtra);
+    if (xtra >= 0) IndexUtilities::extra_link(OUT, xtra);
     Index the name part of the object citation2.3;
     if (I) Index the kind attribution part of the object citation2.4;
     Index the link icons part of the object citation2.5;
     End the object citation line2.2;
     if (details) Add a subsidiary paragraph of details about this object2.7;
     if (xtra >= 0) {
-        IndexUtilities::extra_div_open(OUT, xtra, depth+1, "e0e0e0");
+        IndexUtilities::extra_div_open(OUT, xtra, depth+1, "e0e0e0");
         Add the chain of kinds2.8;
         Add the catalogue of specific properties2.9;
         Add details depending on the kind2.10;
         MapElement::index_usages(OUT, I);
-        IndexUtilities::extra_div_close(OUT, "e0e0e0");
+        IndexUtilities::extra_div_close(OUT, "e0e0e0");
     }
     Recurse the index citation for the object as necessary2.6;
 }
@@ -239,7 +239,7 @@ will be things which are offstage (and their contents and any parts thereof):
 
     if (details) {
         HTML::open_indented_p(OUT, depth, "halftight");
-        if (I != indexing_room) IndexUtilities::anchor(OUT, I->anchor_text);
+        if (I != indexing_room) IndexUtilities::anchor(OUT, I->anchor_text);
     } else {
         #ifdef IF_MODULE
         if (I) MapElement::index_spatial_relationship(OUT, I);
diff --git a/docs/index-module/3-pe.html b/docs/index-module/3-pe.html
index db6b1a760..2476d2084 100644
--- a/docs/index-module/3-pe.html
+++ b/docs/index-module/3-pe.html
@@ -78,51 +78,34 @@ function togglePopup(material_id) {
 void PhrasebookElement::render(OUTPUT_STREAM, localisation_dictionary *LD) {
     inter_tree *I = InterpretIndex::get_tree();
     inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/phrases");
-    inter_symbol *wanted = PackageTypes::get(I, I"_phrasebook_super_heading");
-    inter_tree_node *D = Inter::Packages::definition(pack);
     for (int pass = 1; pass <= 2; pass++) {
         int grand_c = 0;
-        LOOP_THROUGH_INTER_CHILDREN(C, D) {
-            if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-                inter_package *entry = Inter::Package::defined_by_frame(C);
-                if (Inter::Packages::type(entry) == wanted) {
-                    if (pass == 2) HTML_TAG("hr");
-                    HTML_OPEN_WITH("p", "class=\"in1\"");
-                    WRITE("<b>%S</b>", Metadata::read_textual(entry, I"^text"));
+        inter_package *sh_pack;
+        LOOP_THROUGH_SUBPACKAGES(sh_pack, pack, I"_phrasebook_super_heading") {
+            if (pass == 2) HTML_TAG("hr");
+            HTML_OPEN_WITH("p", "class=\"in1\"");
+            WRITE("<b>%S</b>", Metadata::read_textual(sh_pack, I"^text"));
+            HTML_CLOSE("p");
+            int c = 0;
+            inter_package *h_pack;
+            LOOP_THROUGH_SUBPACKAGES(h_pack, sh_pack, I"_phrasebook_heading") {
+                c++; grand_c++;
+                if ((pass == 1) && (c > 1)) WRITE(", ");
+                if (pass == 2) {
+                    IndexUtilities::anchor_numbered(OUT, grand_c);
+                    HTML_OPEN_WITH("p", "class=\"in2\"");
+                    WRITE("<b>");
+                }
+                WRITE("%S", Metadata::read_textual(h_pack, I"^text"));
+                if (pass == 1) IndexUtilities::below_link_numbered(OUT, grand_c);
+                if (pass == 2) {
+                    WRITE("</b>");
                     HTML_CLOSE("p");
-                    int c = 0;
-                    inter_symbol *wanted_b = PackageTypes::get(I, I"_phrasebook_heading");
-                    LOOP_THROUGH_INTER_CHILDREN(B, C) {
-                        if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-                            inter_package *entry_b = Inter::Package::defined_by_frame(B);
-                            if (Inter::Packages::type(entry_b) == wanted_b) {
-                                c++; grand_c++;
-                                if ((pass == 1) && (c > 1)) WRITE(", ");
-                                if (pass == 2) {
-                                    IndexUtilities::anchor_numbered(OUT, grand_c);
-                                    HTML_OPEN_WITH("p", "class=\"in2\"");
-                                    WRITE("<b>");
-                                }
-                                WRITE("%S", Metadata::read_textual(entry_b, I"^text"));
-                                if (pass == 1) IndexUtilities::below_link_numbered(OUT, grand_c);
-                                if (pass == 2) {
-                                    WRITE("</b>");
-                                    HTML_CLOSE("p");
-                                }
-                                if (pass == 2) {
-                                    inter_symbol *wanted_c = PackageTypes::get(I, I"_phrasebook_entry");
-                                    LOOP_THROUGH_INTER_CHILDREN(A, B) {
-                                        if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-                                            inter_package *entry_c = Inter::Package::defined_by_frame(A);
-                                            if (Inter::Packages::type(entry_c) == wanted_c) {
-                                                WRITE("%S", Metadata::read_textual(entry_c, I"^text"));
-                                            }
-                                        }
-                                    }
-                                }
-                            }
-                        }
-                    }
+                }
+                if (pass == 2) {
+                    inter_package *entry_pack;
+                    LOOP_THROUGH_SUBPACKAGES(entry_pack, h_pack, I"_phrasebook_entry")
+                        WRITE("%S", Metadata::read_textual(entry_pack, I"^text"));
                 }
             }
         }
diff --git a/docs/index-module/3-pe2.html b/docs/index-module/3-pe2.html
index 462fb19aa..657e086af 100644
--- a/docs/index-module/3-pe2.html
+++ b/docs/index-module/3-pe2.html
@@ -111,38 +111,27 @@ seems natural enough to learn in practice.
     ssc->pack = sc_pack;
     ssc->no_ends = 0;
     ssc->indexed_already = FALSE;
-    inter_symbol *wanted = PackageTypes::get(I, I"_scene_end");
-    inter_symbol *wanted_within = PackageTypes::get(I, I"_scene_connector");
-    inter_tree_node *D = Inter::Packages::definition(sc_pack);
-    LOOP_THROUGH_INTER_CHILDREN(C, D) {
-        if (C->W.data[ID_IFLD] == PACKAGE_IST) {
-            inter_package *entry = Inter::Package::defined_by_frame(C);
-            if (Inter::Packages::type(entry) == wanted) {
-                simplified_end *se = CREATE(simplified_end);
-                se->end_pack = entry;
-                se->anchor_connectors = NULL;
-                LOOP_THROUGH_INTER_CHILDREN(B, C) {
-                    if (B->W.data[ID_IFLD] == PACKAGE_IST) {
-                        inter_package *inner_entry = Inter::Package::defined_by_frame(B);
-                        if (Inter::Packages::type(inner_entry) == wanted_within) {
-                            simplified_connector *scon = CREATE(simplified_connector);
-                            scon->con_pack = inner_entry;
-                            scon->next = NULL;
-                            if (se->anchor_connectors == NULL) {
-                                se->anchor_connectors = scon;
-                            } else {
-                                simplified_connector *last = se->anchor_connectors;
-                                while ((last) && (last->next)) last = last->next;
-                                last->next = scon;
-                            }
-                            scon->connect_to = NULL;
-                        }
-                    }
-                }
-                if (ssc->no_ends >= MAX_SCENE_ENDS) internal_error("too many scene ends");
-                ssc->ends[ssc->no_ends++] = se;
+    inter_package *end_pack;
+    LOOP_THROUGH_SUBPACKAGES(end_pack, sc_pack, I"_scene_end") {
+        simplified_end *se = CREATE(simplified_end);
+        se->end_pack = end_pack;
+        se->anchor_connectors = NULL;
+        inter_package *con_pack;
+        LOOP_THROUGH_SUBPACKAGES(con_pack, end_pack, I"_scene_connector") {
+            simplified_connector *scon = CREATE(simplified_connector);
+            scon->con_pack = con_pack;
+            scon->next = NULL;
+            if (se->anchor_connectors == NULL) {
+                se->anchor_connectors = scon;
+            } else {
+                simplified_connector *last = se->anchor_connectors;
+                while ((last) && (last->next)) last = last->next;
+                last->next = scon;
             }
+            scon->connect_to = NULL;
         }
+        if (ssc->no_ends >= MAX_SCENE_ENDS) internal_error("too many scene ends");
+        ssc->ends[ssc->no_ends++] = se;
     }
     return ssc;
 }
@@ -295,7 +284,7 @@ about and created but never made use of.)
 

-    IndexUtilities::anchor(OUT, I"SDETAILS");
+    IndexUtilities::anchor(OUT, I"SDETAILS");
     simplified_scene *ssc;
     LOOP_OVER(ssc, simplified_scene) {
         HTML_TAG("hr");
@@ -331,10 +320,9 @@ fact, end.
 
 
     HTML::open_indented_p(OUT, 1, "hanging");
-    IndexUtilities::anchor_numbered(OUT, ssc->allocation_id);
+    IndexUtilities::anchor_numbered(OUT, ssc->allocation_id);
     WRITE("<b>The <i>%S</i> scene</b>", Metadata::read_textual(ssc->pack, I"^name"));
-    int at = (int) Metadata::read_optional_numeric(ssc->pack, I"^at");
-    if (at > 0) IndexUtilities::link(OUT, at);
+    IndexUtilities::link_package(OUT, ssc->pack);
     if (PlotElement::recurs(ssc)) WRITE("&nbsp;&nbsp;<i>recurring</i>");
     HTML_CLOSE("p");
 
@@ -506,7 +494,7 @@ on the initial call when dept if (ssc->indexed_already) WRITE("<i>"); WRITE("%S", Metadata::read_textual(ssc->pack, I"^name")); if (ssc->indexed_already) WRITE("</i>"); - else IndexUtilities::below_link_numbered(OUT, ssc->allocation_id); + else IndexUtilities::below_link_numbered(OUT, ssc->allocation_id);
  • This code is used in §2.

§2.3. Show the never-ends icon if appropriate2.3 = diff --git a/docs/index-module/3-re.html b/docs/index-module/3-re.html index 4dc5a1bd6..c9b42a0b2 100644 --- a/docs/index-module/3-re.html +++ b/docs/index-module/3-re.html @@ -95,8 +95,7 @@ function togglePopup(material_id) { if ((Str::len(type) == 0) || (Str::len(name) == 0)) continue; HTML::first_html_column(OUT, 0); WRITE("%S", name); - int at = (int) Metadata::read_optional_numeric(pack, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); + IndexUtilities::link_package(OUT, pack); HTML::next_html_column(OUT, 0); if (Str::len(type) > 0) WRITE("%S", type); else WRITE("--"); HTML::next_html_column(OUT, 0); diff --git a/docs/index-module/3-rfse.html b/docs/index-module/3-rfse.html index b462be63f..9e1b715a6 100644 --- a/docs/index-module/3-rfse.html +++ b/docs/index-module/3-rfse.html @@ -84,7 +84,7 @@ function togglePopup(material_id) { IndexRules::rulebook_box(OUT, inv, I"Scene changing", NULL, IndexRules::find_rulebook(inv, I"scene_changing"), NULL, 1, FALSE, LD); HTML_OPEN("p"); - IndexUtilities::anchor(OUT, I"SRULES"); + IndexUtilities::anchor(OUT, I"SRULES"); WRITE("<b>General rules applying to scene changes</b>"); HTML_CLOSE("p"); IndexRules::rulebook_box(OUT, inv, I"When a scene begins", NULL, diff --git a/docs/index-module/3-te.html b/docs/index-module/3-te.html index ba82665ec..b07806d8e 100644 --- a/docs/index-module/3-te.html +++ b/docs/index-module/3-te.html @@ -114,13 +114,13 @@ Rules, which of course are always present. So these are hidden by default. if (cat > 1) { if (first_ext) { HTML_OPEN("p"); - IndexUtilities::extra_link(OUT, 2); + IndexUtilities::extra_link(OUT, 2); if (mc > 1) WRITE("Show tables inside extensions too"); else WRITE("Show tables inside extensions (there are none in the main text)"); HTML_CLOSE("p"); first_ext = FALSE; } - IndexUtilities::extra_div_open(OUT, 2, 1, "e0e0e0"); + IndexUtilities::extra_div_open(OUT, 2, 1, "e0e0e0"); HTML_OPEN("p"); WRITE("<i>%S</i>", Metadata::read_textual(mod, I"^title")); HTML_CLOSE("p"); @@ -135,7 +135,7 @@ Rules, which of course are always present. So these are hidden by default.

     if (mc > 0) {
         HTML::end_html_table(OUT);
-        if (open_cat > 1) IndexUtilities::extra_div_close(OUT, "e0e0e0");
+        if (open_cat > 1) IndexUtilities::extra_div_close(OUT, "e0e0e0");
     }
 
  • This code is used in §1 (twice).
@@ -156,8 +156,7 @@ Helvetica-style lower case "x", but life is full of compromises. inter_package *entry = Inter::Package::defined_by_frame(C); if (Inter::Packages::type(entry) == PackageTypes::get(I, I"_table_contribution")) { if (ntc++ > 0) WRITE(" +"); - int at = (int) Metadata::read_optional_numeric(entry, I"^at"); - IndexUtilities::link(OUT, at); + IndexUtilities::link_package(OUT, entry); } } } diff --git a/docs/index-module/3-te2.html b/docs/index-module/3-te2.html index 8d9c56f4f..dada149c9 100644 --- a/docs/index-module/3-te2.html +++ b/docs/index-module/3-te2.html @@ -101,16 +101,10 @@ function togglePopup(material_id) { TokensElement::index_tokens_for(OUT, I, "things inside", NULL, I"things_token", NULL); TokensElement::index_tokens_for(OUT, I, "things preferably held", NULL, I"things_token", NULL); inter_package *pack = Inter::Packages::by_url(I, I"/main/completion/grammar"); - inter_symbol *wanted = PackageTypes::get(I, I"_command_grammar"); - inter_tree_node *D = Inter::Packages::definition(pack); - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - if (Metadata::read_optional_numeric(entry, I"^is_token")) - TokensElement::index_tokens_for(OUT, I, NULL, entry, NULL, NULL); - } - } + inter_package *cg_pack; + LOOP_THROUGH_SUBPACKAGES(cg_pack, pack, I"_command_grammar") { + if (Metadata::read_optional_numeric(cg_pack, I"^is_token")) + TokensElement::index_tokens_for(OUT, I, NULL, cg_pack, NULL, NULL); } } @@ -121,10 +115,7 @@ function togglePopup(material_id) { if (special) WRITE("%s", special); else if (defns) WRITE("%S", Metadata::read_optional_textual(defns, I"^name")); WRITE("]\""); - if (defns) { - int at = (int) Metadata::read_optional_numeric(defns, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); - } + if (defns) IndexUtilities::link_package(OUT, defns); if (Str::len(help) > 0) IndexUtilities::DocReferences::link(OUT, help); if (explanation) WRITE(" - %s", explanation); HTML_CLOSE("p"); @@ -132,32 +123,25 @@ function togglePopup(material_id) { } void TokensElement::index_list_for_token(OUTPUT_STREAM, inter_tree *I, inter_package *cg) { - inter_symbol *wanted = PackageTypes::get(I, I"_cg_line"); - inter_tree_node *D = Inter::Packages::definition(cg); int k = 0; - LOOP_THROUGH_INTER_CHILDREN(C, D) { - if (C->W.data[ID_IFLD] == PACKAGE_IST) { - inter_package *entry = Inter::Package::defined_by_frame(C); - if (Inter::Packages::type(entry) == wanted) { - text_stream *trueverb = Metadata::read_optional_textual(entry, I"^true_verb"); - HTML::open_indented_p(OUT, 2, "hanging"); - if (k++ == 0) WRITE("="); else WRITE("or"); - WRITE(" &quot;"); - TokensElement::verb_definition(OUT, - Metadata::read_optional_textual(entry, I"^text"), - trueverb, EMPTY_WORDING); - WRITE("&quot;"); - int at = (int) Metadata::read_optional_numeric(entry, I"^at"); - if (at > 0) IndexUtilities::link(OUT, at); - if (Metadata::read_optional_numeric(entry, I"^reversed")) - WRITE(" <i>reversed</i>"); - HTML_CLOSE("p"); - } - } + inter_package *line_pack; + LOOP_THROUGH_SUBPACKAGES(line_pack, cg, I"_cg_line") { + text_stream *trueverb = Metadata::read_optional_textual(line_pack, I"^true_verb"); + HTML::open_indented_p(OUT, 2, "hanging"); + if (k++ == 0) WRITE("="); else WRITE("or"); + WRITE(" &quot;"); + TokensElement::verb_definition(OUT, + Metadata::read_optional_textual(line_pack, I"^text"), + trueverb, EMPTY_WORDING); + WRITE("&quot;"); + IndexUtilities::link_package(OUT, line_pack); + if (Metadata::read_optional_numeric(line_pack, I"^reversed")) + WRITE(" <i>reversed</i>"); + HTML_CLOSE("p"); } } -void TokensElement::verb_definition(OUTPUT_STREAM, text_stream *T, text_stream *trueverb, wording W) { +void TokensElement::verb_definition(OUTPUT_STREAM, text_stream *T, text_stream *trueverb, wording W) { int i = 1; if (Str::len(T) < 2) return; if (Str::len(trueverb) > 0) { diff --git a/docs/index-module/3-ve.html b/docs/index-module/3-ve.html index f57df42d0..084761d9b 100644 --- a/docs/index-module/3-ve.html +++ b/docs/index-module/3-ve.html @@ -91,7 +91,7 @@ function togglePopup(material_id) {
     inter_symbol *definition_area = NULL, *current_area = NULL;
     HTML_OPEN("p");
-    IndexUtilities::anchor(OUT, I"NAMES");
+    IndexUtilities::anchor(OUT, I"NAMES");
     int understood_note_given = FALSE;
     for (int i=0; i<TreeLists::len(inv->variable_nodes); i++) {
         inter_package *pack = Inter::Package::defined_by_frame(inv->variable_nodes->list[i].node);
@@ -126,16 +126,14 @@ function togglePopup(material_id) {
         inter_package *heading_pack = Inter::Packages::container(definition_area->definition);
         HTML_CLOSE("p");
         HTML_OPEN("p");
-        IndexUtilities::show_definition_area(OUT, heading_pack, FALSE);
+        IndexUtilities::show_definition_area(OUT, heading_pack, FALSE);
     }
     current_area = definition_area;
 
     text_stream *name = Metadata::read_optional_textual(pack, I"^name");
     WRITE("%S", name);
-    int at = (int) Metadata::read_optional_numeric(pack, I"^at");
-    if (at > 0) IndexUtilities::link(OUT, at);
-    text_stream *doc = Metadata::read_optional_textual(pack, I"^documentation");
-    if (Str::len(doc) > 0) IndexUtilities::DocReferences::link(OUT, doc);
+    IndexUtilities::link_package(OUT, pack);
+    IndexUtilities::link_to_documentation(OUT, pack);
     text_stream *contents = Metadata::read_optional_textual(pack, I"^contents");
     WRITE(" - <i>%S</i>", contents);
     HTML_TAG("br");
diff --git a/docs/index-module/3-ve2.html b/docs/index-module/3-ve2.html
index f5fcf83b0..b4e3641e7 100644
--- a/docs/index-module/3-ve2.html
+++ b/docs/index-module/3-ve2.html
@@ -88,13 +88,12 @@ function togglePopup(material_id) {
             (lex->part_of_speech == PREP_TLEXE)) {
             text_stream *entry_text = lex->lemma;
             HTML_OPEN_WITH("p", "class=\"hang\"");
-            IndexUtilities::anchor_numbered(OUT, 10000+verb_count++);  anchors from 10000: see above
+            IndexUtilities::anchor_numbered(OUT, 10000+verb_count++);  anchors from 10000: see above
             if (lex->part_of_speech == VERB_TLEXE) WRITE("To <b>%S</b>", entry_text);
             else if (lex->part_of_speech == MVERB_TLEXE) WRITE("To <b>%S</b>", entry_text);
             else if (lex->part_of_speech == PREP_TLEXE) WRITE("To be <b>%S</b>", entry_text);
             else WRITE("To be able to <b>%S</b>", entry_text);
-            int at = (int) Metadata::read_optional_numeric(lex->lex_package, I"^at");
-            if (at > 0) IndexUtilities::link(OUT, at);
+            IndexUtilities::link_package(OUT, lex->lex_package);
             if (lex->part_of_speech == MVERB_TLEXE) WRITE(" ... for saying only");
             else WRITE(" ... <i>%S</i>", Metadata::read_optional_textual(lex->lex_package, I"^meaning"));
             HTML_CLOSE("p");
diff --git a/docs/index-module/4-rhm.html b/docs/index-module/4-rhm.html
index e641fc7bb..7bfa38686 100644
--- a/docs/index-module/4-rhm.html
+++ b/docs/index-module/4-rhm.html
@@ -745,7 +745,7 @@ that the grids are calculated, the region colours decided, and so on.
 void PL::HTMLMap::render_single_room_as_HTML(OUTPUT_STREAM, faux_instance *R) {
     WRITE("\n\n");
     HTML_OPEN("p");
-    IndexUtilities::anchor(OUT, R->anchor_text);
+    IndexUtilities::anchor(OUT, R->anchor_text);
     HTML_TAG_WITH("a", "name=wo_%d", R->allocation_id);
     HTML::begin_plain_html_table(OUT);
     HTML::first_html_column(OUT, 0);
diff --git a/inform7/Figures/memory-diagnostics.txt b/inform7/Figures/memory-diagnostics.txt
index c9b0807e7..a5965833d 100644
--- a/inform7/Figures/memory-diagnostics.txt
+++ b/inform7/Figures/memory-diagnostics.txt
@@ -1,4 +1,4 @@
-Total memory consumption was 391661K = 382 MB
+Total memory consumption was 391667K = 382 MB
 
 60.4% was used for 1994926 objects, in 371045 frames in 296 x 800K = 236800K = 231 MB:
 
@@ -236,7 +236,7 @@ Total memory consumption was 391661K = 382 MB
 
 39.5% was used for memory not allocated for objects:
 
-    20.6%  text stream storage                      82735296 bytes in 530462 claims
+    20.6%  text stream storage                      82741540 bytes in 530498 claims
      4.5%  dictionary storage                       18153472 bytes in 33229 claims
      ----  sorting                                  744 bytes in 3 claims
      1.7%  source text                              7200000 bytes in 3 claims
diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt
index c6042ba8a..674c4e4ac 100644
--- a/inform7/Figures/timings-diagnostics.txt
+++ b/inform7/Figures/timings-diagnostics.txt
@@ -1,9 +1,9 @@
 100.0% in inform7 run
      55.6% in compilation to Inter
          39.8% in //Sequence::undertake_queued_tasks//
-          3.6% in //MajorNodes::pre_pass//
+          3.5% in //MajorNodes::pre_pass//
           2.6% in //MajorNodes::pass_1//
-          2.1% in //RTPhrasebook::compile_entries//
+          2.0% in //RTPhrasebook::compile_entries//
           1.4% in //ImperativeDefinitions::assess_all//
           1.1% in //RTKindConstructors::compile//
           0.4% in //ImperativeDefinitions::compile_first_block//
@@ -18,11 +18,11 @@
           0.1% in //World::stages_II_and_III//
           1.7% not specifically accounted for
      42.2% in running Inter pipeline
-         11.0% in step preparation
-         10.0% in inter step 7/14: consolidate-text
-          8.2% in inter step 2/14: link
-          7.1% in inter step 14/14: generate inform6 -> auto.inf
-          1.5% in inter step 10/14: make-identifiers-unique
+         11.2% in step preparation
+          9.8% in inter step 7/14: consolidate-text
+          8.1% in inter step 2/14: link
+          7.2% in inter step 14/14: generate inform6 -> auto.inf
+          1.6% in inter step 10/14: make-identifiers-unique
           0.4% in inter step 11/14: reconcile-verbs
           0.2% in inter step 13/14: eliminate-redundant-operations
           0.2% in inter step 6/14: assimilate
diff --git a/inform7/Internal/Languages/English/Index.txt b/inform7/Internal/Languages/English/Index.txt
index 9e6427a4d..c62ef1828 100644
--- a/inform7/Internal/Languages/English/Index.txt
+++ b/inform7/Internal/Languages/English/Index.txt
@@ -44,6 +44,13 @@
 %Index.Elements.Cm.Title = Commands
 %Index.Elements.Cm.Heading = Commands which the player can type|About commands
 
+%Index.Elements.Cm.Command = a command for controlling play
+%Index.Elements.Cm.TestingCommand = a testing command not available in the final game
+%Index.Elements.Cm.DirectionCommand = going
+
+%Index.Elements.Cm.Alias = same as
+%Index.Elements.Cm.Reversed = reversed
+
 %Index.Elements.To.Title = Tokens
 %Index.Elements.To.Heading = Those square-bracketed pieces inside Understand grammar|About tokens; New tokens
 
@@ -53,6 +60,54 @@
 %Index.Elements.Ch.Title = Chart
 %Index.Elements.Ch.Heading = A chart of all the kinds|About kinds; New kinds of object; Other new kinds
 
+%Index.Elements.Ch.BasicKinds = basic kinds
+%Index.Elements.Ch.NewKinds = making new kinds from old
+%Index.Elements.Ch.Plural = plural
+
+%Index.Elements.Ch.DefaultColumn = default value
+%Index.Elements.Ch.RepeatColumn = repeat
+%Index.Elements.Ch.PropsColumn = props
+%Index.Elements.Ch.UnderColumn = under
+
+%Index.Elements.Ch.DefaultGloss = 
+	The default value is used when we make something like 
+	a variable but don't tell Inform what its value is. For instance, if 
+	we write 'Zero hour is a time that varies', but don't tell Inform 
+	anything specific like 'Zero hour is 11:21 PM.', then Inform uses 
+	the value in the table above to decide what it will be. 
+	The same applies if we create a property (for instance, 'A person 
+	has a number called lucky number.'). Kinds of value not included 
+	in the table cannot be used in variables and properties.
+%Index.Elements.Ch.RepeatGloss = 
+	A tick for repeat means that it's possible to 
+	repeat through values of this kind. For instance, 'repeat with T 
+	running through times:' is allowed, but 'repeat with N running 
+	through numbers:' is not - there are too many numbers for this to 
+	make sense. A tick here also means it's possible to form lists such 
+	as 'list of rulebooks', or to count the 'number of scenes'.
+%Index.Elements.Ch.PropsGloss = 
+	A tick for props means that values of this 
+	kind can have properties. For instance, 'A scene can be thrilling or 
+	dull.' makes an either/or property of a scene, but 'A number can be 
+	nice or nasty.' is not allowed because it would cost too much storage 
+	space. (Of course 'Definition:' can always be used to make adjectives 
+	applying to numbers; it's only properties which have storage 
+	worries.)
+%Index.Elements.Ch.UnderGloss = 
+	A tick for under means that it's possible 
+	to understand values of this kind. For instance, 'Understand "award 
+	[number]" as awarding.' might be allowed, if awarding were an action 
+	applying to a number, but 'Understand "run [rule]" as rule-running.' 
+	is not allowed - there are so many rules with such long names that 
+	Inform doesn't add them to its vocabulary during play.
+%Index.Elements.Ch.CovarianceGloss =
+	Covariance means that if K is a kind of L, then something
+	you make from K can be used as the same thing made from L. For example,
+	a list of doors can be used as a list of things, because 'list of K' is
+	covariant. Contravariance means it works the other way round.
+	For example, an activity on things can be used as an activity on doors,
+	but not vice versa, because 'activity of K' is contravariant.
+
 %Index.Elements.Ar.Title = Arithmetic
 %Index.Elements.Ar.Heading = Which values can be added up, multiplied and so on|About arithmetic
 
diff --git a/inform7/Tests/Test Internals/_Results_Ideal/Index-Chart.txt b/inform7/Tests/Test Internals/_Results_Ideal/Index-Chart.txt
index e2ac68d70..175dc3dfc 100644
--- a/inform7/Tests/Test Internals/_Results_Ideal/Index-Chart.txt	
+++ b/inform7/Tests/Test Internals/_Results_Ideal/Index-Chart.txt	
@@ -1,5 +1,4 @@
 1. Ch
-

@@ -1028,8 +1050,8 @@ and southwest, for instance; down and up.
Usually unmarked for listing not marked for listing.
Can have opposite (direction).

-

 12 directions

-
@@ -30,25 +29,48 @@
@@ -1119,8 +1141,8 @@ Like a scene in a play: a period of time which is usually tied to events in the

command parser error (plural command parser errors)

Matches: value, sayable value, understandable value, enumerated value
-

 25 command parser errors

-