diff --git a/README.md b/README.md index cc1c5e31a..3e5c775d7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Inform 7 -v10.1.0-alpha.1+6R54 'Krypton' (18 March 2021) +v10.1.0-alpha.1+6R55 'Krypton' (19 March 2021) ## About Inform 7 diff --git a/build.txt b/build.txt index 681c2d724..4b30cfa5b 100644 --- a/build.txt +++ b/build.txt @@ -1,3 +1,3 @@ Prerelease: alpha.1 -Build Date: 18 March 2021 -Build Number: 6R54 +Build Date: 19 March 2021 +Build Number: 6R55 diff --git a/docs/if-module/1-im.html b/docs/if-module/1-im.html index 710070e22..069c75984 100644 --- a/docs/if-module/1-im.html +++ b/docs/if-module/1-im.html @@ -86,7 +86,7 @@ function togglePopup(material_id) { COMPILE_WRITER(action_pattern *, ActionPatterns::log) COMPILE_WRITER(command_grammar *, CommandGrammars::log) COMPILE_WRITER(cg_line *, CGLines::log) -COMPILE_WRITER(cg_token *, CGTokens::log) +COMPILE_WRITER(cg_token *, CGTokens::log) COMPILE_WRITER(action_name_list *, ActionNameLists::log) COMPILE_WRITER(anl_entry *, ActionNameLists::log_entry) COMPILE_WRITER(action_name *, ActionNameNames::log) @@ -133,7 +133,7 @@ function togglePopup(material_id) {
     REGISTER_WRITER('A', ActionPatterns::log);
-    REGISTER_WRITER('c', CGTokens::log);
+    REGISTER_WRITER('c', CGTokens::log);
     REGISTER_WRITER('G', CommandGrammars::log);
     REGISTER_WRITER('g', CGLines::log);
     REGISTER_WRITER('L', ActionNameLists::log);
diff --git a/docs/if-module/4-act.html b/docs/if-module/4-act.html
index 835a82a16..0101d2c4f 100644
--- a/docs/if-module/4-act.html
+++ b/docs/if-module/4-act.html
@@ -100,7 +100,7 @@ kind K_action_name    CLASS_DEFINITION
 } action_name;
 
- +

§2. Note that we notify the K_action_name kind that a new enumerated value for it exists; we don't need to record the reply (i.e. the number used as this value at run-time) because it will be the same as the allocation ID diff --git a/docs/if-module/4-nap.html b/docs/if-module/4-nap.html index 5cfd84608..ee8bc333f 100644 --- a/docs/if-module/4-nap.html +++ b/docs/if-module/4-nap.html @@ -93,7 +93,7 @@ this category if it matches one of the patterns. CLASS_DEFINITION } named_action_pattern_entry; -

+

§2. We are allowed to give names to certain kinds of behaviour by "characterising" an action.

diff --git a/docs/if-module/5-cg.html b/docs/if-module/5-cg.html index 553fcd9e6..612fd4bb8 100644 --- a/docs/if-module/5-cg.html +++ b/docs/if-module/5-cg.html @@ -144,7 +144,7 @@ form, so this is not as bloated a structure as it looks. CLASS_DEFINITION } command_grammar; - +

§4. We begin as usual with a constructor and some debug log tracing.

@@ -447,7 +447,7 @@ different numbers, for example; the return cg; } -command_grammar *CommandGrammars::get_parsing_grammar(kind *K) { +command_grammar *CommandGrammars::get_parsing_grammar(kind *K) { if (K == NULL) return NULL; if (Kinds::Behaviour::is_object(K)) internal_error("cannot get CG for K_object"); return K->construct->understand_as_values; @@ -475,11 +475,11 @@ in which players consulted a biographical dictionary of the Meldrew family.
 command_grammar *consultation_gv = NULL;
 
-void CommandGrammars::prepare_consultation_cg(void) {
+void CommandGrammars::prepare_consultation_cg(void) {
     consultation_gv = NULL;
 }
 
-command_grammar *CommandGrammars::get_consultation_cg(void) {
+command_grammar *CommandGrammars::get_consultation_cg(void) {
     if (consultation_gv == NULL) consultation_gv = CommandGrammars::cg_new(CG_IS_CONSULT);
     return consultation_gv;
 }
@@ -491,7 +491,7 @@ property value used adjectivally like this can be given a CG.
 

-command_grammar *CommandGrammars::for_prn(property *prn) {
+command_grammar *CommandGrammars::for_prn(property *prn) {
     if (EitherOrProperties::get_parsing_grammar(prn) != NULL)
         return EitherOrProperties::get_parsing_grammar(prn);
     command_grammar *cg = CommandGrammars::cg_new(CG_IS_PROPERTY_NAME);
@@ -507,12 +507,12 @@ are not possible, but see CommandGramm
 

-int CommandGrammars::is_empty(command_grammar *cg) {
+int CommandGrammars::is_empty(command_grammar *cg) {
     if ((cg == NULL) || (cg->first_line == NULL)) return TRUE;
     return FALSE;
 }
 
-void CommandGrammars::add_line(command_grammar *cg, cg_line *cgl) {
+void CommandGrammars::add_line(command_grammar *cg, cg_line *cgl) {
     LOGIF(GRAMMAR, "$G + line: $g\n", cg, cgl);
     if ((cg->cg_is == CG_IS_COMMAND) &&
         (CGLines::list_length(cg) >= MAX_LINES_PER_GRAMMAR)) {
@@ -547,7 +547,7 @@ the buck down to Command Grammar Lines
 

-void CommandGrammars::prepare(void) {
+void CommandGrammars::prepare(void) {
     command_grammar *cg;
     Log::new_stage(I"Slashing command grammar");
     LOOP_OVER(cg, command_grammar)
@@ -575,7 +575,7 @@ recurses back here.
 

-parse_node *CommandGrammars::determine(command_grammar *cg, int depth) {
+parse_node *CommandGrammars::determine(command_grammar *cg, int depth) {
     current_sentence = cg->where_cg_created;
     If this CG produces a value we have determined already, return that21.1;
     If recursion went impossibly deep, the CG grammar must be ill-founded21.2;
@@ -703,7 +703,7 @@ sort once, so:
 }
 
diff --git a/docs/if-module/5-cgl.html b/docs/if-module/5-cgl.html index 18f780a52..0282a7b59 100644 --- a/docs/if-module/5-cgl.html +++ b/docs/if-module/5-cgl.html @@ -140,7 +140,7 @@ removing it from action. That's a feature only seen in lines for CLASS_DEFINITION } cg_line;
-
  • The structure cg_line is accessed in 4/ap, 4/act, 4/as, 4/nap, 5/us, 5/cg, 5/gpr and here.
+
  • The structure cg_line is accessed in 4/ap, 4/act, 4/as, 4/nap, 5/us, 5/cg and here.

§2.

@@ -377,10 +377,10 @@ detected by the following function:
     if ((cgl->tokens)
         && (cgl->tokens->next_token == NULL)
         && (cgl->tokens->slash_class == 0)
-        && (CGTokens::is_literal(cgl->tokens))
+        && (CGTokens::is_literal(cgl->tokens))
         && (cgl->pluralised == FALSE)
         && (CGLines::conditional(cgl) == FALSE))
-        return Wordings::first_wn(CGTokens::text(cgl->tokens));
+        return Wordings::first_wn(CGTokens::text(cgl->tokens));
     return -1;
 }
 
@@ -390,7 +390,7 @@ this purpose, so:

-void CGLines::slash(command_grammar *cg) {
+void CGLines::slash(command_grammar *cg) {
     LOOP_THROUGH_UNSORTED_CG_LINES(cgl, cg) {
         current_sentence = cgl->where_grammar_specified;
         Annotate the CG tokens with slash-class and slash-dash-dash15.1;
@@ -446,8 +446,9 @@ definition no effect, and disappears without trace in this process.
     int alternatives_group = 0;
     cg_token *class_start = NULL;
     LOOP_THROUGH_CG_TOKENS(cgt, cgl) {
-        if ((cgt->next_token) && (Wordings::length(CGTokens::text(cgt->next_token)) == 1) &&
-            (Lexer::word(Wordings::first_wn(CGTokens::text(cgt->next_token))) == FORWARDSLASH_V)) {
+        if ((cgt->next_token) && (Wordings::length(CGTokens::text(cgt->next_token)) == 1) &&
+            (Lexer::word(Wordings::first_wn(CGTokens::text(cgt->next_token))) ==
+                FORWARDSLASH_V)) {
             if (cgt->slash_class == 0) {
                 class_start = cgt; alternatives_group++;  start new equiv class
                 class_start->slash_dash_dash = FALSE;
@@ -456,12 +457,13 @@ definition no effect, and disappears without trace in this process.
             if (cgt->next_token->next_token)
                 cgt->next_token->next_token->slash_class = alternatives_group;
             if ((cgt->next_token->next_token) &&
-                (Wordings::length(CGTokens::text(cgt->next_token->next_token)) == 1) &&
-                (Lexer::word(Wordings::first_wn(CGTokens::text(cgt->next_token->next_token))) == DOUBLEDASH_V)) {
+                (Wordings::length(CGTokens::text(cgt->next_token->next_token)) == 1) &&
+                (Lexer::word(Wordings::first_wn(CGTokens::text(cgt->next_token->next_token))) ==
+                    DOUBLEDASH_V)) {
                 class_start->slash_dash_dash = TRUE;
-                cgt->next_token = cgt->next_token->next_token->next_token;  excise slash and dash-dash
+                cgt->next_token = cgt->next_token->next_token->next_token;  excise both
             } else {
-                cgt->next_token = cgt->next_token->next_token;  excise the slash from the token list
+                cgt->next_token = cgt->next_token->next_token;  excise slash
             }
         }
     }
@@ -473,7 +475,7 @@ definition no effect, and disappears without trace in this process.
 
     LOOP_THROUGH_CG_TOKENS(cgt, cgl)
         if ((cgt->slash_class > 0) &&
-            (CGTokens::is_literal(cgt) == FALSE)) {
+            (CGTokens::is_literal(cgt) == FALSE)) {
             StandardProblems::sentence_problem(Task::syntax_tree(),
                 _p_(PM_OverAmbitiousSlash),
                 "the slash '/' can only be used between single literal words",
@@ -564,9 +566,9 @@ affect how the list will be arranged when it is compiled.
 }
 

§16.1. The general sort bonus is \(Rs_0 + s_1\), where \(R\) is the CGL_SCORE_TOKEN_RANGE -and \(s_0\), \(s_1\) are the scores for the first and second tokens describing values; -or if none of the \(n\) tokens describes a value, it is \(R^2n\), which is guaranteed -to be larger. +and \(s_0\), \(s_1\) are the scores for the first and second tokens describing values, +which are such that \(0\leq s_i<R\); or if none of the \(n\) tokens describes a value, +the GSB is \(R^2n\), which is guaranteed to be much larger.

However, there is also an understanding sort bonus, which is really a penalty @@ -577,8 +579,9 @@ number, but is such that a "[text]" earlier in the line is penalised just a little bit more than a "[text]" later.

-

For \(R=10\), the following might thus happen. (For simplicity, I've assumed -the individual tokens scores are 1.) +

For \(R=10\), the following might thus happen. (I've simplified this table by +having the individual tokens all score 1, but in fact they can score a range +of small numbers: see CGTokens::score_bonus.)

@@ -600,22 +603,24 @@ parsing the player's command at run-time. For the exact sorting rules, see below
 
 
     int nulls_count = 0, pos = 0;
-    for (cg_token *cgtt = first; cgtt; cgtt = cgtt->next_token) {
-        int score = 0;
-        parse_node *spec = CGTokens::determine(cgtt, depth, &score);
+    for (cg_token *cgt = first; cgt; cgt = cgt->next_token) {
+        parse_node *spec = CGTokens::determine(cgt, depth);
+        int score = CGTokens::score_bonus(cgt);
+        if ((score < 0) || (score >= CGL_SCORE_TOKEN_RANGE))
+            internal_error("token score out of range");
         LOGIF(GRAMMAR_CONSTRUCTION, "token %d/%d: <%W> --> $P (score %d)\n",
-            pos+1, line_length, CGTokens::text(cgtt), spec, score);
+            pos+1, line_length, CGTokens::text(cgt), spec, score);
         if (spec) {
             Text tokens contribute also to the understanding sort bonus16.1.1;
             int score_multiplier = 1;
             if (DeterminationTypes::get_no_values_described(&(cgl->cgl_type)) == 0)
                 score_multiplier = CGL_SCORE_TOKEN_RANGE;
             DeterminationTypes::add_term(&(cgl->cgl_type), spec,
-                CGTokens::is_multiple(cgtt));
+                CGTokens::is_multiple(cgt));
             cgl->general_sort_bonus += score*score_multiplier;
         } else nulls_count++;
 
-        if (CGTokens::is_multiple(cgtt)) multiples++;
+        if (CGTokens::is_multiple(cgt)) multiples++;
         pos++;
     }
     if (nulls_count == line_length)
@@ -823,7 +828,7 @@ the specificity of the tokens is what decides. The first token is more important
 than the second, and a more specific token comes before a lower one.
 

-

See CGTokens::determine for how the score of an individual token +

See CGTokens::determine for how the score of an individual token is worked out.

@@ -893,7 +898,7 @@ TURN ON VISION ON would match both of the alternative CGLs.
  • This code is used in §19.
diff --git a/docs/if-module/5-cgt.html b/docs/if-module/5-cgt.html index d2e2168fd..31da1540b 100644 --- a/docs/if-module/5-cgt.html +++ b/docs/if-module/5-cgt.html @@ -73,48 +73,268 @@ function togglePopup(material_id) {

CGs are list of CG lines, which are lists of CG tokens.

-
+
-

§1.

+

§1. Introduction. Until 2021, CG tokens were held as parse nodes in the syntax tree, with a +special type TOKEN_NT and a set of annotations, but as cute as that was +it was also obfuscatory, and now each CG token corresponds to a cg_token +object as follows: +

 typedef struct cg_token {
     struct wording text_of_token;
-    int is_literal;
-    int slash_class;
-    int slash_dash_dash;
     int grammar_token_code;
-    struct parse_node *grammar_value;  0 or else one of the *_GTC values
+    struct parse_node *what_token_describes;  0 or else one of the *_GTC values
     struct binary_predicate *token_relation;
-    struct cg_token *next_token;
+    struct noun_filter_token *noun_filter;
+    struct command_grammar *defined_by;
+    int slash_class;  used in slashing: see CGLines::slash
+    int slash_dash_dash;  ditto
+    struct cg_token *next_token;  in the list for a CG line
     CLASS_DEFINITION
 } cg_token;
 
-wording CGTokens::text(cg_token *cgt) {
-    return cgt?(cgt->text_of_token):(EMPTY_WORDING);
+cg_token *CGTokens::cgt_of(wording W, int lit) {
+    cg_token *cgt = CREATE(cg_token);
+    cgt->text_of_token = W;
+    cgt->slash_dash_dash = FALSE;
+    cgt->slash_class = 0;
+    cgt->what_token_describes = NULL;
+    cgt->grammar_token_code = lit?LITERAL_GTC:0;
+    cgt->token_relation = NULL;
+    cgt->noun_filter = NULL;
+    cgt->defined_by = NULL;
+    cgt->next_token = NULL;
+    return cgt;
 }
 
  • The structure cg_token is accessed in 5/cgl and here.
-

§2. Tokens with a nonzero grammar_token_code correspond closely to what are -also called "tokens" in the runtime command parser. +

§2. Text to a CG token list. Tokens are created when text such as "drill [something] with [something]" +is parsed, from an Understand sentence or elsewhere. What happens is much +the same as when text with substitutions is read: the text is retokenised +by the lexer to produce the following, in which the square brackets have +become commas:

-
define NAMED_TOKEN_GTC 1  these positive values are used only in parsing
+
+"drill" , something , "with" , something
+
+

In fact we use a different punctuation set from the lexer's default, because +we want forward slashes to break words, so that we need / to be a punctuation +mark: thus "get away/off/out" becomes +

+ +
+"get" "away" / "off" / "out"
+
+
define GRAMMAR_PUNCTUATION_MARKS L".,:;?!(){}[]/"  note the slash
+
+
+cg_token *CGTokens::tokenise(wording W) {
+    wchar_t *as_wide_string = Lexer::word_text(Wordings::first_wn(W));
+    Reject this if it contains punctuation2.1;
+    wording TW = Feeds::feed_C_string_full(as_wide_string, TRUE,
+        GRAMMAR_PUNCTUATION_MARKS);
+    Reject this if it contains two consecutive commas2.2;
+
+    cg_token *tokens = CGTokens::break_into_tokens(TW);
+    if (tokens == NULL) {
+        StandardProblems::sentence_problem(Task::syntax_tree(),
+            _p_(PM_UnderstandEmptyText),
+            "'understand' should be followed by text which contains at least "
+            "one word or square-bracketed token",
+            "so for instance 'understand \"take [something]\" as taking' is fine, "
+            "but 'understand \"\" as the fog' is not. The same applies to the contents "
+            "of 'topic' columns in tables, since those are also instructions for "
+            "understanding.");
+    }
+    return tokens;
+}
+
+

§2.1. Reject this if it contains punctuation2.1 = +

+ +
+    int skip = FALSE, literal_punct = FALSE;
+    for (int i=0; as_wide_string[i]; i++) {
+        if (as_wide_string[i] == '[') skip = TRUE;
+        if (as_wide_string[i] == ']') skip = FALSE;
+        if (skip) continue;
+        if ((as_wide_string[i] == '.') || (as_wide_string[i] == ',') ||
+            (as_wide_string[i] == '!') || (as_wide_string[i] == '?') ||
+            (as_wide_string[i] == ':') || (as_wide_string[i] == ';'))
+            literal_punct = TRUE;
+    }
+    if (literal_punct) {
+        StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_LiteralPunctuation),
+            "'understand' text cannot contain literal punctuation",
+            "or more specifically cannot contain any of these: . , ! ? : ; since they "
+            "are already used in various ways by the parser, and would not correctly "
+            "match here.");
+        return NULL;
+    }
+
+
  • This code is used in §2.
+

§2.2. Reject this if it contains two consecutive commas2.2 = +

+ +
+    LOOP_THROUGH_WORDING(i, TW)
+        if (i < Wordings::last_wn(TW))
+            if ((compare_word(i, COMMA_V)) && (compare_word(i+1, COMMA_V))) {
+                StandardProblems::sentence_problem(Task::syntax_tree(),
+                    _p_(PM_UnderstandCommaCommand),
+                    "'understand' as an action cannot involve a comma",
+                    "since a command leading to an action never does. "
+                    "(Although Inform understands commands like 'PETE, LOOK' "
+                    "only the part after the comma is read as an action command: "
+                    "the part before the comma is read as the name of someone, "
+                    "according to the usual rules for parsing a name.) "
+                    "Because of the way Inform processes text with square "
+                    "brackets, this problem message is also sometimes seen "
+                    "if empty square brackets are used, as in 'Understand "
+                    "\"bless []\" as blessing.'");
+                return NULL;
+            }
+
+
  • This code is used in §2.
+

§3. The following tiny Preform grammar is then used to break up the resulting +text at commas: +

+ +
+<grammar-token-breaking> ::=
+    ... , ... |      ==> { NOT_APPLICABLE, - }
+    <quoted-text> |  ==> { TRUE, - }
+    ...              ==> { FALSE, - }
+
+ +

§4. The following function takes a wording and turns it into a linked list of +CG tokens, divided by commas: +

+ +
+cg_token *CGTokens::break_into_tokens(wording W) {
+    return CGTokens::break_into_tokens_r(NULL, W);
+}
+cg_token *CGTokens::break_into_tokens_r(cg_token *list, wording W) {
+    <grammar-token-breaking>(W);
+    switch (<<r>>) {
+        case NOT_APPLICABLE: {
+            wording LW = GET_RW(<grammar-token-breaking>, 1);
+            wording RW = GET_RW(<grammar-token-breaking>, 2);
+            list = CGTokens::break_into_tokens_r(list, LW);
+            list = CGTokens::break_into_tokens_r(list, RW);
+            break;
+        }
+        case TRUE:
+            Word::dequote(Wordings::first_wn(W));
+            if (*(Lexer::word_text(Wordings::first_wn(W))) == 0) return list;
+            W = Feeds::feed_C_string_full(Lexer::word_text(Wordings::first_wn(W)),
+                FALSE, GRAMMAR_PUNCTUATION_MARKS);
+            LOOP_THROUGH_WORDING(i, W) {
+                cg_token *cgt = CGTokens::cgt_of(Wordings::one_word(i), TRUE);
+                list = CGTokens::add_to_list(cgt, list);
+            }
+            break;
+        case FALSE: {
+            cg_token *cgt = CGTokens::cgt_of(W, FALSE);
+            list = CGTokens::add_to_list(cgt, list);
+            break;
+        }
+    }
+    return list;
+}
+
+

§5. If list represents the head of the list (and is NULL for an empty list), +this adds cgt at the end and returns the new head. +

+ +
+cg_token *CGTokens::add_to_list(cg_token *cgt, cg_token *list) {
+    if (list == NULL) return cgt;
+    if (cgt == NULL) return list;
+    cg_token *x = list;
+    while (x->next_token) x = x->next_token;
+    x->next_token = cgt;
+    return list;
+}
+
+

§6. As the above shows, the text of a token is not necessarily a single word, +unless it's a literal. +

+ +
+wording CGTokens::text(cg_token *cgt) {
+    return cgt?(cgt->text_of_token):(EMPTY_WORDING);
+}
+
+

§7. The GTC. The GTC, or grammar token code, is a sort of type indicator for tokens. As +produced by the tokeniser above, tokens initially have GTC either UNDETERMINED_GTC +or LITERAL_GTC. Differentiation of non-literal tokens into other types happens +in CGTokens::determine. +

+ +

Note that there are two sets of GTC values, one set positive, one negative. The +negative ones correspond closely to command-parser grammar reserved tokens in +the old I6 compiler, and this is indeed what they compile to if we are +generating I6 code. +

+ +
define NAMED_TOKEN_GTC 1
 define RELATED_GTC 2
 define STUFF_GTC 3
 define ANY_STUFF_GTC 4
 define ANY_THINGS_GTC 5
-define NOUN_TOKEN_GTC -1         I6 noun
-define MULTI_TOKEN_GTC -2        I6 multi
-define MULTIINSIDE_TOKEN_GTC -3  I6 multiinside
-define MULTIHELD_TOKEN_GTC -4    I6 multiheld
-define HELD_TOKEN_GTC -5         I6 held
-define CREATURE_TOKEN_GTC -6     I6 creature
-define TOPIC_TOKEN_GTC -7        I6 topic
-define MULTIEXCEPT_TOKEN_GTC -8  I6 multiexcept
+define LITERAL_GTC 6
+define UNDETERMINED_GTC 0
+define NOUN_TOKEN_GTC -1         like I6 noun
+define MULTI_TOKEN_GTC -2        like I6 multi
+define MULTIINSIDE_TOKEN_GTC -3  like I6 multiinside
+define MULTIHELD_TOKEN_GTC -4    like I6 multiheld
+define HELD_TOKEN_GTC -5         like I6 held
+define CREATURE_TOKEN_GTC -6     like I6 creature
+define TOPIC_TOKEN_GTC -7        like I6 topic
+define MULTIEXCEPT_TOKEN_GTC -8  like I6 multiexcept
 
-void CGTokens::log(cg_token *cgt) {
+int CGTokens::is_literal(cg_token *cgt) {
+    if ((cgt) && (cgt->grammar_token_code == LITERAL_GTC)) return TRUE;
+    return FALSE;
+}
+
+int CGTokens::is_I6_parser_token(cg_token *cgt) {
+    if ((cgt) && (cgt->grammar_token_code < 0)) return TRUE;
+    return FALSE;
+}
+
+int CGTokens::is_topic(cg_token *cgt) {
+    if ((cgt) && (cgt->grammar_token_code == TOPIC_TOKEN_GTC)) return TRUE;
+    return FALSE;
+}
+
+

§8. A multiple token is one which permits multiple matches in the run-time command +parser: for instance, the player can type ALL where a MULTI_TOKEN_GTC is +expected. +

+ +
+int CGTokens::is_multiple(cg_token *cgt) {
+    switch (cgt->grammar_token_code) {
+        case MULTI_TOKEN_GTC:
+        case MULTIINSIDE_TOKEN_GTC:
+        case MULTIHELD_TOKEN_GTC:
+        case MULTIEXCEPT_TOKEN_GTC:
+            return TRUE;
+    }
+    return FALSE;
+}
+
+

§9. Logging.

+ +
+void CGTokens::log(cg_token *cgt) {
     if (cgt == NULL) LOG("<no-cgt>");
     else {
         LOG("<CGT%d:%W", cgt->allocation_id, cgt->text_of_token);
@@ -139,252 +359,50 @@ also called "tokens" in the runtime command parser.
     }
 }
 
-

§3.

- -

is_literal is set for literal words such as "into" -and clear for square-bracketed tokens such as "[something]". +

§10. Parsing nonliteral tokens. Unless a token is literal and in double-quotes, it will start out as having +UNDETERMINED_GTC until we investigate what the words in it mean, which we +will do with the following Preform grammar.

-

The grammar_token_code annotation is meaningful only for parse nodes -with an evaluation of type DESCRIPTION. These are tokens which describe a -range of objects. Examples include "[open container]", which compiles to an -I6 noun filter, "[any container]", which compiles to an I6 scope filter, or -"[things]", one of a small number of special cases compiling to primitive I6 -parser tokens. The annotation holds the allocation ID for the noun/scope -filter structure built for the occasion in the former cases, and one of the -following constants in the latter case. (These must all have negative values -in order not to clash with allocation IDs 0, 1, 2, ..., and clearly must all -be different, but otherwise the values are not significant and there is no -preferred order.) -

- -

For tokens with any other evaluation, general_purpose is always 0, so -that the special values below cannot arise. -

- -

§4. Tokens are created when text such as "drill [something] with [something]" -is parsed, from an Understand sentence or elsewhere. What happens is much -the same as when text with substitutions is read: that produces -

- -
-

"drill", something, "with", something

-
- -

and the following little grammar is used to divide this text up into its -four constituent tokens. -

- -
-<grammar-token-breaking> ::=
-    ... , ... |    ==> { NOT_APPLICABLE, - }
-    <quoted-text> |    ==> { TRUE, - }
-    ...                     ==> { FALSE, - }
-
- -

§5. We use a different punctuation set, in which forward slashes break words, -to handle such as: -

- -
-

Understand "get away/off/out" as exiting.

-
- -

Inform would ordinarily lex the text away/off/out as one single word — so that -something like "on/off switch" would be regarded as two words not four — -but with slash treated as a punctuation mark, we instead read "away / off / -out", a sequence of five lexical words. -

- -
define GRAMMAR_PUNCTUATION_MARKS L".,:;?!(){}[]/"  note the slash...
-
-
-cg_token *CGTokens::break_into_tokens(cg_token *from, wording W) {
-    <grammar-token-breaking>(W);
-    switch (<<r>>) {
-        case NOT_APPLICABLE: {
-            wording LW = GET_RW(<grammar-token-breaking>, 1);
-            wording RW = GET_RW(<grammar-token-breaking>, 2);
-            from = CGTokens::break_into_tokens(from, LW);
-            from = CGTokens::break_into_tokens(from, RW);
-            break;
-        }
-        case TRUE:
-            Word::dequote(Wordings::first_wn(W));
-            if (*(Lexer::word_text(Wordings::first_wn(W))) == 0) return from;
-            W = Feeds::feed_C_string_full(Lexer::word_text(Wordings::first_wn(W)), FALSE, GRAMMAR_PUNCTUATION_MARKS);
-            LOOP_THROUGH_WORDING(i, W) {
-                cg_token *cgt = CGTokens::cgt_of(Wordings::one_word(i), TRUE);
-                from = CGTokens::graft(cgt, from);
-            }
-            break;
-        case FALSE: {
-            cg_token *cgt = CGTokens::cgt_of(W, FALSE);
-            from = CGTokens::graft(cgt, from);
-            break;
-        }
-    }
-    return from;
-}
-
-cg_token *CGTokens::cgt_of(wording W, int lit) {
-    cg_token *cgt = CREATE(cg_token);
-    cgt->text_of_token = W;
-    cgt->is_literal = lit;
-    cgt->slash_dash_dash = FALSE;
-    cgt->slash_class = 0;
-    cgt->grammar_value = NULL;
-    cgt->grammar_token_code = 0;
-    cgt->token_relation = NULL;
-    cgt->next_token = NULL;
-    return cgt;
-}
-
-cg_token *CGTokens::graft(cg_token *cgt, cg_token *list) {
-    if (list == NULL) return cgt;
-    if (cgt == NULL) return list;
-    cg_token *x = list;
-    while (x->next_token) x = x->next_token;
-    x->next_token = cgt;
-    return list;
-}
-
-int CGTokens::is_literal(cg_token *cgt) {
-    return (cgt)?(cgt->is_literal):FALSE;
-}
-
-

§6. Multiple tokens. A multiple token is one which permits multiple matches in the I6 parser: for -instance, permits the use of "all". -

- -
-int CGTokens::is_multiple(cg_token *cgt) {
-    switch (cgt->grammar_token_code) {
-        case MULTI_TOKEN_GTC:
-        case MULTIINSIDE_TOKEN_GTC:
-        case MULTIHELD_TOKEN_GTC:
-        case MULTIEXCEPT_TOKEN_GTC:
-            return TRUE;
-    }
-    return FALSE;
-}
-
-

§7. The special tokens. Do not change any of these GTC numbers without first checking and updating -the discussion of CGL sorting in Command Grammar Lines: -

- -
-int CGTokens::gsb_for_special_token(int gtc) {
-    switch(gtc) {
-        case NOUN_TOKEN_GTC: return 0;
-        case MULTI_TOKEN_GTC: return 0;
-        case MULTIINSIDE_TOKEN_GTC: return 1;
-        case MULTIHELD_TOKEN_GTC: return 2;
-        case HELD_TOKEN_GTC: return 3;
-        case CREATURE_TOKEN_GTC: return 0;
-        case TOPIC_TOKEN_GTC: return -1;
-        case MULTIEXCEPT_TOKEN_GTC: return 2;
-        default: internal_error("tried to find GSB for invalid GTC");
-    }
-    return 0;  to prevent a gcc error: never reached
-}
-
-

§8. These translate into I6 as follows: -

- -
-char *CGTokens::i6_token_for_special_token(int gtc) {
-    switch(gtc) {
-        case NOUN_TOKEN_GTC: return "noun";
-        case MULTI_TOKEN_GTC: return "multi";
-        case MULTIINSIDE_TOKEN_GTC: return "multiinside";
-        case MULTIHELD_TOKEN_GTC: return "multiheld";
-        case HELD_TOKEN_GTC: return "held";
-        case CREATURE_TOKEN_GTC: return "creature";
-        case TOPIC_TOKEN_GTC: return "topic";
-        case MULTIEXCEPT_TOKEN_GTC: return "multiexcept";
-        default: internal_error("tried to find I6 token for invalid GTC");
-    }
-    return "";  to prevent a gcc error: never reached
-}
-
-inter_name *CGTokens::iname_for_special_token(int gtc) {
-    switch(gtc) {
-        case NOUN_TOKEN_GTC: return VERB_DIRECTIVE_NOUN_iname;
-        case MULTI_TOKEN_GTC: return VERB_DIRECTIVE_MULTI_iname;
-        case MULTIINSIDE_TOKEN_GTC: return VERB_DIRECTIVE_MULTIINSIDE_iname;
-        case MULTIHELD_TOKEN_GTC: return VERB_DIRECTIVE_MULTIHELD_iname;
-        case HELD_TOKEN_GTC: return VERB_DIRECTIVE_HELD_iname;
-        case CREATURE_TOKEN_GTC: return VERB_DIRECTIVE_CREATURE_iname;
-        case TOPIC_TOKEN_GTC: return VERB_DIRECTIVE_TOPIC_iname;
-        case MULTIEXCEPT_TOKEN_GTC: return VERB_DIRECTIVE_MULTIEXCEPT_iname;
-        default: internal_error("tried to find inter name for invalid GTC");
-    }
-    return NULL;  to prevent a gcc error: never reached
-}
-
-char *CGTokens::i6_constant_for_special_token(int gtc) {
-    switch(gtc) {
-        case NOUN_TOKEN_GTC: return "NOUN_TOKEN";
-        case MULTI_TOKEN_GTC: return "MULTI_TOKEN";
-        case MULTIINSIDE_TOKEN_GTC: return "MULTIINSIDE_TOKEN";
-        case MULTIHELD_TOKEN_GTC: return "MULTIHELD_TOKEN";
-        case HELD_TOKEN_GTC: return "HELD_TOKEN";
-        case CREATURE_TOKEN_GTC: return "CREATURE_TOKEN";
-        case TOPIC_TOKEN_GTC: return "TOPIC_TOKEN";
-        case MULTIEXCEPT_TOKEN_GTC: return "MULTIEXCEPT_TOKEN";
-        default: internal_error("tried to find I6 constant for invalid GTC");
-    }
-    return "";  to prevent a gcc error: never reached
-}
-
-

§9. The special tokens all return a value in I6 which needs a kind -to be used in I7: these are defined by the following routine. -

- -
-kind *CGTokens::kind_for_special_token(int gtc) {
-    if ((K_understanding) && (gtc == TOPIC_TOKEN_GTC)) return K_understanding;
-    return K_object;
-}
-
-

§10. The tokens which aren't literal words in double-quotes are parsed as follows: +

Note that <grammar-token> always matches any text, even if it sometimes throws +a problem message on the way. Its return integer is a valid GTC, and its +return pointer is a (non-null) description of what the token matches.

 <grammar-token> ::=
-    <named-grammar-token> |                          ==> { NAMED_TOKEN_GTC, -, <<command_grammar:named>> = RP[1] }
-    any things |                                     ==> { ANY_THINGS_GTC, -, <<parse_node:s>> = Specifications::from_kind(K_thing) }
-    any <s-description> |                            ==> { ANY_STUFF_GTC, -, <<parse_node:s>> = RP[1] }
-    anything |                                       ==> { ANY_STUFF_GTC, -, <<parse_node:s>> = Specifications::from_kind(K_thing) }
-    anybody |                                        ==> { ANY_STUFF_GTC, -, <<parse_node:s>> = Specifications::from_kind(K_person) }
-    anyone |                                         ==> { ANY_STUFF_GTC, -, <<parse_node:s>> = Specifications::from_kind(K_person) }
-    anywhere |                                       ==> { ANY_STUFF_GTC, -, <<parse_node:s>> = Specifications::from_kind(K_room) }
-    something related by reversed <relation-name> |  ==> { RELATED_GTC, BinaryPredicates::get_reversal(RP[1]) }
-    something related by <relation-name> |           ==> { RELATED_GTC, RP[1] }
-    something related by ... |                       ==> Issue PM_GrammarBadRelation problem10.1
-    <standard-grammar-token> |                       ==> { R[1], NULL }
-    <definite-article> <k-kind> |                    ==> { STUFF_GTC, -, <<parse_node:s>> = Specifications::from_kind(RP[2]) }
-    <s-description> |                                ==> { STUFF_GTC, -, <<parse_node:s>> = RP[1] }
-    <s-type-expression> |                            ==> Issue PM_BizarreToken problem10.7
-    ...                                              ==> Issue PM_UnknownToken problem10.8
+    <named-grammar-token> |       ==> Apply the command grammar10.1
+    any things |                  ==> { ANY_THINGS_GTC, Specifications::from_kind(K_thing) }
+    any <s-description> |         ==> { ANY_STUFF_GTC, RP[1] }
+    anything |                    ==> { ANY_STUFF_GTC, Specifications::from_kind(K_thing) }
+    anybody |                     ==> { ANY_STUFF_GTC, Specifications::from_kind(K_person) }
+    anyone |                      ==> { ANY_STUFF_GTC, Specifications::from_kind(K_person) }
+    anywhere |                    ==> { ANY_STUFF_GTC, Specifications::from_kind(K_room) }
+    something related by reversed <relation-name> |   ==> Apply the reversed relation10.2
+    something related by <relation-name> |            ==> Apply the relation10.3
+    something related by ... |    ==> Issue PM_GrammarBadRelation problem10.4
+    <standard-grammar-token> |    ==> { pass 1 }
+    <definite-article> <k-kind> | ==> { STUFF_GTC, Specifications::from_kind(RP[2]) }
+    <s-description> |             ==> { STUFF_GTC, RP[1] }
+    <s-type-expression> |         ==> Issue PM_BizarreToken problem10.9
+    ...                           ==> Issue PM_UnknownToken problem10.10
 
 <standard-grammar-token> ::=
-    something |                                      ==> { NOUN_TOKEN_GTC, - }
-    things |                                         ==> { MULTI_TOKEN_GTC, - }
-    things inside |                                  ==> { MULTIINSIDE_TOKEN_GTC, - }
-    things preferably held |                         ==> { MULTIHELD_TOKEN_GTC, - }
-    something preferably held |                      ==> { HELD_TOKEN_GTC, - }
-    other things |                                   ==> { MULTIEXCEPT_TOKEN_GTC, - }
-    someone |                                        ==> { CREATURE_TOKEN_GTC, - }
-    somebody |                                       ==> { CREATURE_TOKEN_GTC, - }
-    text |                                           ==> { TOPIC_TOKEN_GTC, - }
-    topic |                                          ==> Issue PM_UseTextNotTopic problem10.2
-    a topic |                                        ==> Issue PM_UseTextNotTopic problem10.2
-    object |                                         ==> Issue PM_UseThingNotObject problem10.3
-    an object |                                      ==> Issue PM_UseThingNotObject problem10.3
-    something held |                                 ==> Issue something held problem message10.4
-    things held                                      ==> Issue things held problem message10.5
+    something |                 ==> { NOUN_TOKEN_GTC, Specifications::from_kind(K_object) }
+    things |                    ==> { MULTI_TOKEN_GTC, Specifications::from_kind(K_object) }
+    things inside |             ==> { MULTIINSIDE_TOKEN_GTC, Specifications::from_kind(K_object) }
+    things preferably held |    ==> { MULTIHELD_TOKEN_GTC, Specifications::from_kind(K_object) }
+    something preferably held | ==> { HELD_TOKEN_GTC, Specifications::from_kind(K_object) }
+    other things |              ==> { MULTIEXCEPT_TOKEN_GTC, Specifications::from_kind(K_object) }
+    someone |                   ==> { CREATURE_TOKEN_GTC, Specifications::from_kind(K_object) }
+    somebody |                  ==> { CREATURE_TOKEN_GTC, Specifications::from_kind(K_object) }
+    text |                      ==> { TOPIC_TOKEN_GTC, Specifications::from_kind(K_understanding) }
+    topic |                     ==> Issue PM_UseTextNotTopic problem10.5
+    a topic |                   ==> Issue PM_UseTextNotTopic problem10.5
+    object |                    ==> Issue PM_UseThingNotObject problem10.6
+    an object |                 ==> Issue PM_UseThingNotObject problem10.6
+    something held |            ==> Issue something held problem message10.7
+    things held                 ==> Issue things held problem message10.8
 
 <named-grammar-token> internal {
     command_grammar *cg = CommandGrammars::named_token_by_name(W);
@@ -396,7 +414,28 @@ to be used in I7: these are defined by the following routine.
 }
 
-

§10.1. Issue PM_GrammarBadRelation problem10.1 = +

§10.1. Apply the command grammar10.1 = +

+ +
+    ==> { NAMED_TOKEN_GTC, ParsingPlugin::rvalue_from_command_grammar(RP[1]) }
+
+
  • This code is used in §10.
+

§10.2. Apply the reversed relation10.2 = +

+ +
+    ==> { RELATED_GTC, Rvalues::from_binary_predicate(BinaryPredicates::get_reversal(RP[1])) }
+
+
  • This code is used in §10.
+

§10.3. Apply the relation10.3 = +

+ +
+    ==> { RELATED_GTC, Rvalues::from_binary_predicate(RP[1]) }
+
+
  • This code is used in §10.
+

§10.4. Issue PM_GrammarBadRelation problem10.4 =

@@ -408,10 +447,10 @@ to be used in I7: these are defined by the following routine.
         "invites me to understand names of related things, "
         "but the relation is not one that I know.");
     Problems::issue_problem_end();
-    ==> { RELATED_GTC, NULL };
+    ==> { RELATED_GTC, Rvalues::from_binary_predicate(R_equality) }
 
  • This code is used in §10.
-

§10.2. Issue PM_UseTextNotTopic problem10.2 = +

§10.5. Issue PM_UseTextNotTopic problem10.5 =

@@ -429,10 +468,10 @@ to be used in I7: these are defined by the following routine.
         "or in descriptions of actions or in table columns; it's really "
         "intended only for defining new commands.");
     Problems::issue_problem_end();
-    ==> { TOPIC_TOKEN_GTC, NULL };
+    ==> { TOPIC_TOKEN_GTC, Specifications::from_kind(K_understanding) };
 
  • This code is used in §10 (twice).
-

§10.3. Issue PM_UseThingNotObject problem10.3 = +

§10.6. Issue PM_UseThingNotObject problem10.6 =

@@ -445,33 +484,65 @@ to be used in I7: these are defined by the following routine.
         "all here', but Inform uses the special syntax '[thing]' "
         "for that. (Or '[things]' if multiple objects are allowed.)");
     Problems::issue_problem_end();
-    ==> { MULTI_TOKEN_GTC, NULL };
+    ==> { MULTI_TOKEN_GTC, Specifications::from_kind(K_object) }
 
  • This code is used in §10 (twice).
-

§10.4. Issue something held problem message10.4 = +

§10.7. Issue something held problem message10.7 =

-    CGTokens::incompatible_change_problem(
+    CGTokens::incompatible_change_problem(
         "something held", "something", "something preferably held");
-    ==> { HELD_TOKEN_GTC, NULL };
+    ==> { HELD_TOKEN_GTC, Specifications::from_kind(K_object) }
 
  • This code is used in §10.
-

§10.5. Issue things held problem message10.5 = +

§10.8. Issue things held problem message10.8 =

-    CGTokens::incompatible_change_problem(
+    CGTokens::incompatible_change_problem(
             "things held", "things", "things preferably held");
-    ==> { MULTIHELD_TOKEN_GTC, NULL };
+    ==> { MULTIHELD_TOKEN_GTC, Specifications::from_kind(K_object) }
 
  • This code is used in §10.
-

§10.6. Something of an extended mea culpa: but it had the desired effect, in +

§10.9. Issue PM_BizarreToken problem10.9 = +

+ +
+    LOG("$T", current_sentence);
+    Problems::quote_source(1, current_sentence);
+    Problems::quote_wording(2, W);
+    Problems::quote_kind_of(3, RP[1]);
+    StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_BizarreToken));
+    Problems::issue_problem_segment(
+        "The grammar token '%2' in the sentence %1 looked to me as "
+        "if it might be %3, but this isn't something allowed in "
+        "parsing grammar.");
+    Problems::issue_problem_end();
+    ==> { STUFF_GTC, Specifications::from_kind(K_thing) }
+
+
  • This code is used in §10.
+

§10.10. Issue PM_UnknownToken problem10.10 = +

+ +
+    LOG("$T", current_sentence);
+    Problems::quote_source(1, current_sentence);
+    Problems::quote_wording(2, W);
+    StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_UnknownToken));
+    Problems::issue_problem_segment(
+        "I was unable to understand what you meant by the grammar token '%2' "
+        "in the sentence %1.");
+    Problems::issue_problem_end();
+    ==> { STUFF_GTC, Specifications::from_kind(K_thing) }
+
+
  • This code is used in §10.
+

§11. Something of an extended mea culpa: but it had the desired effect, in that nobody complained about what might have been a controversial change.

-void CGTokens::incompatible_change_problem(char *token_tried, char *token_instead,
+void CGTokens::incompatible_change_problem(char *token_tried, char *token_instead,
     char *token_better) {
     Problems::quote_source(1, current_sentence);
     Problems::quote_text(2, token_tried);
@@ -497,141 +568,130 @@ that nobody complained about what might have been a controversial change.
     Problems::issue_problem_end();
 }
 
-

§10.7. Issue PM_BizarreToken problem10.7 = +

§12. Determining. To calculate a description of what is being described by a token, then, we +call the following function, which delegates to <grammar-token> above. +

+ +

In the two cases NAMED_TOKEN_GTC and RELATED_GTC the pointer result is +a temporary one telling us which named token, and which relation, respectively: +we then convert those into the result. In all other cases, the parse_node +pointer returned by <grammar-token> is the result.

-    LOG("$T", current_sentence);
-    Problems::quote_source(1, current_sentence);
-    Problems::quote_wording(2, W);
-    Problems::quote_kind_of(3, RP[1]);
-    StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_BizarreToken));
-    Problems::issue_problem_segment(
-        "The grammar token '%2' in the sentence %1 looked to me as "
-        "if it might be %3, but this isn't something allowed in "
-        "parsing grammar.");
-    Problems::issue_problem_end();
-    ==> { STUFF_GTC, - };
-
-
  • This code is used in §10.
-

§10.8. Issue PM_UnknownToken problem10.8 = -

+parse_node *CGTokens::determine(cg_token *cgt, int depth) { + if (CGTokens::is_literal(cgt)) return NULL; -
-    LOG("$T", current_sentence);
-    Problems::quote_source(1, current_sentence);
-    Problems::quote_wording(2, W);
-    StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_UnknownToken));
-    Problems::issue_problem_segment(
-        "I was unable to understand what you meant by the grammar token '%2' "
-        "in the sentence %1.");
-    Problems::issue_problem_end();
-    ==> { STUFF_GTC, - };
-
-
  • This code is used in §10.
-
-parse_node *CGTokens::determine(cg_token *cgt, int depth, int *score) {
-    if (CGTokens::is_literal(cgt)) return NULL;
+    <grammar-token>(CGTokens::text(cgt));
+    cgt->grammar_token_code = <<r>>;
+    parse_node *result = <<rp>>;
 
-    <<command_grammar:named>> = NULL;
-    parse_node *spec = NULL;
-    <grammar-token>(CGTokens::text(cgt));
-    switch (<<r>>) {
-        case NAMED_TOKEN_GTC: Determine a named grammar token11.1; break;
-        case ANY_STUFF_GTC: Determine an any grammar token11.2; break;
-        case ANY_THINGS_GTC: Determine an any grammar token11.2; break;
-        case RELATED_GTC: Determine a related grammar token11.3; break;
-        case STUFF_GTC: Determine a kind grammar token11.4; break;
-        default: Determine a special grammar token11.5; break;
+    switch (cgt->grammar_token_code) {
+        case NAMED_TOKEN_GTC:
+            cgt->defined_by = ParsingPlugin::rvalue_to_command_grammar(result);
+            result = CommandGrammars::determine(cgt->defined_by, depth+1);
+            break;
+        case ANY_STUFF_GTC:
+            Make sure the result is a description with one free variable12.1;
+            cgt->noun_filter = UnderstandFilterTokens::nft_new(result, TRUE, FALSE);
+            break;
+        case ANY_THINGS_GTC:
+            Make sure the result is a description with one free variable12.1;
+            cgt->noun_filter = UnderstandFilterTokens::nft_new(result, TRUE, TRUE);
+            break;
+        case RELATED_GTC:
+            cgt->token_relation = Rvalues::to_binary_predicate(result);
+            kind *K = BinaryPredicates::term_kind(cgt->token_relation, 0);
+            if (K == NULL) K = K_object;
+            result = Specifications::from_kind(K);
+            break;
+        case STUFF_GTC:
+            Make sure the result is a description with one free variable12.1;
+            cgt->noun_filter = UnderstandFilterTokens::nft_new(result, FALSE, FALSE);
+            break;
+        default:
+            Node::set_text(result, CGTokens::text(cgt));
+            break;
     }
-    if (spec) Vet the grammar token determination for parseability at run-time11.6;
-    return spec;
+
+    if (result) Vet the grammar token determination for parsability at run-time12.2;
+    cgt->what_token_describes = result;
+    return cgt->what_token_describes;
 }
 
-

§11.1. Determine a named grammar token11.1 = +

§12.1. If the token determines an actual constant value — as it can when it is a +named token which always refers to a specific thing, for example — it is +possible for result not to be a description. Otherwise, though, it has to +be a description which is true or false for any given value, so: +

+ +

Make sure the result is a description with one free variable12.1 =

-    parse_node *val = ParsingPlugin::rvalue_from_command_grammar(<<command_grammar:named>>);
-    spec = CommandGrammars::determine(<<command_grammar:named>>, depth+1);
-    cgt->grammar_value = val;
-
-
  • This code is used in §11.
-

§11.2. Determine an any grammar token11.2 = -

- -
-    spec = <<parse_node:s>>;
-    if (Specifications::is_description(spec)) {
-        int any_things = FALSE;
-        if (<<r>> == ANY_THINGS_GTC) any_things = TRUE;
-        cgt->grammar_token_code = UnderstandFilterTokens::new_id(spec, TRUE, any_things);
-        cgt->grammar_value = spec;
+    pcalc_prop *prop = Specifications::to_proposition(result);
+    if ((prop) && (Binding::number_free(prop) != 1)) {
+        LOG("So $P and $D\n", result, prop);
+        StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_FilterQuantified),
+            "the [any ...] doesn't clearly give a description in the '...' part",
+            "where I was expecting something like '[any vehicle]'.");
+        result = Specifications::from_kind(K_object);
     }
 
-
  • This code is used in §11 (twice).
-

§11.3. Determine a related grammar token11.3 = +

  • This code is used in §12 (three times).
+

§12.2. Vet the grammar token determination for parsability at run-time12.2 =

-    binary_predicate *bp = <<rp>>;
-    if (bp) cgt->token_relation = bp;
-
-
  • This code is used in §11.
-

§11.4. Determine a kind grammar token11.4 = -

- -
-    spec = <<parse_node:s>>;
-    cgt->grammar_value = spec;
-    if (Specifications::is_description_like(spec)) {
-        *score = 5;
-        cgt->grammar_token_code = UnderstandFilterTokens::new_id(spec, FALSE, FALSE);
-    }
-
-
  • This code is used in §11.
-

§11.5. Determine a special grammar token11.5 = -

- -
-    int p = <<r>>;
-    kind *K = CGTokens::kind_for_special_token(p);
-    spec = Specifications::from_kind(K);
-    Node::set_text(spec, CGTokens::text(cgt));
-    *score = CGTokens::gsb_for_special_token(p);
-    cgt->grammar_value = spec;
-    cgt->grammar_token_code = p;
-
-
  • This code is used in §11.
-

§11.6. Vet the grammar token determination for parseability at run-time11.6 = -

- -
-    if (Specifications::is_description(spec)) {
-        kind *K = Specifications::to_kind(spec);
+    if (Specifications::is_description(result)) {
+        kind *K = Specifications::to_kind(result);
         if ((K_understanding) &&
             (Kinds::Behaviour::is_object(K) == FALSE) &&
             (Kinds::eq(K, K_understanding) == FALSE) &&
             (Kinds::Behaviour::request_I6_GPR(K) == FALSE)) {
             Problems::quote_source(1, current_sentence);
-            Problems::quote_wording(2, CGTokens::text(cgt));
-            StandardProblems::handmade_problem(Task::syntax_tree(),
-                _p_(PM_UnparsableKind));
+            Problems::quote_wording(2, CGTokens::text(cgt));
+            StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_UnparsableKind));
             Problems::issue_problem_segment(
-                "The grammar token '%2' in the sentence %1 "
-                "invites me to understand values typed by the player during "
-                "play but for a kind of value which is beyond my ability. "
-                "Generally speaking, the allowable kinds of value are "
-                "number, time, text and any new kind of value you may "
-                "have created - but not, for instance, scene or rule.");
+                "The grammar token '%2' in the sentence %1 invites me to understand "
+                "values typed by the player during play but for a kind of value which "
+                "is beyond my ability. Generally speaking, the allowable kinds of value "
+                "are number, time, text and any new kind of value you may have created - "
+                "but not, for instance, scene or rule.");
             Problems::issue_problem_end();
-            spec = NULL;
+            result = Specifications::from_kind(K_object);
         }
     }
 
-
  • This code is used in §11.
+
  • This code is used in §12.
+

§13. Scoring. This score is needed when sorting CG lines in order of applicability: see the +discussion at CGLines::cgl_determine. The function must return a value +which is at least 0 but strictly less than CGL_SCORE_TOKEN_RANGE. The +general idea is that higher scores cause tokens to take precedence over lower +ones. +

+ +
+int CGTokens::score_bonus(cg_token *cgt) {
+    if (cgt == NULL) internal_error("no cgt");
+    if (cgt->grammar_token_code == UNDETERMINED_GTC) internal_error("undetermined");
+    int gtc = cgt->grammar_token_code;
+    switch(gtc) {
+        case STUFF_GTC:             return 5;
+        case NOUN_TOKEN_GTC:        return 1;
+        case MULTI_TOKEN_GTC:       return 1;
+        case MULTIINSIDE_TOKEN_GTC: return 2;
+        case MULTIHELD_TOKEN_GTC:   return 3;
+        case HELD_TOKEN_GTC:        return 4;
+        case CREATURE_TOKEN_GTC:    return 1;
+        case TOPIC_TOKEN_GTC:       return 0;
+        case MULTIEXCEPT_TOKEN_GTC: return 3;
+    }
+    return 1;
+}
+
diff --git a/docs/if-module/5-dt.html b/docs/if-module/5-dt.html index 1a10e0706..b57f18260 100644 --- a/docs/if-module/5-dt.html +++ b/docs/if-module/5-dt.html @@ -200,7 +200,7 @@ of CGL sorting in Command Grammar Lines}
diff --git a/docs/if-module/5-gp.html b/docs/if-module/5-gp.html deleted file mode 100644 index b26c50bf4..000000000 --- a/docs/if-module/5-gp.html +++ /dev/null @@ -1,201 +0,0 @@ - - - - Grammar Properties - - - - - - - - - - - - - - - - - - -
- - -

A plugin for the I6 run-time properties needed to support parsing.

- -
- -

§1. Definitions.

- -

§2.

- -
-property *P_parse_name = NULL;
-
-

§3. And every property permission likewise: -

- -
-typedef struct parsing_pp_data {
-    int visibility_level_in_parser;  if so, does the run-time I6 parser recognise it?
-    struct wording visibility_condition;  (at least if...?)
-    struct parse_node *visibility_sentence;  where this is specified
-    CLASS_DEFINITION
-} parsing_pp_data;
-
-
  • The structure parsing_pp_data is private to this section.
-

§4. Initialising.

- -
-parsing_data *Visibility::new_data(inference_subject *subj) {
-    parsing_data *pd = CREATE(parsing_data);
-    pd->understand_as_this_object = NULL;
-    return pd;
-}
-
-parsing_pp_data *Visibility::new_pp_data(property_permission *pp) {
-    parsing_pp_data *pd = CREATE(parsing_pp_data);
-    pd->visibility_level_in_parser = 0;
-    pd->visibility_condition = EMPTY_WORDING;
-    pd->visibility_sentence = NULL;
-    return pd;
-}
-
-int Visibility::new_permission_notify(property_permission *new_pp) {
-    CREATE_PLUGIN_PP_DATA(parsing, new_pp, Visibility::new_pp_data);
-    return FALSE;
-}
-
-

§5. Visible properties. A visible property is one which can be used to describe an object: for -instance, if colour is a visible property of a car, then it can be called -"green car" if and only if the current value of the colour of the car is -"green". -

- -

Properly speaking it is not the property which is visible, but the -combination of property and object (or kind): thus the following test -depends on a property permission and not a mere property. -

- -
-int Visibility::seek(property *pr, inference_subject *subj,
-    int level, wording WHENW) {
-    int parity, upto = 1;
-    if (Properties::is_either_or(pr) == FALSE) upto = 0;
-    for (parity = 0; parity <= upto; parity++) {
-        property *seek_prn = (parity == 0)?pr:(EitherOrProperties::get_negation(pr));
-        if (seek_prn == NULL) continue;
-        if (PropertyPermissions::find(subj, seek_prn, TRUE) == NULL) continue;
-        property_permission *pp = PropertyPermissions::grant(subj, seek_prn, FALSE);
-        PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser = level;
-        PP_PLUGIN_DATA(parsing, pp)->visibility_sentence = current_sentence;
-        PP_PLUGIN_DATA(parsing, pp)->visibility_condition = WHENW;
-        return TRUE;
-    }
-    return FALSE;
-}
-
-int Visibility::any_property_visible_to_subject(inference_subject *subj, int allow_inheritance) {
-    property *pr;
-    LOOP_OVER(pr, property) {
-        property_permission *pp =
-            PropertyPermissions::find(subj, pr, allow_inheritance);
-        if ((pp) && (PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser > 0))
-            return TRUE;
-    }
-    return FALSE;
-}
-
-int Visibility::get_level(property_permission *pp) {
-    return PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser;
-}
-
-parse_node *Visibility::get_condition(property_permission *pp) {
-    parse_node *spec;
-    if (Wordings::empty(PP_PLUGIN_DATA(parsing, pp)->visibility_condition)) return NULL;
-    spec = NULL;
-    if (<s-condition>(PP_PLUGIN_DATA(parsing, pp)->visibility_condition)) spec = <<rp>>;
-    else spec = Specifications::new_UNKNOWN(PP_PLUGIN_DATA(parsing, pp)->visibility_condition);
-    if (Dash::validate_conditional_clause(spec) == FALSE) {
-        LOG("$T", spec);
-        current_sentence = PP_PLUGIN_DATA(parsing, pp)->visibility_sentence;
-        StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_BadVisibilityWhen),
-            "the condition after 'when' makes no sense to me",
-            "although otherwise this worked - it is only the part after 'when' "
-            "which I can't follow.");
-        PP_PLUGIN_DATA(parsing, pp)->visibility_condition = EMPTY_WORDING;
-        return NULL;
-    }
-    return spec;
-}
-
-void Visibility::log_parsing_visibility(inference_subject *infs) {
-    LOG("Permissions for $j:\n", infs);
-    property_permission *pp = NULL;
-    LOOP_OVER_PERMISSIONS_FOR_INFS(pp, infs) {
-        LOG("$Y: visibility %d, condition %W\n",
-            PropertyPermissions::get_property(pp),
-            PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser,
-            PP_PLUGIN_DATA(parsing, pp)->visibility_condition);
-    }
-    if (InferenceSubjects::narrowest_broader_subject(infs))
-        Visibility::log_parsing_visibility(InferenceSubjects::narrowest_broader_subject(infs));
-}
-
- - -
- - - diff --git a/docs/if-module/5-gpr.html b/docs/if-module/5-gpr.html deleted file mode 100644 index 2ded86a4b..000000000 --- a/docs/if-module/5-gpr.html +++ /dev/null @@ -1,1335 +0,0 @@ - - - - General Parsing Routines - - - - - - - - - - - - - - - - - - -
- - -

To compile I6 general parsing routines (GPRs) and/or |parse_name| properties as required by the I7 grammar.

- -
- -

§1. Definitions.

- -
-typedef struct parse_name_notice {
-    inter_name *pnn_iname;
-    inference_subject *parse_subject;
-    CLASS_DEFINITION
-} parse_name_notice;
-
-
  • The structure parse_name_notice is private to this section.
-

§2. In this section we compile GPRs, routines to handle Consult-like text, -and also parse_name routines, which as we shall see come in two different -forms. These routines share a basic protocol for dealing with the I6 -library, which makes things considerably easier. In each case, the -routine is compiled as a head and then, subsequently, a tail: the user -of the routines is expected to compile the actual grammar in between -the two. Every head must be followed by exactly one tail of the same -sort; every tail must be preceded by exactly one head of the same sort; -but code to parse at wn may be placed in between. -

- -

The GPRs compiled to parse literal values of given kinds of values -(for instance, exotic verbal forms of numbers, or verbal names of -the constants for new kinds of value, or literal patterns) are not -compiled here: they are in Tokens Parsing Values. -

- -

§3. Consult routines. These are used to parse an explicit range of words (such as traditionally -found in the CONSULT command) at run time, and they are not I6 grammar -tokens, and do not appear in Verb declarations: otherwise, such -routines are very similar to GPRs. -

- -

First, we need to look after a pointer to the CG used to hold the grammar -being matched against the snippet of words. -

- -
-inter_name *UnderstandGeneralTokens::consult_iname(command_grammar *cg) {
-    if (cg == NULL) return NULL;
-    if (cg->compilation_data.cg_consult_iname == NULL) {
-        current_sentence = cg->where_cg_created;
-        package_request *PR = Hierarchy::local_package(CONSULT_TOKENS_HAP);
-        cg->compilation_data.cg_consult_iname = Hierarchy::make_iname_in(CONSULT_FN_HL, PR);
-    }
-    return cg->compilation_data.cg_consult_iname;
-}
-
-

§4. Parse name properties. One of the major services provided by I7, as compared with I6, is that it -automatically compiles what would otherwise be laborious parse_name -routines for its objects. This is messy, because the underlying I6 syntax -is messy. The significant complication is that the I6 parser makes two -quite different uses of parse_name: not just for parsing names, but -also for determining whether two objects are visually distinguishable, -something it needs to know in order to make plural objects work properly. -

- -

If an object has any actual grammar attached, say a collection of grammar -lines belonging to GV3, we will compile the parse_name as an independent -I6 routine with a name like Parse_Name_GV3. If not, a parse_name may -still be needed, because of the distinguishability problem: if so then we -will simply compile a parse_name routine inline, in the usual I6 way. -

- -
-inter_name *UnderstandGeneralTokens::get_gv_parse_name(command_grammar *cg) {
-    if (cg->compilation_data.cg_parse_name_iname == NULL) {
-        compilation_unit *C = CompilationUnits::find(cg->where_cg_created);
-        package_request *PR = Hierarchy::package(C, PARSE_NAMES_HAP);
-        cg->compilation_data.cg_parse_name_iname = Hierarchy::make_iname_in(PARSE_NAME_FN_HL, PR);
-    }
-    return cg->compilation_data.cg_parse_name_iname;
-}
-
-inter_name *UnderstandGeneralTokens::compile_parse_name_property(inference_subject *subj) {
-    inter_name *symb = NULL;
-    command_grammar *cg = PARSING_DATA_FOR_SUBJ(subj)->understand_as_this_object;
-    if (CommandGrammars::is_empty(cg) == FALSE) {
-        symb = UnderstandGeneralTokens::get_gv_parse_name(cg);
-    } else {
-        if (Visibility::any_property_visible_to_subject(subj, FALSE)) {
-            parse_name_notice *notice = CREATE(parse_name_notice);
-            compilation_unit *C = CompilationUnits::find(subj->infs_created_at);
-            package_request *PR = Hierarchy::package(C, PARSE_NAMES_HAP);
-            notice->pnn_iname = Hierarchy::make_iname_in(PARSE_NAME_DASH_FN_HL, PR);
-            notice->parse_subject = subj;
-            symb = notice->pnn_iname;
-        }
-    }
-    return symb;
-}
-
-void UnderstandGeneralTokens::write_parse_name_routines(void) {
-    parse_name_notice *notice;
-    LOOP_OVER(notice, parse_name_notice) {
-        gpr_kit gprk = UnderstandValueTokens::new_kit();
-        packaging_state save = Emit::unused_packaging_state();
-        if (UnderstandGeneralTokens::compile_parse_name_head(&save, &gprk,
-            notice->parse_subject, NULL, notice->pnn_iname)) {
-            UnderstandGeneralTokens::compile_parse_name_tail(&gprk);
-            Routines::end(save);
-        }
-    }
-}
-
-

§5. The following routine produces one of three outcomes: either (i) the -head of an I6 declaration of a free-standing routine to be used as a -parse_name property, or (ii) the head of an I6 inline declaration of a -parse_name property as a with clause for an Object directive, or -

- -
  • (iii) the empty output, in happy cases where neither parsing nor -distinguishability need to be investigated. The routine returns a flag -indicating if a tail need be compiled (i.e., in cases (i) or (ii) but not -(iii)). -
-

In cases (i) and (ii), the head is immediately followed by code which -looks at the names of visible properties. Recall that a visible property -is one which can be used to describe an object: for instance, if colour -is a visible property of a car, then it can be called "green car" if -and only if the current value of the colour of the car is "green", and -so forth. In all such cases, we need to parse the text to look for the -name of the current value. -

- -

But if a property can be used as part of the name, then it follows that -two objects with the same grammar (and name words) cease to be -indistinguishable when their values for this property differ. For instance, -given two otherwise identical cars which can only be called "car", we -can distinguish them with the names "red car" and "green car" if one -is red and the other green. The parser needs to know this. It calls the -parse_name routine with an I6 global called parser_action set to -##TheSame in such a case, and we can return 0 to make no decision or --2 to say that they are different. -

- -

Note that the parser checks this only if two or more objects share the same -parse_name routine: which will in I7 happen only if they each inherit it -from the I6 class of a common kind. Because parse_name is not additive in -I6, this can only occur if the objects, and any intervening classes for -intervening kinds, define no parse_name of their own. -

- -

We will test distinguishability only for kinds which have permissions for -visible properties: kinds because no other parse_name values can ever -be duplicated in instance objects, and visible properties because these -are the only ways to tell apart instances which have no grammar of their -own. (If either had grammar of its own, it would also have its own -parse_name routine.) For all other kinds, we return a make-no-decision -value in response to a ##TheSame request: this ensures that the I6 -parser looks at the name properties of the objects instead, and in -the absence of either I7-level grammar lines or visible properties, that -will be the correct decision. -

- -
-int UnderstandGeneralTokens::compile_parse_name_head(packaging_state *save,
-    gpr_kit *gprk, inference_subject *subj,
-    command_grammar *cg, inter_name *rname) {
-    int test_distinguishability = FALSE, sometimes_has_visible_properties = FALSE;
-    inter_name *N = NULL;
-
-    if (subj == NULL) internal_error("compiling parse_name head for null subj");
-
-    if (cg) {
-        sometimes_has_visible_properties =
-            Visibility::any_property_visible_to_subject(subj, TRUE);
-        N = UnderstandGeneralTokens::get_gv_parse_name(cg);
-    } else {
-        if (Visibility::any_property_visible_to_subject(subj, FALSE)
-            == FALSE) return FALSE;
-    }
-
-    if (KindSubjects::to_kind(subj)) test_distinguishability = TRUE;
-
-    inter_name *compile_to = rname;
-    if (compile_to == NULL) compile_to = N;
-    if (compile_to == NULL) internal_error("no parse name routine name given");
-
-    *save = Routines::begin(compile_to);
-
-    UnderstandValueTokens::add_parse_name_vars(gprk);
-
-    UnderstandGeneralTokens::top_of_head(gprk, N, subj,
-        test_distinguishability, sometimes_has_visible_properties, rname);
-    return TRUE;
-}
-
-

§6. The following multi-pass approach checks the possible patterns: -

- -
  • (1) (words in name property) (visible property names) (words in name property) (longer grammar) (words in name property) -
  • (2) (visible property names) (longer grammar) (words in name property) -
  • (3) (longer grammar) (words in name property) -
-

The longer match is taken: but note that a match of visible property names -alone is rejected unless at least one property has been declared sufficient -to identify the object all by itself. Longer grammar means grammar lines -containing 2 or more words, since all single-fixed-word grammar lines for -CGs destined to be parse_names is stripped out and converted into the -name property. -

- -

There are clearly other possibilities and the above system is something of -a pragmatic compromise (in that to check other cases would be slower and -more complex). I suspect we will return to this. -

- -
-void UnderstandGeneralTokens::top_of_head(gpr_kit *gprk, inter_name *cg_iname, inference_subject *subj,
-    int test_distinguishability, int sometimes_has_visible_properties, inter_name *given_name) {
-
-    Produce::inv_primitive(Emit::tree(), IFDEBUG_BIP);
-    Produce::down(Emit::tree());
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), IF_BIP);
-            Produce::down(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), GE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_TRACE_HL));
-                    Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 3);
-                Produce::up(Emit::tree());
-                Produce::code(Emit::tree());
-                Produce::down(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PRINT_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_text(Emit::tree(), I"Parse_name called\n");
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    Produce::up(Emit::tree());
-
-    if ((cg_iname) && (sometimes_has_visible_properties == FALSE)) {
-        Produce::inv_primitive(Emit::tree(), IF_BIP);
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), EQ_BIP);
-            Produce::down(Emit::tree());
-                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_ACTION_HL));
-                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(THESAME_HL));
-            Produce::up(Emit::tree());
-            Produce::code(Emit::tree());
-            Produce::down(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-                Produce::down(Emit::tree());
-                    Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    }
-    Save word number6.1;
-
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_symbol(Emit::tree(), K_value, gprk->pass_s);
-        Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), WHILE_BIP);
-    Produce::down(Emit::tree());
-        Produce::inv_primitive(Emit::tree(), LE_BIP);
-        Produce::down(Emit::tree());
-            Produce::val_symbol(Emit::tree(), K_value, gprk->pass_s);
-            Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 3);
-        Produce::up(Emit::tree());
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-            Reset word number6.2;
-            Produce::inv_primitive(Emit::tree(), STORE_BIP);
-            Produce::down(Emit::tree());
-                Produce::ref_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-            Produce::up(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), STORE_BIP);
-            Produce::down(Emit::tree());
-                Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
-                Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
-            Produce::up(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), STORE_BIP);
-            Produce::down(Emit::tree());
-                Produce::ref_symbol(Emit::tree(), K_value, gprk->n_s);
-                Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
-            Produce::up(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), WHILE_BIP);
-            Produce::down(Emit::tree());
-                Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
-                Produce::code(Emit::tree());
-                Produce::down(Emit::tree());
-
-                     On pass 1 only, advance wn past name property words
-                     (but do not do this for ##TheSame, when wn is undefined)
-                    Produce::inv_primitive(Emit::tree(), IF_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), AND_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), NE_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_ACTION_HL));
-                                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(THESAME_HL));
-                            Produce::up(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_symbol(Emit::tree(), K_value, gprk->pass_s);
-                                Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
-                            Produce::up(Emit::tree());
-                        Produce::up(Emit::tree());
-                        Produce::code(Emit::tree());
-                        Produce::down(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), WHILE_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::inv_call_iname(Emit::tree(), Hierarchy::find(WORDINPROPERTY_HL));
-                                Produce::down(Emit::tree());
-                                    Produce::inv_call_iname(Emit::tree(), Hierarchy::find(NEXTWORDSTOPPED_HL));
-                                    Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
-                                    Produce::val_iname(Emit::tree(), K_value, RTParsing::name_iname());
-                                Produce::up(Emit::tree());
-                                Produce::code(Emit::tree());
-                                Produce::down(Emit::tree());
-                                    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                                    Produce::down(Emit::tree());
-                                        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
-                                        Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
-                                    Produce::up(Emit::tree());
-                                Produce::up(Emit::tree());
-                            Produce::up(Emit::tree());
-
-                            Produce::inv_primitive(Emit::tree(), POSTDECREMENT_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-                            Produce::up(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::ref_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-                                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-                            Produce::up(Emit::tree());
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-
-                    Produce::inv_primitive(Emit::tree(), IF_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), OR_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_symbol(Emit::tree(), K_value, gprk->pass_s);
-                                Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
-                            Produce::up(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_symbol(Emit::tree(), K_value, gprk->pass_s);
-                                Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 2);
-                            Produce::up(Emit::tree());
-                        Produce::up(Emit::tree());
-                        Produce::code(Emit::tree());
-                        Produce::down(Emit::tree());
-                        UnderstandGeneralTokens::consider_visible_properties(gprk, subj, test_distinguishability);
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-
-                    Produce::inv_primitive(Emit::tree(), IF_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), AND_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), NE_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_ACTION_HL));
-                                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(THESAME_HL));
-                            Produce::up(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_symbol(Emit::tree(), K_value, gprk->pass_s);
-                                Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
-                            Produce::up(Emit::tree());
-                        Produce::up(Emit::tree());
-                        Produce::code(Emit::tree());
-                        Produce::down(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), WHILE_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::inv_call_iname(Emit::tree(), Hierarchy::find(WORDINPROPERTY_HL));
-                                Produce::down(Emit::tree());
-                                    Produce::inv_call_iname(Emit::tree(), Hierarchy::find(NEXTWORDSTOPPED_HL));
-                                    Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
-                                    Produce::val_iname(Emit::tree(), K_value, RTParsing::name_iname());
-                                Produce::up(Emit::tree());
-                                Produce::code(Emit::tree());
-                                Produce::down(Emit::tree());
-                                    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                                    Produce::down(Emit::tree());
-                                        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
-                                        Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
-                                    Produce::up(Emit::tree());
-                                Produce::up(Emit::tree());
-                            Produce::up(Emit::tree());
-
-                            Produce::inv_primitive(Emit::tree(), POSTDECREMENT_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-                            Produce::up(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::ref_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-                                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-                            Produce::up(Emit::tree());
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-}
-
-

§6.1. Save word number6.1 = -

- -
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_symbol(Emit::tree(), K_value, gprk->original_wn_s);
-        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-    Produce::up(Emit::tree());
-
-
  • This code is used in §6.
-

§6.2. Reset word number6.2 = -

- -
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-        Produce::val_symbol(Emit::tree(), K_value, gprk->original_wn_s);
-    Produce::up(Emit::tree());
-
-
  • This code is used in §6.
-

§7. The head and tail routines can only be understood by knowing that the -following code is used to reset the grammar-line parser after each failure -of a CGL to parse. -

- -
-void UnderstandGeneralTokens::after_gl_failed(gpr_kit *gprk, inter_symbol *label, int pluralised) {
-    if (pluralised) {
-        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-        Produce::down(Emit::tree());
-            Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_ACTION_HL));
-            Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PLURALFOUND_HL));
-        Produce::up(Emit::tree());
-    }
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
-        Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), CONTINUE_BIP);
-
-    Produce::place_label(Emit::tree(), label);
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-        Produce::val_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-    Produce::up(Emit::tree());
-}
-
-

§8. The interesting point about the tail of the parse_name routine is that -it ends on the ] "close routine" character, in mid-source line. This is -because the routine may be being used inside an Object directive, and -would therefore need to be followed by a comma, or in free-standing I6 code, -in which case it would need to be followed by a semi-colon. -

- -
-void UnderstandGeneralTokens::compile_parse_name_tail(gpr_kit *gprk) {
-                    Produce::inv_primitive(Emit::tree(), BREAK_BIP);
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-
-            Produce::inv_primitive(Emit::tree(), WHILE_BIP);
-            Produce::down(Emit::tree());
-                Produce::inv_call_iname(Emit::tree(), Hierarchy::find(WORDINPROPERTY_HL));
-                Produce::down(Emit::tree());
-                    Produce::inv_call_iname(Emit::tree(), Hierarchy::find(NEXTWORDSTOPPED_HL));
-                    Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
-                    Produce::val_iname(Emit::tree(), K_value, RTParsing::name_iname());
-                Produce::up(Emit::tree());
-                Produce::code(Emit::tree());
-                Produce::down(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::ref_symbol(Emit::tree(), K_value, gprk->n_s);
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-
-            Produce::inv_primitive(Emit::tree(), IF_BIP);
-            Produce::down(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), OR_BIP);
-                Produce::down(Emit::tree());
-                    Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
-                    Produce::inv_primitive(Emit::tree(), GT_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_symbol(Emit::tree(), K_value, gprk->n_s);
-                        Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-                Produce::code(Emit::tree());
-                Produce::down(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::ref_symbol(Emit::tree(), K_value, gprk->n_s);
-                        Produce::inv_primitive(Emit::tree(), MINUS_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), PLUS_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_symbol(Emit::tree(), K_value, gprk->n_s);
-                                Produce::val_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-                            Produce::up(Emit::tree());
-                            Produce::val_symbol(Emit::tree(), K_value, gprk->original_wn_s);
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-
-            Produce::inv_primitive(Emit::tree(), IF_BIP);
-            Produce::down(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                Produce::down(Emit::tree());
-                    Produce::val_symbol(Emit::tree(), K_value, gprk->pass_s);
-                    Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
-                Produce::up(Emit::tree());
-                Produce::code(Emit::tree());
-                Produce::down(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::ref_symbol(Emit::tree(), K_value, gprk->pass1_n_s);
-                        Produce::val_symbol(Emit::tree(), K_value, gprk->n_s);
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), IF_BIP);
-            Produce::down(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                Produce::down(Emit::tree());
-                    Produce::val_symbol(Emit::tree(), K_value, gprk->pass_s);
-                    Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 2);
-                Produce::up(Emit::tree());
-                Produce::code(Emit::tree());
-                Produce::down(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::ref_symbol(Emit::tree(), K_value, gprk->pass2_n_s);
-                        Produce::val_symbol(Emit::tree(), K_value, gprk->n_s);
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
-            Produce::down(Emit::tree());
-                Produce::ref_symbol(Emit::tree(), K_value, gprk->pass_s);
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    Produce::up(Emit::tree());
-
-    Produce::inv_primitive(Emit::tree(), IFDEBUG_BIP);
-    Produce::down(Emit::tree());
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), IF_BIP);
-            Produce::down(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), GE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_TRACE_HL));
-                    Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 3);
-                Produce::up(Emit::tree());
-                Produce::code(Emit::tree());
-                Produce::down(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PRINT_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_text(Emit::tree(), I"Pass 1: ");
-                    Produce::up(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PRINTNUMBER_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_symbol(Emit::tree(), K_value, gprk->pass1_n_s);
-                    Produce::up(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PRINT_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_text(Emit::tree(), I" Pass 2: ");
-                    Produce::up(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PRINTNUMBER_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_symbol(Emit::tree(), K_value, gprk->pass2_n_s);
-                    Produce::up(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PRINT_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_text(Emit::tree(), I" Pass 3: ");
-                    Produce::up(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PRINTNUMBER_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_symbol(Emit::tree(), K_value, gprk->n_s);
-                    Produce::up(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PRINT_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_text(Emit::tree(), I"\n");
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    Produce::up(Emit::tree());
-
-    Produce::inv_primitive(Emit::tree(), IF_BIP);
-    Produce::down(Emit::tree());
-        Produce::inv_primitive(Emit::tree(), GT_BIP);
-        Produce::down(Emit::tree());
-            Produce::val_symbol(Emit::tree(), K_value, gprk->pass1_n_s);
-            Produce::val_symbol(Emit::tree(), K_value, gprk->n_s);
-        Produce::up(Emit::tree());
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), STORE_BIP);
-            Produce::down(Emit::tree());
-                Produce::ref_symbol(Emit::tree(), K_value, gprk->n_s);
-                Produce::val_symbol(Emit::tree(), K_value, gprk->pass1_n_s);
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), IF_BIP);
-    Produce::down(Emit::tree());
-        Produce::inv_primitive(Emit::tree(), GT_BIP);
-        Produce::down(Emit::tree());
-            Produce::val_symbol(Emit::tree(), K_value, gprk->pass2_n_s);
-            Produce::val_symbol(Emit::tree(), K_value, gprk->n_s);
-        Produce::up(Emit::tree());
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), STORE_BIP);
-            Produce::down(Emit::tree());
-                Produce::ref_symbol(Emit::tree(), K_value, gprk->n_s);
-                Produce::val_symbol(Emit::tree(), K_value, gprk->pass2_n_s);
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-        Produce::inv_primitive(Emit::tree(), PLUS_BIP);
-        Produce::down(Emit::tree());
-            Produce::val_symbol(Emit::tree(), K_value, gprk->original_wn_s);
-            Produce::val_symbol(Emit::tree(), K_value, gprk->n_s);
-        Produce::up(Emit::tree());
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), IF_BIP);
-    Produce::down(Emit::tree());
-        Produce::inv_primitive(Emit::tree(), EQ_BIP);
-        Produce::down(Emit::tree());
-            Produce::val_symbol(Emit::tree(), K_value, gprk->n_s);
-            Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
-        Produce::up(Emit::tree());
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-            Produce::down(Emit::tree());
-                Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) -1);
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    Produce::up(Emit::tree());
-    Produce::inv_call_iname(Emit::tree(), Hierarchy::find(DETECTPLURALWORD_HL));
-    Produce::down(Emit::tree());
-        Produce::val_symbol(Emit::tree(), K_value, gprk->original_wn_s);
-        Produce::val_symbol(Emit::tree(), K_value, gprk->n_s);
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-    Produce::down(Emit::tree());
-        Produce::val_symbol(Emit::tree(), K_value, gprk->n_s);
-    Produce::up(Emit::tree());
-}
-
-

§9. We generate code suitable for inclusion in a parse_name routine which -either tests distinguishability then parses, or else just parses, the -visible properties of a given subject (which may be a kind or instance). -Sometimes we allow visibility to be inherited from a permission given -to a kind, sometimes we require that the permission be given to this -specific object. -

- -
-void UnderstandGeneralTokens::consider_visible_properties(gpr_kit *gprk, inference_subject *subj,
-    int test_distinguishability) {
-    int phase = 2;
-    if (test_distinguishability) phase = 1;
-    for (; phase<=2; phase++) {
-        property *pr;
-        UnderstandGeneralTokens::start_considering_visible_properties(gprk, phase);
-        LOOP_OVER(pr, property) {
-            if ((Properties::is_either_or(pr)) && (RTProperties::stored_in_negation(pr))) continue;
-            property_permission *pp =
-                PropertyPermissions::find(subj, pr, TRUE);
-            if ((pp) && (Visibility::get_level(pp) > 0))
-                UnderstandGeneralTokens::consider_visible_property(gprk, subj, pr, pp, phase);
-        }
-        UnderstandGeneralTokens::finish_considering_visible_properties(gprk, phase);
-    }
-}
-
-

§10. Common handling for distinguishing and parsing. The top-level considering routines parcel up work and hand it over to -the distinguishing routines if phase is 1, and the parsing routines -if phase is 2. Note that if there are no sometimes-visible-properties -then the correct behaviour is to call none of the routines below this -level, and to compile nothing to the file. -

- -
-int visible_properties_code_written = FALSE;  persistent state used only here
-
-void UnderstandGeneralTokens::start_considering_visible_properties(gpr_kit *gprk, int phase) {
-    visible_properties_code_written = FALSE;
-}
-
-void UnderstandGeneralTokens::consider_visible_property(gpr_kit *gprk, inference_subject *subj,
-    property *pr, property_permission *pp, int phase) {
-    int conditional_vis = FALSE;
-    parse_node *spec;
-
-    if (visible_properties_code_written == FALSE) {
-        visible_properties_code_written = TRUE;
-        if (phase == 1)
-            UnderstandGeneralTokens::begin_distinguishing_visible_properties(gprk);
-        else
-            UnderstandGeneralTokens::begin_parsing_visible_properties(gprk);
-    }
-
-    spec = Visibility::get_condition(pp);
-
-    if (spec) {
-        conditional_vis = TRUE;
-        if (phase == 1)
-            UnderstandGeneralTokens::test_distinguish_visible_property(gprk, spec);
-        else
-            UnderstandGeneralTokens::test_parse_visible_property(gprk, spec);
-    }
-
-    if (phase == 1)
-        UnderstandGeneralTokens::distinguish_visible_property(gprk, pr);
-    else
-        UnderstandGeneralTokens::parse_visible_property(gprk, subj, pr, Visibility::get_level(pp));
-
-    if (conditional_vis) { Produce::up(Emit::tree()); Produce::up(Emit::tree()); }
-}
-
-void UnderstandGeneralTokens::finish_considering_visible_properties(gpr_kit *gprk, int phase) {
-    if (visible_properties_code_written) {
-        if (phase == 1)
-            UnderstandGeneralTokens::finish_distinguishing_visible_properties(gprk);
-        else
-            UnderstandGeneralTokens::finish_parsing_visible_properties(gprk);
-    }
-}
-
-

§11. Distinguishing visible properties. We distinguish two objects P1 and P2 based on the following criteria: -

- -
  • (i) if any property is currently visible for P1 but not P2 or vice versa, -then they are distinguishable; (ii) if any value property is visible -but P1 and P2 have different values for it, then they are distinguishable; -
  • (iii) if any either/or property is visible but P1 has it and P2 hasn't, -or vice versa, then they are distinguishable; and otherwise we revert to -the I6 parser's standard algorithm, which looks at the name property. -
-
-void UnderstandGeneralTokens::begin_distinguishing_visible_properties(gpr_kit *gprk) {
-    Produce::inv_primitive(Emit::tree(), IF_BIP);
-    Produce::down(Emit::tree());
-        Produce::inv_primitive(Emit::tree(), EQ_BIP);
-        Produce::down(Emit::tree());
-            Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_ACTION_HL));
-            Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(THESAME_HL));
-        Produce::up(Emit::tree());
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), IFDEBUG_BIP);
-            Produce::down(Emit::tree());
-                Produce::code(Emit::tree());
-                Produce::down(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), IF_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), GE_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_TRACE_HL));
-                            Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 4);
-                        Produce::up(Emit::tree());
-                        Produce::code(Emit::tree());
-                        Produce::down(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), PRINT_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_text(Emit::tree(), I"p1, p2 = ");
-                            Produce::up(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), PRINTNUMBER_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_ONE_HL));
-                            Produce::up(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), PRINT_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_text(Emit::tree(), I", ");
-                            Produce::up(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), PRINTNUMBER_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_TWO_HL));
-                            Produce::up(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), PRINT_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_text(Emit::tree(), I"\n");
-                            Produce::up(Emit::tree());
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), STORE_BIP);
-            Produce::down(Emit::tree());
-                Produce::ref_symbol(Emit::tree(), K_value, gprk->ss_s);
-                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
-            Produce::up(Emit::tree());
-}
-
-void UnderstandGeneralTokens::test_distinguish_visible_property(gpr_kit *gprk, parse_node *spec) {
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
-        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_ONE_HL));
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
-        Specifications::Compiler::emit_as_val(K_truth_state, spec);
-    Produce::up(Emit::tree());
-
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
-        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_TWO_HL));
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_symbol(Emit::tree(), K_value, gprk->g_s);
-        Specifications::Compiler::emit_as_val(K_truth_state, spec);
-    Produce::up(Emit::tree());
-
-    Produce::inv_primitive(Emit::tree(), IF_BIP);
-    Produce::down(Emit::tree());
-        Produce::inv_primitive(Emit::tree(), NE_BIP);
-        Produce::down(Emit::tree());
-            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
-            Produce::val_symbol(Emit::tree(), K_value, gprk->g_s);
-        Produce::up(Emit::tree());
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-            Return minus two11.1;
-        Produce::up(Emit::tree());
-    Produce::up(Emit::tree());
-
-    Produce::inv_primitive(Emit::tree(), IF_BIP);
-    Produce::down(Emit::tree());
-        Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-}
-
-void UnderstandGeneralTokens::distinguish_visible_property(gpr_kit *gprk, property *prn) {
-    TEMPORARY_TEXT(C)
-    WRITE_TO(C, "Distinguishing property %n", RTProperties::iname(prn));
-    Emit::code_comment(C);
-    DISCARD_TEXT(C)
-
-    if (Properties::is_either_or(prn)) {
-        Produce::inv_primitive(Emit::tree(), IF_BIP);
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), AND_BIP);
-            Produce::down(Emit::tree());
-                RTPropertyValues::emit_iname_has_property(K_value, Hierarchy::find(PARSER_ONE_HL), prn);
-                Produce::inv_primitive(Emit::tree(), NOT_BIP);
-                Produce::down(Emit::tree());
-                    RTPropertyValues::emit_iname_has_property(K_value, Hierarchy::find(PARSER_TWO_HL), prn);
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-            Produce::code(Emit::tree());
-            Produce::down(Emit::tree());
-                Return minus two11.1;
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-
-        Produce::inv_primitive(Emit::tree(), IF_BIP);
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), AND_BIP);
-            Produce::down(Emit::tree());
-                RTPropertyValues::emit_iname_has_property(K_value, Hierarchy::find(PARSER_TWO_HL), prn);
-                Produce::inv_primitive(Emit::tree(), NOT_BIP);
-                Produce::down(Emit::tree());
-                    RTPropertyValues::emit_iname_has_property(K_value, Hierarchy::find(PARSER_ONE_HL), prn);
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-            Produce::code(Emit::tree());
-            Produce::down(Emit::tree());
-                Return minus two11.1;
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    } else {
-        kind *K = ValueProperties::kind(prn);
-        inter_name *distinguisher = Kinds::Behaviour::get_distinguisher_as_iname(K);
-        Produce::inv_primitive(Emit::tree(), IF_BIP);
-        Produce::down(Emit::tree());
-            if (distinguisher) {
-                Produce::inv_call_iname(Emit::tree(), distinguisher);
-                Produce::down(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_ONE_HL));
-                        Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(prn));
-                    Produce::up(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_TWO_HL));
-                        Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(prn));
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-            } else {
-                Produce::inv_primitive(Emit::tree(), NE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_ONE_HL));
-                        Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(prn));
-                    Produce::up(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSER_TWO_HL));
-                        Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(prn));
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-            }
-            Produce::code(Emit::tree());
-            Produce::down(Emit::tree());
-                Return minus two11.1;
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    }
-}
-
-

§11.1. Return minus two11.1 = -

- -
-    Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-    Produce::down(Emit::tree());
-        Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) -2);
-    Produce::up(Emit::tree());
-
-
  • This code is used in §11 (four times).
-

§12.

- -
-void UnderstandGeneralTokens::finish_distinguishing_visible_properties(gpr_kit *gprk) {
-            Produce::inv_primitive(Emit::tree(), STORE_BIP);
-            Produce::down(Emit::tree());
-                Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
-                Produce::val_symbol(Emit::tree(), K_value, gprk->ss_s);
-            Produce::up(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-            Produce::down(Emit::tree());
-                Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    Produce::up(Emit::tree());
-}
-
-

§13. Parsing visible properties. Here, unlike in distinguishing visible properties, it is unambiguous that -self refers to the object being parsed: there is therefore no need to -alter the value of self to make any visibility condition work correctly. -

- -
-void UnderstandGeneralTokens::begin_parsing_visible_properties(gpr_kit *gprk) {
-    Emit::code_comment(I"Match any number of visible property values");
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_symbol(Emit::tree(), K_value, gprk->g_s);
-        Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), WHILE_BIP);
-    Produce::down(Emit::tree());
-        Produce::val_symbol(Emit::tree(), K_value, gprk->g_s);
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), STORE_BIP);
-            Produce::down(Emit::tree());
-                Produce::ref_symbol(Emit::tree(), K_value, gprk->g_s);
-                Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
-            Produce::up(Emit::tree());
-}
-
-void UnderstandGeneralTokens::test_parse_visible_property(gpr_kit *gprk, parse_node *spec) {
-    Produce::inv_primitive(Emit::tree(), IF_BIP);
-    Produce::down(Emit::tree());
-        Specifications::Compiler::emit_as_val(K_truth_state, spec);
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-}
-
-int unique_pvp_counter = 0;
-void UnderstandGeneralTokens::parse_visible_property(gpr_kit *gprk,
-    inference_subject *subj, property *prn, int visibility_level) {
-    TEMPORARY_TEXT(C)
-    WRITE_TO(C, "Parsing property %n", RTProperties::iname(prn));
-    Emit::code_comment(C);
-    DISCARD_TEXT(C)
-
-    if (Properties::is_either_or(prn)) {
-        TEMPORARY_TEXT(L)
-        WRITE_TO(L, ".pvp_pass_L_%d", unique_pvp_counter++);
-        inter_symbol *pass_label = Produce::reserve_label(Emit::tree(), L);
-        DISCARD_TEXT(L)
-
-        UnderstandGeneralTokens::parse_visible_either_or(
-            gprk, prn, visibility_level, pass_label);
-        property *prnbar = EitherOrProperties::get_negation(prn);
-        if (prnbar)
-            UnderstandGeneralTokens::parse_visible_either_or(
-                gprk, prnbar, visibility_level, pass_label);
-
-        Produce::place_label(Emit::tree(), pass_label);
-    } else {
-        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-        Produce::down(Emit::tree());
-            Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-            Produce::val_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-        Produce::up(Emit::tree());
-
-        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-        Produce::down(Emit::tree());
-            Produce::ref_symbol(Emit::tree(), K_value, gprk->spn_s);
-            Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSED_NUMBER_HL));
-        Produce::up(Emit::tree());
-        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-        Produce::down(Emit::tree());
-            Produce::ref_symbol(Emit::tree(), K_value, gprk->ss_s);
-            Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(ETYPE_HL));
-        Produce::up(Emit::tree());
-
-        Produce::inv_primitive(Emit::tree(), IF_BIP);
-        Produce::down(Emit::tree());
-            kind *K = ValueProperties::kind(prn);
-            inter_name *recog_gpr = Kinds::Behaviour::get_recognition_only_GPR_as_iname(K);
-            if (recog_gpr) {
-                Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                Produce::down(Emit::tree());
-                    Produce::inv_call_iname(Emit::tree(), recog_gpr);
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
-                            Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(prn));
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-                    Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_PREPOSITION_HL));
-                Produce::up(Emit::tree());
-            } else if (Kinds::Behaviour::offers_I6_GPR(K)) {
-                inter_name *i6_gpr_name = Kinds::Behaviour::get_explicit_I6_GPR_iname(K);
-                if (i6_gpr_name) {
-                    Produce::inv_primitive(Emit::tree(), AND_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::inv_call_iname(Emit::tree(), i6_gpr_name);
-                            Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_NUMBER_HL));
-                        Produce::up(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
-                                Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(prn));
-                            Produce::up(Emit::tree());
-                            Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSED_NUMBER_HL));
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-                } else if (Kinds::Behaviour::is_an_enumeration(K)) {
-                    Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::inv_call_iname(Emit::tree(), RTKinds::get_instance_GPR_iname(K));
-                        Produce::down(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
-                                Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(prn));
-                            Produce::up(Emit::tree());
-                        Produce::up(Emit::tree());
-                        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_NUMBER_HL));
-                    Produce::up(Emit::tree());
-                } else {
-                    Produce::inv_primitive(Emit::tree(), AND_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::inv_call_iname(Emit::tree(), RTKinds::get_kind_GPR_iname(K));
-                            Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_NUMBER_HL));
-                        Produce::up(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
-                                Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(prn));
-                            Produce::up(Emit::tree());
-                            Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(PARSED_NUMBER_HL));
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-                }
-            } else internal_error("Unable to recognise kind of value in parsing");
-            Produce::code(Emit::tree());
-            Produce::down(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::ref_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-                    Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-                Produce::up(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::ref_symbol(Emit::tree(), K_value, gprk->g_s);
-                    Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
-                Produce::up(Emit::tree());
-                if (visibility_level == 2) {
-                    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
-                        Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
-                    Produce::up(Emit::tree());
-                }
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-
-        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-        Produce::down(Emit::tree());
-            Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(PARSED_NUMBER_HL));
-            Produce::val_symbol(Emit::tree(), K_value, gprk->spn_s);
-        Produce::up(Emit::tree());
-        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-        Produce::down(Emit::tree());
-            Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(ETYPE_HL));
-            Produce::val_symbol(Emit::tree(), K_value, gprk->ss_s);
-        Produce::up(Emit::tree());
-    }
-}
-
-void UnderstandGeneralTokens::parse_visible_either_or(gpr_kit *gprk, property *prn, int visibility_level,
-    inter_symbol *pass_l) {
-    command_grammar *cg = EitherOrProperties::get_parsing_grammar(prn);
-    UnderstandGeneralTokens::pvp_test_begins_dash(gprk);
-    Produce::inv_primitive(Emit::tree(), IF_BIP);
-    Produce::down(Emit::tree());
-        wording W = prn->name;
-        int j = 0; LOOP_THROUGH_WORDING(i, W) j++;
-        int ands = 0;
-        if (j > 0) { Produce::inv_primitive(Emit::tree(), AND_BIP); Produce::down(Emit::tree()); ands++; }
-        RTPropertyValues::emit_iname_has_property(K_value, Hierarchy::find(SELF_HL), prn);
-        int k = 0;
-        LOOP_THROUGH_WORDING(i, W) {
-            if (k < j-1) { Produce::inv_primitive(Emit::tree(), AND_BIP); Produce::down(Emit::tree()); ands++; }
-            Produce::inv_primitive(Emit::tree(), EQ_BIP);
-            Produce::down(Emit::tree());
-                Produce::inv_call_iname(Emit::tree(), Hierarchy::find(NEXTWORDSTOPPED_HL));
-                TEMPORARY_TEXT(N)
-                WRITE_TO(N, "%N", i);
-                Produce::val_dword(Emit::tree(), N);
-                DISCARD_TEXT(N)
-            Produce::up(Emit::tree());
-            k++;
-        }
-
-        for (int a=0; a<ands; a++) Produce::up(Emit::tree());
-        Produce::code(Emit::tree());
-        Produce::down(Emit::tree());
-            UnderstandGeneralTokens::pvp_test_passes_dash(gprk, visibility_level, pass_l);
-        Produce::up(Emit::tree());
-    Produce::up(Emit::tree());
-    if (cg) {
-        if (cg->compilation_data.cg_prn_iname == NULL) internal_error("no PRN iname");
-        UnderstandGeneralTokens::pvp_test_begins_dash(gprk);
-        Produce::inv_primitive(Emit::tree(), IF_BIP);
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), AND_BIP);
-            Produce::down(Emit::tree());
-                RTPropertyValues::emit_iname_has_property(K_value, Hierarchy::find(SELF_HL), prn);
-                Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                Produce::down(Emit::tree());
-                    Produce::inv_call_iname(Emit::tree(), cg->compilation_data.cg_prn_iname);
-                    Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_PREPOSITION_HL));
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-            Produce::code(Emit::tree());
-            Produce::down(Emit::tree());
-                UnderstandGeneralTokens::pvp_test_passes_dash(gprk, visibility_level, pass_l);
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    }
-}
-
-void UnderstandGeneralTokens::pvp_test_begins_dash(gpr_kit *gprk) {
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-        Produce::val_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-    Produce::up(Emit::tree());
-}
-
-void UnderstandGeneralTokens::pvp_test_passes_dash(gpr_kit *gprk, int visibility_level, inter_symbol *pass_l) {
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-    Produce::up(Emit::tree());
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_symbol(Emit::tree(), K_value, gprk->g_s);
-        Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
-    Produce::up(Emit::tree());
-    if (visibility_level == 2) {
-        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-        Produce::down(Emit::tree());
-            Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
-            Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
-        Produce::up(Emit::tree());
-    }
-    if (pass_l) {
-        Produce::inv_primitive(Emit::tree(), JUMP_BIP);
-        Produce::down(Emit::tree());
-            Produce::lab(Emit::tree(), pass_l);
-        Produce::up(Emit::tree());
-    }
-}
-
-void UnderstandGeneralTokens::finish_parsing_visible_properties(gpr_kit *gprk) {
-        Produce::up(Emit::tree());
-    Produce::up(Emit::tree());
-    Emit::code_comment(I"try_from_wn is now advanced past any visible property values");
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-        Produce::val_symbol(Emit::tree(), K_value, gprk->try_from_wn_s);
-    Produce::up(Emit::tree());
-}
-
- - -
- - - diff --git a/docs/if-module/5-nft.html b/docs/if-module/5-nft.html deleted file mode 100644 index c1eeddf23..000000000 --- a/docs/if-module/5-nft.html +++ /dev/null @@ -1,393 +0,0 @@ - - - - Noun Filter Tokens - - - - - - - - - - - - - - - - - - -
- - -

Filters are used to require nouns to have specific kinds or attributes, or to have specific scoping rules: they correspond to Inform 6's |noun=Routine| and |scope=Routine| tokens. Though these are quite different concepts in I6, their common handling seems natural in I7.

- -
- -

§1. Definitions.

- -
-typedef struct noun_filter_token {
-    struct parse_node *the_filter;
-    struct parse_node *nft_created_at;
-    int global_scope_flag;
-    int any_things_flag;
-    int parse_using_gpr;
-    int nft_compiled;
-    struct inter_name *nft_iname;
-    CLASS_DEFINITION
-} noun_filter_token;
-
-
  • The structure noun_filter_token is private to this section.
-

§2. There are only three things we can do with these: create them, compile -their names (used as I6 tokens), and compile their routines. -

- -
-noun_filter_token *UnderstandFilterTokens::nft_new(parse_node *spec, int global_scope, int any_things) {
-    pcalc_prop *prop = Specifications::to_proposition(spec);
-    if ((prop) && (Binding::number_free(prop) != 1)) {
-        LOG("So $P and $D\n", spec, prop);
-        StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_FilterQuantified),
-            "the [any ...] doesn't clearly give a description in the '...' part",
-            "where I was expecting something like '[any vehicle]'.");
-        spec = Specifications::from_kind(K_object);
-    }
-
-    noun_filter_token *nft = CREATE(noun_filter_token);
-    nft->the_filter = spec;
-    nft->global_scope_flag = global_scope;
-    nft->any_things_flag = any_things;
-    nft->nft_created_at = current_sentence;
-    nft->parse_using_gpr = FALSE;
-    nft->nft_compiled = FALSE;
-
-    if (global_scope) {
-        package_request *PR = Hierarchy::local_package(SCOPE_FILTERS_HAP);
-        nft->nft_iname = Hierarchy::make_iname_in(SCOPE_FILTER_FN_HL, PR);
-    } else {
-        package_request *PR = Hierarchy::local_package(NOUN_FILTERS_HAP);
-        nft->nft_iname = Hierarchy::make_iname_in(NOUN_FILTER_FN_HL, PR);
-    }
-    return nft;
-}
-
-inter_name *UnderstandFilterTokens::nft_compile_routine_iname(noun_filter_token *nft) {
-    return nft->nft_iname;
-}
-
-void UnderstandFilterTokens::nft_compile_routine(noun_filter_token *nft) {
-    parse_node *noun_var = Lvalues::new_actual_NONLOCAL_VARIABLE(Inter_noun_VAR);
-    kind *R = Specifications::to_kind(nft->the_filter);
-    kind *K = NonlocalVariables::kind(Inter_noun_VAR);
-    NonlocalVariables::set_kind(Inter_noun_VAR, R);
-    if (Kinds::Behaviour::is_object(R) == FALSE) nft->parse_using_gpr = TRUE;
-
-    packaging_state save = Routines::begin(nft->nft_iname);
-    if (nft->parse_using_gpr) {
-        inter_symbol *v_s = LocalVariables::add_internal_local_c_as_symbol(I"v", "value parsed");
-        inter_symbol *n_s = LocalVariables::add_internal_local_c_as_symbol(I"n", "saved value of noun");
-
-        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-        Produce::down(Emit::tree());
-            Produce::ref_symbol(Emit::tree(), K_value, v_s);
-            inter_name *gpr_to_ask = Kinds::Behaviour::get_explicit_I6_GPR_iname(R);
-            if (gpr_to_ask == NULL) gpr_to_ask = RTKinds::get_kind_GPR_iname(R);
-            Produce::inv_call_iname(Emit::tree(), gpr_to_ask);
-        Produce::up(Emit::tree());
-
-        Produce::inv_primitive(Emit::tree(), IF_BIP);
-        Produce::down(Emit::tree());
-            Produce::inv_primitive(Emit::tree(), EQ_BIP);
-            Produce::down(Emit::tree());
-                Produce::val_symbol(Emit::tree(), K_value, v_s);
-                Produce::val_iname(Emit::tree(), K_object, Hierarchy::find(GPR_NUMBER_HL));
-            Produce::up(Emit::tree());
-            Produce::code(Emit::tree());
-            Produce::down(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::ref_symbol(Emit::tree(), K_value, n_s);
-                    Produce::val_iname(Emit::tree(), K_object, Hierarchy::find(NOUN_HL));
-                Produce::up(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::ref_iname(Emit::tree(), K_object, Hierarchy::find(NOUN_HL));
-                    Produce::val_iname(Emit::tree(), K_object, Hierarchy::find(PARSED_NUMBER_HL));
-                Produce::up(Emit::tree());
-
-                Produce::inv_primitive(Emit::tree(), IF_BIP);
-                Produce::down(Emit::tree());
-                    Produce::inv_primitive(Emit::tree(), NOT_BIP);
-                    Produce::down(Emit::tree());
-                        Calculus::Deferrals::emit_test_if_var_matches_description(noun_var, nft->the_filter);
-                    Produce::up(Emit::tree());
-                    Produce::code(Emit::tree());
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::ref_symbol(Emit::tree(), K_value, v_s);
-                            Produce::val_iname(Emit::tree(), K_object, Hierarchy::find(GPR_FAIL_HL));
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-
-                Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::ref_iname(Emit::tree(), K_object, Hierarchy::find(NOUN_HL));
-                    Produce::val_symbol(Emit::tree(), K_value, n_s);
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-
-        Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-        Produce::down(Emit::tree());
-            Produce::val_symbol(Emit::tree(), K_value, v_s);
-        Produce::up(Emit::tree());
-    } else if (nft->global_scope_flag) {
-        inter_symbol *obj_s = LocalVariables::add_internal_local_c_as_symbol(I"obj", "object loop variable");
-        inter_symbol *o2_s = LocalVariables::add_internal_local_c_as_symbol(I"o2", "saved value of noun");
-
-        Produce::inv_primitive(Emit::tree(), SWITCH_BIP);
-        Produce::down(Emit::tree());
-            Produce::val_iname(Emit::tree(), K_object, Hierarchy::find(SCOPE_STAGE_HL));
-            Produce::code(Emit::tree());
-            Produce::down(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), CASE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
-                    Produce::code(Emit::tree());
-                    Produce::down(Emit::tree());
-                        if (nft->any_things_flag) Produce::rtrue(Emit::tree());
-                        else Produce::rfalse(Emit::tree());
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), CASE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 2);
-                    Produce::code(Emit::tree());
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::ref_symbol(Emit::tree(), K_value, obj_s);
-                            Produce::val_iname(Emit::tree(), K_object, Hierarchy::find(NOUN_HL));
-                        Produce::up(Emit::tree());
-
-                        Produce::inv_primitive(Emit::tree(), OBJECTLOOP_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::ref_iname(Emit::tree(), K_object, Hierarchy::find(NOUN_HL));
-                            Produce::val_iname(Emit::tree(), K_value, RTKinds::I6_classname(K_object));
-                            Calculus::Deferrals::emit_test_if_var_matches_description(noun_var, nft->the_filter);
-
-                            Produce::code(Emit::tree());
-                            Produce::down(Emit::tree());
-                                Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                                Produce::down(Emit::tree());
-                                    Produce::ref_symbol(Emit::tree(), K_value, o2_s);
-                                    Produce::val_iname(Emit::tree(), K_object, Hierarchy::find(NOUN_HL));
-                                Produce::up(Emit::tree());
-                                Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                                Produce::down(Emit::tree());
-                                    Produce::ref_iname(Emit::tree(), K_object, Hierarchy::find(NOUN_HL));
-                                    Produce::val_symbol(Emit::tree(), K_value, obj_s);
-                                Produce::up(Emit::tree());
-
-                                Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                                Produce::down(Emit::tree());
-                                    Produce::ref_iname(Emit::tree(), K_object, Hierarchy::find(SUPPRESS_SCOPE_LOOPS_HL));
-                                    Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
-                                Produce::up(Emit::tree());
-
-                                Produce::inv_call_iname(Emit::tree(), Hierarchy::find(PLACEINSCOPE_HL));
-                                Produce::down(Emit::tree());
-                                    Produce::val_symbol(Emit::tree(), K_value, o2_s);
-                                    Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
-                                Produce::up(Emit::tree());
-
-                                Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                                Produce::down(Emit::tree());
-                                    Produce::ref_iname(Emit::tree(), K_object, Hierarchy::find(SUPPRESS_SCOPE_LOOPS_HL));
-                                    Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
-                                Produce::up(Emit::tree());
-
-                                Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                                Produce::down(Emit::tree());
-                                    Produce::ref_iname(Emit::tree(), K_object, Hierarchy::find(NOUN_HL));
-                                    Produce::val_symbol(Emit::tree(), K_value, o2_s);
-                                Produce::up(Emit::tree());
-                            Produce::up(Emit::tree());
-                        Produce::up(Emit::tree());
-
-                        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::ref_iname(Emit::tree(), K_object, Hierarchy::find(NOUN_HL));
-                            Produce::val_symbol(Emit::tree(), K_value, obj_s);
-                        Produce::up(Emit::tree());
-
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), CASE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 3);
-                    Produce::code(Emit::tree());
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::ref_iname(Emit::tree(), K_object, Hierarchy::find(NEXTBEST_ETYPE_HL));
-                            Produce::val_iname(Emit::tree(), K_object, Hierarchy::find(NOTINCONTEXTPE_HL));
-                        Produce::up(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) (-1));
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-                Produce::up(Emit::tree());
-            Produce::up(Emit::tree());
-        Produce::up(Emit::tree());
-    } else {
-        inter_symbol *x_s = LocalVariables::add_internal_local_c_as_symbol(I"x", "saved value of noun");
-        Produce::inv_primitive(Emit::tree(), STORE_BIP);
-        Produce::down(Emit::tree());
-            Produce::ref_symbol(Emit::tree(), K_value, x_s);
-            Produce::val_iname(Emit::tree(), K_object, Hierarchy::find(NOUN_HL));
-        Produce::up(Emit::tree());
-
-        Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-        Produce::down(Emit::tree());
-            if (Specifications::to_proposition(nft->the_filter)) {
-                Propositions::Checker::type_check(Specifications::to_proposition(nft->the_filter), Propositions::Checker::tc_no_problem_reporting());
-                Calculus::Deferrals::emit_test_of_proposition(
-                    noun_var, Specifications::to_proposition(nft->the_filter));
-            } else
-                Calculus::Deferrals::emit_test_if_var_matches_description(noun_var, nft->the_filter);
-        Produce::up(Emit::tree());
-    }
-    Routines::end(save);
-    NonlocalVariables::set_kind(Inter_noun_VAR, K);
-}
-
-

§3. Access via ID. For now, though, these are perhaps strangely accessed by ID number. (Because -the parse_node structure can't conveniently be annotated with pointers, -that's why.) -

- -
-int too_late_for_further_NFTs = FALSE;
-
-int UnderstandFilterTokens::new_id(parse_node *spec, int global_scope, int any_things) {
-    if (too_late_for_further_NFTs)
-        StandardProblems::sentence_problem(Task::syntax_tree(), _p_(BelievedImpossible),
-            "complicated instructions on understanding the player's command "
-            "are not allowed in the past tense",
-            "for instance by being applied to several previous turns in a row.");
-
-    kind *K = Specifications::to_kind(spec);
-    if ((Kinds::Behaviour::is_object(K) == FALSE) && (Kinds::Behaviour::request_I6_GPR(K) == FALSE) && (global_scope))
-        StandardProblems::sentence_problem(Task::syntax_tree(), _p_(BelievedImpossible),
-            "this is a kind of value I can't understand in command grammar",
-            "so the '[any ...]' part will have to go.");
-
-    return UnderstandFilterTokens::nft_new(spec, global_scope, any_things)->allocation_id;
-}
-
-void UnderstandFilterTokens::compile_id(int id) {
-    noun_filter_token *nft;
-    LOOP_OVER(nft, noun_filter_token)
-        if (nft->allocation_id == id) {
-            if (nft->parse_using_gpr) Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_TT_HL));
-            else if (nft->global_scope_flag) Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SCOPE_TT_HL));
-            else Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(ROUTINEFILTER_TT_HL));
-            Produce::val_iname(Emit::tree(), K_value, nft->nft_iname);
-        }
-}
-
-void UnderstandFilterTokens::emit_id(int id) {
-    noun_filter_token *nft;
-    LOOP_OVER(nft, noun_filter_token)
-        if (nft->allocation_id == id) {
-            inter_ti annot = 0;
-            if (nft->parse_using_gpr == FALSE) {
-                if (nft->global_scope_flag) annot = SCOPE_FILTER_IANN;
-                else annot = NOUN_FILTER_IANN;
-            }
-            inter_name *iname = UnderstandFilterTokens::nft_compile_routine_iname(nft);
-            if (annot != 0)
-                if (Produce::read_annotation(iname, annot) != 1)
-                    Produce::annotate_i(iname, annot, 1);
-            Emit::array_iname_entry(iname);
-        }
-}
-
-

§4. Compiling everything. Having referred to these filter routines, we need to compile them. -

- -
-void UnderstandFilterTokens::compile(void) {
-    noun_filter_token *nft;
-    LOOP_OVER(nft, noun_filter_token)
-        if (nft->nft_compiled == FALSE) {
-            current_sentence = nft->nft_created_at;
-            UnderstandFilterTokens::nft_compile_routine(nft);
-            nft->nft_compiled = TRUE;
-        }
-     too_late_for_further_NFTs = TRUE;
-}
-
- - -
- - - diff --git a/docs/if-module/5-pp.html b/docs/if-module/5-pp.html index 9b32f5dfb..284de6f91 100644 --- a/docs/if-module/5-pp.html +++ b/docs/if-module/5-pp.html @@ -92,7 +92,7 @@ chapter. PluginManager::plug(COMPARE_CONSTANT_PLUG, ParsingPlugin::compare_CONSTANT); PluginManager::plug(NEW_VARIABLE_NOTIFY_PLUG, ParsingPlugin::new_variable_notify); PluginManager::plug(NEW_SUBJECT_NOTIFY_PLUG, ParsingPlugin::new_subject_notify); - PluginManager::plug(NEW_PERMISSION_NOTIFY_PLUG, Visibility::new_permission_notify); + PluginManager::plug(NEW_PERMISSION_NOTIFY_PLUG, Visibility::new_permission_notify); PluginManager::plug(COMPLETE_MODEL_PLUG, ParsingPlugin::complete_model); }
@@ -107,14 +107,14 @@ for generating that is a little delicate. BENCH(Understand::traverse); } if (stage == INTER2_CSEQ) { - BENCH(UnderstandGeneralTokens::write_parse_name_routines); + BENCH(UnderstandGeneralTokens::write_parse_name_routines); BENCH(RTCommandGrammarLines::MistakeActionSub_routine); BENCH(CommandGrammars::prepare); BENCH(RTCommandGrammars::compile_conditions); - BENCH(UnderstandValueTokens::number); - BENCH(UnderstandValueTokens::truth_state); - BENCH(UnderstandValueTokens::time); - BENCH(UnderstandValueTokens::compile_type_gprs); + BENCH(UnderstandValueTokens::number); + BENCH(UnderstandValueTokens::truth_state); + BENCH(UnderstandValueTokens::time); + BENCH(UnderstandValueTokens::compile_type_gprs); if (debugging) { BENCH(TestCommand::write_text); BENCH(TestCommand::TestScriptSub_routine); @@ -123,11 +123,11 @@ for generating that is a little delicate. } } if (stage == INTER3_CSEQ) { - BENCH(UnderstandFilterTokens::compile); + BENCH(UnderstandFilterTokens::compile); } if (stage == INTER4_CSEQ) { BENCH(RTCommandGrammars::compile_all); - BENCH(UnderstandFilterTokens::compile); + BENCH(UnderstandFilterTokens::compile); } return FALSE; } @@ -145,12 +145,18 @@ and in particular, to every object instance and every kind of object. CLASS_DEFINITION } parsing_data; +parsing_data *ParsingPlugin::new_data(inference_subject *subj) { + parsing_data *pd = CREATE(parsing_data); + pd->understand_as_this_object = NULL; + return pd; +} + int ParsingPlugin::new_subject_notify(inference_subject *subj) { - ATTACH_PLUGIN_DATA_TO_SUBJECT(parsing, subj, Visibility::new_data(subj)); + ATTACH_PLUGIN_DATA_TO_SUBJECT(parsing, subj, ParsingPlugin::new_data(subj)); return FALSE; }
-
  • The structure parsing_data is accessed in 5/cg, 5/gp, 5/gpr.
+
  • The structure parsing_data is accessed in 5/cg and here.

§4. We make use of a new kind of rvalue in this plugin: K_understanding. This is created in Familiar Kinds (in kinds), not here, but we do have to provide the following functions to handle its constant rvalues. These correspond to @@ -170,9 +176,9 @@ the following functions to handle its constant rvalues. These correspond to return FALSE; } -parse_node *ParsingPlugin::rvalue_from_command_grammar(command_grammar *val) { +parse_node *ParsingPlugin::rvalue_from_command_grammar(command_grammar *val) { CONV_FROM(command_grammar, K_understanding) } -command_grammar *ParsingPlugin::rvalue_to_command_grammar(parse_node *spec) { +command_grammar *ParsingPlugin::rvalue_to_command_grammar(parse_node *spec) { CONV_TO(command_grammar) }

§5. A number of global variables are given special treatment by this plugin, @@ -206,7 +212,7 @@ the Inter command parser at runtime, whose data is typeless.

§7.

-int ParsingPlugin::new_variable_notify(nonlocal_variable *var) {
+int ParsingPlugin::new_variable_notify(nonlocal_variable *var) {
     if (<notable-parsing-variables>(var->name)) {
         switch (<<r>>) {
             case 0:
@@ -233,7 +239,7 @@ and is in that sense (okay, ironically) "nameless".
 
 property *P_name = NULL;
 
-property *ParsingPlugin::name_property(void) {
+property *ParsingPlugin::name_property(void) {
     if (P_name == NULL) {
         P_name = ValueProperties::new_nameless(I"name", K_text);
         Hierarchy::make_available(Emit::tree(), RTParsing::name_iname());
@@ -248,10 +254,10 @@ get the name pr
 

-int ParsingPlugin::complete_model(int stage) {
+int ParsingPlugin::complete_model(int stage) {
     if (stage == WORLD_STAGE_V) {
         instance *I;
-        P_parse_name = ValueProperties::new_nameless(I"parse_name", K_value);
+        property *P_parse_name = ValueProperties::new_nameless(I"parse_name", K_value);
 
         LOOP_OVER_INSTANCES(I, K_object) {
             inference_subject *subj = Instances::as_subject(I);
@@ -302,7 +308,7 @@ where grammar has specified a need. (By default, this will not happen.)
 

-    inter_name *S = UnderstandGeneralTokens::compile_parse_name_property(subj);
+    inter_name *S = UnderstandGeneralTokens::compile_parse_name_property(subj);
     if (S)
         ValueProperties::assert(P_parse_name, subj,
             Rvalues::from_iname(S), CERTAIN_CE);
@@ -321,7 +327,7 @@ where grammar has specified a need. (By default, this will not happen.)
 
 MAKE_ANNOTATION_FUNCTIONS(constant_command_grammar, command_grammar)
 
-void ParsingPlugin::nodes_and_annotations(void) {
+void ParsingPlugin::nodes_and_annotations(void) {
     Annotations::declare_type(constant_command_grammar_ANNOT,
         ParsingPlugin::write_constant_grammar_verb_ANNOT);
 
@@ -335,7 +341,7 @@ where grammar has specified a need. (By default, this will not happen.)
 }
 
diff --git a/docs/if-module/5-tpv.html b/docs/if-module/5-tpv.html deleted file mode 100644 index 873e63443..000000000 --- a/docs/if-module/5-tpv.html +++ /dev/null @@ -1,393 +0,0 @@ - - - - Tokens Parsing Values - - - - - - - - - - - - - - - - - - -
- - -

In the argot of Inform 6, GPR stands for General Parsing Routine, and I7 makes heavy use of GPR tokens to achieve its ends. This section is where the necessary I6 routines are compiled.

- -

§1.

- -
-typedef struct gpr_kit {
-    inter_symbol *cur_addr_s;
-    inter_symbol *cur_len_s;
-    inter_symbol *cur_word_s;
-    inter_symbol *f_s;
-    inter_symbol *g_s;
-    inter_symbol *group_wn_s;
-    inter_symbol *instance_s;
-    inter_symbol *matched_number_s;
-    inter_symbol *mid_word_s;
-    inter_symbol *n_s;
-    inter_symbol *original_wn_s;
-    inter_symbol *pass_s;
-    inter_symbol *pass1_n_s;
-    inter_symbol *pass2_n_s;
-    inter_symbol *range_from_s;
-    inter_symbol *range_words_s;
-    inter_symbol *rv_s;
-    local_variable *rv_lv;
-    inter_symbol *sgn_s;
-    inter_symbol *spn_s;
-    inter_symbol *ss_s;
-    inter_symbol *tot_s;
-    inter_symbol *try_from_wn_s;
-    inter_symbol *v_s;
-    inter_symbol *w_s;
-    inter_symbol *wpos_s;
-    inter_symbol *x_s;
-} gpr_kit;
-
-gpr_kit UnderstandValueTokens::new_kit(void) {
-    gpr_kit gprk;
-    gprk.cur_addr_s = NULL;
-    gprk.cur_len_s = NULL;
-    gprk.cur_word_s = NULL;
-    gprk.f_s = NULL;
-    gprk.g_s = NULL;
-    gprk.group_wn_s = NULL;
-    gprk.instance_s = NULL;
-    gprk.matched_number_s = NULL;
-    gprk.mid_word_s = NULL;
-    gprk.n_s = NULL;
-    gprk.original_wn_s = NULL;
-    gprk.pass_s = NULL;
-    gprk.pass1_n_s = NULL;
-    gprk.pass2_n_s = NULL;
-    gprk.range_from_s = NULL;
-    gprk.range_words_s = NULL;
-    gprk.rv_s = NULL;
-    gprk.rv_lv = NULL;
-    gprk.sgn_s = NULL;
-    gprk.spn_s = NULL;
-    gprk.ss_s = NULL;
-    gprk.tot_s = NULL;
-    gprk.try_from_wn_s = NULL;
-    gprk.v_s = NULL;
-    gprk.w_s = NULL;
-    gprk.wpos_s = NULL;
-    gprk.x_s = NULL;
-    return gprk;
-}
-
-void UnderstandValueTokens::add_instance_call(gpr_kit *gprk) {
-    gprk->instance_s = LocalVariables::add_named_call_as_symbol(I"instance");
-}
-
-void UnderstandValueTokens::add_range_calls(gpr_kit *gprk) {
-    gprk->range_from_s = LocalVariables::add_internal_local_c_as_symbol(I"range_from", "call parameter: word number of snippet start");
-    gprk->range_words_s = LocalVariables::add_internal_local_c_as_symbol(I"range_words", "call parameter: snippet length");
-}
-
-void UnderstandValueTokens::add_original(gpr_kit *gprk) {
-    gprk->original_wn_s = LocalVariables::add_internal_local_as_symbol(I"original_wn");
-}
-
-void UnderstandValueTokens::add_standard_set(gpr_kit *gprk) {
-    gprk->group_wn_s = LocalVariables::add_internal_local_as_symbol(I"group_wn");
-    gprk->v_s = LocalVariables::add_internal_local_as_symbol(I"v");
-    gprk->w_s = LocalVariables::add_internal_local_as_symbol(I"w");
-    gprk->rv_s = LocalVariables::add_internal_local_as_symbol_noting(I"rv", &(gprk->rv_lv));
-}
-
-void UnderstandValueTokens::add_lp_vars(gpr_kit *gprk) {
-    gprk->wpos_s = LocalVariables::add_internal_local_as_symbol(I"wpos");
-    gprk->mid_word_s = LocalVariables::add_internal_local_as_symbol(I"mid_word");
-    gprk->matched_number_s = LocalVariables::add_internal_local_as_symbol(I"matched_number");
-    gprk->cur_word_s = LocalVariables::add_internal_local_as_symbol(I"cur_word");
-    gprk->cur_len_s = LocalVariables::add_internal_local_as_symbol(I"cur_len");
-    gprk->cur_addr_s = LocalVariables::add_internal_local_as_symbol(I"cur_addr");
-    gprk->sgn_s = LocalVariables::add_internal_local_as_symbol(I"sgn");
-    gprk->tot_s = LocalVariables::add_internal_local_as_symbol(I"tot");
-    gprk->f_s = LocalVariables::add_internal_local_as_symbol(I"f");
-    gprk->x_s = LocalVariables::add_internal_local_as_symbol(I"x");
-}
-
-void UnderstandValueTokens::add_parse_name_vars(gpr_kit *gprk) {
-    gprk->original_wn_s = LocalVariables::add_internal_local_c_as_symbol(I"original_wn", "first word of text parsed");
-    gprk->group_wn_s = LocalVariables::add_internal_local_c_as_symbol(I"group_wn", "first word matched against A/B/C/... disjunction");
-    gprk->try_from_wn_s = LocalVariables::add_internal_local_c_as_symbol(I"try_from_wn", "position to try matching from");
-    gprk->n_s = LocalVariables::add_internal_local_c_as_symbol(I"n", "number of words matched");
-    gprk->f_s = LocalVariables::add_internal_local_c_as_symbol(I"f", "flag: sufficiently good match found to justify success");
-    gprk->w_s = LocalVariables::add_internal_local_c_as_symbol(I"w", "for use by individual grammar lines");
-    gprk->rv_s = LocalVariables::add_internal_local_as_symbol_noting(I"rv", &(gprk->rv_lv));
-    gprk->g_s = LocalVariables::add_internal_local_c_as_symbol(I"g", "temporary: success flag for parsing visibles");
-    gprk->ss_s = LocalVariables::add_internal_local_c_as_symbol(I"ss", "temporary: saves 'self' in distinguishing visibles");
-    gprk->spn_s = LocalVariables::add_internal_local_c_as_symbol(I"spn", "temporary: saves 'parsed_number' in parsing visibles");
-    gprk->pass_s = LocalVariables::add_internal_local_c_as_symbol(I"pass", "pass counter (1 to 3)");
-    gprk->pass1_n_s = LocalVariables::add_internal_local_c_as_symbol(I"pass1_n", "value of n recorded during pass 1");
-    gprk->pass2_n_s = LocalVariables::add_internal_local_c_as_symbol(I"pass2_n", "value of n recorded during pass 2");
-}
-
-void UnderstandValueTokens::number(void) {
-    inter_name *iname = Hierarchy::find(DECIMAL_TOKEN_INNER_HL);
-    packaging_state save = Routines::begin(iname);
-    gpr_kit gprk = UnderstandValueTokens::new_kit();
-    UnderstandValueTokens::add_original(&gprk);
-    command_grammar *cg = CommandGrammars::get_parsing_grammar(K_number);
-    if (cg) RTCommandGrammars::compile_iv(&gprk, cg);
-    Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-    Produce::down(Emit::tree());
-        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_FAIL_HL));
-    Produce::up(Emit::tree());
-    Routines::end(save);
-    Hierarchy::make_available(Emit::tree(), iname);
-}
-
-void UnderstandValueTokens::time(void) {
-    inter_name *iname = Hierarchy::find(TIME_TOKEN_INNER_HL);
-    packaging_state save = Routines::begin(iname);
-    gpr_kit gprk = UnderstandValueTokens::new_kit();
-    UnderstandValueTokens::add_original(&gprk);
-    kind *K = TimesOfDay::kind();
-    if (K) {
-        command_grammar *cg = CommandGrammars::get_parsing_grammar(K);
-        if (cg) RTCommandGrammars::compile_iv(&gprk, cg);
-    }
-    Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-    Produce::down(Emit::tree());
-        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_FAIL_HL));
-    Produce::up(Emit::tree());
-    Routines::end(save);
-    Hierarchy::make_available(Emit::tree(), iname);
-}
-
-void UnderstandValueTokens::truth_state(void) {
-    inter_name *iname = Hierarchy::find(TRUTH_STATE_TOKEN_INNER_HL);
-    packaging_state save = Routines::begin(iname);
-    gpr_kit gprk = UnderstandValueTokens::new_kit();
-    UnderstandValueTokens::add_original(&gprk);
-    command_grammar *cg = CommandGrammars::get_parsing_grammar(K_truth_state);
-    if (cg) RTCommandGrammars::compile_iv(&gprk, cg);
-    Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-    Produce::down(Emit::tree());
-        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_FAIL_HL));
-    Produce::up(Emit::tree());
-    Routines::end(save);
-    Hierarchy::make_available(Emit::tree(), iname);
-}
-
-void UnderstandValueTokens::compile_type_gprs(void) {
-    int next_label = 1, longest;
-    command_grammar *cg;
-    kind *K;
-    LOOP_OVER_BASE_KINDS(K) {
-        if ((Kinds::Behaviour::is_an_enumeration(K)) ||
-            (Kinds::Behaviour::is_quasinumerical(K))) {
-            instance *q; literal_pattern *lp;
-            if (Kinds::Behaviour::needs_I6_GPR(K) == FALSE) continue;
-            inter_name *iname = RTKinds::get_kind_GPR_iname(K);
-            packaging_state save = Routines::begin(iname);
-            int need_lf_vars = FALSE;
-            LITERAL_FORMS_LOOP(lp, K) {
-                need_lf_vars = TRUE;
-                break;
-            }
-            gpr_kit gprk = UnderstandValueTokens::new_kit();
-            UnderstandValueTokens::add_original(&gprk);
-            UnderstandValueTokens::add_standard_set(&gprk);
-            if (need_lf_vars) UnderstandValueTokens::add_lp_vars(&gprk);
-            Compile body of kind GPR1.1;
-            Routines::end(save);
-
-            if (Kinds::Behaviour::is_an_enumeration(K)) {
-                inter_name *iname = RTKinds::get_instance_GPR_iname(K);
-                packaging_state save = Routines::begin(iname);
-                gpr_kit gprk = UnderstandValueTokens::new_kit();
-                UnderstandValueTokens::add_instance_call(&gprk);
-                UnderstandValueTokens::add_original(&gprk);
-                UnderstandValueTokens::add_standard_set(&gprk);
-                GV_IS_VALUE_instance_mode = TRUE;
-                Compile body of kind GPR1.1;
-                GV_IS_VALUE_instance_mode = FALSE;
-                Routines::end(save);
-            }
-        }
-    }
-}
-
-
  • The structure gpr_kit is accessed in 5/gpr and here.
-

§1.1. Compile body of kind GPR1.1 = -

- -
-    Save word number1.1.1;
-    LITERAL_FORMS_LOOP(lp, K) {
-        RTLiteralPatterns::gpr(&gprk, lp);
-        Reset word number1.1.2;
-    }
-
-    cg = CommandGrammars::get_parsing_grammar(K);
-    if (cg != NULL) {
-        RTCommandGrammars::compile_iv(&gprk, cg);
-        Reset word number1.1.2;
-    }
-    longest = 0;
-    LOOP_OVER_INSTANCES(q, K) {
-        wording NW = Instances::get_name_in_play(q, FALSE);
-        int L = Wordings::length(NW) - 1;
-        if (L > longest) longest = L;
-    }
-    for (; longest >= 0; longest--) {
-        LOOP_OVER_INSTANCES(q, K) {
-            wording NW = Instances::get_name_in_play(q, FALSE);
-            if (Wordings::length(NW) - 1 == longest) {
-                if (GV_IS_VALUE_instance_mode) {
-                    Produce::inv_primitive(Emit::tree(), IF_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), EQ_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::val_symbol(Emit::tree(), K_value, gprk.instance_s);
-                            Produce::val_iname(Emit::tree(), K_value, RTInstances::iname(q));
-                        Produce::up(Emit::tree());
-                        Produce::code(Emit::tree());
-                        Produce::down(Emit::tree());
-                }
-                Reset word number1.1.2;
-
-                TEMPORARY_TEXT(L)
-                WRITE_TO(L, ".Failed_%d", next_label++);
-                inter_symbol *flab = Produce::reserve_label(Emit::tree(), L);
-                DISCARD_TEXT(L)
-
-                LOOP_THROUGH_WORDING(k, NW) {
-                    Produce::inv_primitive(Emit::tree(), IF_BIP);
-                    Produce::down(Emit::tree());
-                        Produce::inv_primitive(Emit::tree(), NE_BIP);
-                        Produce::down(Emit::tree());
-                            Produce::inv_call_iname(Emit::tree(), Hierarchy::find(NEXTWORDSTOPPED_HL));
-                            TEMPORARY_TEXT(W)
-                            WRITE_TO(W, "%N", k);
-                            Produce::val_dword(Emit::tree(), W);
-                            DISCARD_TEXT(W)
-                        Produce::up(Emit::tree());
-                        Produce::code(Emit::tree());
-                        Produce::down(Emit::tree());
-                            Produce::inv_primitive(Emit::tree(), JUMP_BIP);
-                            Produce::down(Emit::tree());
-                                Produce::lab(Emit::tree(), flab);
-                            Produce::up(Emit::tree());
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-                }
-                Produce::inv_primitive(Emit::tree(), STORE_BIP);
-                Produce::down(Emit::tree());
-                    Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(PARSED_NUMBER_HL));
-                    Produce::val_iname(Emit::tree(), K_value, RTInstances::iname(q));
-                Produce::up(Emit::tree());
-                Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-                Produce::down(Emit::tree());
-                    Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_NUMBER_HL));
-                Produce::up(Emit::tree());
-
-                if (GV_IS_VALUE_instance_mode) {
-                        Produce::up(Emit::tree());
-                    Produce::up(Emit::tree());
-                }
-                Produce::place_label(Emit::tree(), flab);
-            }
-        }
-    }
-    Produce::inv_primitive(Emit::tree(), RETURN_BIP);
-    Produce::down(Emit::tree());
-        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_FAIL_HL));
-    Produce::up(Emit::tree());
-
-
  • This code is used in §1 (twice).
-

§1.1.1. Save word number1.1.1 = -

- -
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_symbol(Emit::tree(), K_value, gprk.original_wn_s);
-        Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-    Produce::up(Emit::tree());
-
-
  • This code is used in §1.1.
-

§1.1.2. Reset word number1.1.2 = -

- -
-    Produce::inv_primitive(Emit::tree(), STORE_BIP);
-    Produce::down(Emit::tree());
-        Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
-        Produce::val_symbol(Emit::tree(), K_value, gprk.original_wn_s);
-    Produce::up(Emit::tree());
-
-
  • This code is used in §1.1 (three times).
- - -
- - - diff --git a/docs/if-module/5-us.html b/docs/if-module/5-us.html index df094c3c4..aee4b8e31 100644 --- a/docs/if-module/5-us.html +++ b/docs/if-module/5-us.html @@ -577,8 +577,8 @@ integer result is 0 if no problems were thrown, or -1 if they were. <understand-prop-op-uncond> ==> { R[1], RP[1] } <understand-prop-op-uncond> ::= - referring to <understand-prop-ref> | ==> { 1, RP[1] } - describing <understand-prop-ref> | ==> { 2, RP[1] } + referring to <understand-prop-ref> | ==> { REFERRING_TO_VISIBILITY_LEVEL, RP[1] } + describing <understand-prop-ref> | ==> { DESCRIBING_VISIBILITY_LEVEL, RP[1] } ... ==> Issue PM_BadUnderstandProperty problem13.1 <understand-prop-ref> ::= @@ -773,7 +773,7 @@ it, one at a time, by previous Understand sentences. }
  • This code is used in §15.
-

§16. Property blocks. Again, some semantic checks, but the real work is delegated to Visibility::seek. +

§16. Property blocks. Again, some semantic checks, but the real work is delegated to Visibility::set.

@@ -805,7 +805,7 @@ it, one at a time, by previous Understand sentences.
             "of day, or units; but certain built-into-Inform kinds of value "
             "(like snippet or rulebook, for instance) I can't use.");
     }
-    if (Visibility::seek(pr, subj, level, WHENW) == FALSE) {
+    if (Visibility::set(pr, subj, level, WHENW) == FALSE) {
         StandardProblems::sentence_problem(Task::syntax_tree(),
             _p_(PM_UnknownUnpermittedProperty),
             "that property is not allowed for the thing or kind in question",
@@ -1049,10 +1049,12 @@ and add it to a suitably chosen CG with             (Kinds::Behaviour::is_subkind_of_object(Specifications::to_kind(spec)) == FALSE)
             && (Descriptions::number_of_adjectives_applied_to(spec) == 1)
             && (AdjectivalPredicates::parity(
-                Propositions::first_unary_predicate(Specifications::to_proposition(spec), NULL)))) {
+                Propositions::first_unary_predicate(
+                    Specifications::to_proposition(spec), NULL)))) {
             adjective *aph =
                 AdjectivalPredicates::to_adjective(
-                    Propositions::first_unary_predicate(Specifications::to_proposition(spec), NULL));
+                    Propositions::first_unary_predicate(
+                        Specifications::to_proposition(spec), NULL));
             instance *q = AdjectiveAmbiguity::has_enumerative_meaning(aph);
             if (q) {
                 ur->cg_result = CG_IS_VALUE;
@@ -1089,73 +1091,11 @@ and add it to a suitably chosen CG with 
-    wchar_t *as_wide_string = Lexer::word_text(Wordings::first_wn(W));
-    Reject this if it contains punctuation19.9.1;
-    wording tokenised = Feeds::feed_C_string_full(as_wide_string, TRUE,
-        GRAMMAR_PUNCTUATION_MARKS);
-    Reject this if it contains two consecutive commas19.9.2;
-
-    tokens = CGTokens::break_into_tokens(NULL, tokenised);
-    if (tokens == NULL) {
-        StandardProblems::sentence_problem(Task::syntax_tree(),
-            _p_(PM_UnderstandEmptyText),
-            "'understand' should be followed by text which contains at least "
-            "one word or square-bracketed token",
-            "so for instance 'understand \"take [something]\" as taking' is fine, "
-            "but 'understand \"\" as the fog' is not. The same applies to the contents "
-            "of 'topic' columns in tables, since those are also instructions for "
-            "understanding.");
-        return;
-    }
+    int np = problem_count;
+    tokens = CGTokens::tokenise(W);
+    if (problem_count > np) return;
 
  • This code is used in §19.
-

§19.9.1. Reject this if it contains punctuation19.9.1 = -

- -
-    int skip = FALSE, literal_punct = FALSE;
-    for (int i=0; as_wide_string[i]; i++) {
-        if (as_wide_string[i] == '[') skip = TRUE;
-        if (as_wide_string[i] == ']') skip = FALSE;
-        if (skip) continue;
-        if ((as_wide_string[i] == '.') || (as_wide_string[i] == ',') ||
-            (as_wide_string[i] == '!') || (as_wide_string[i] == '?') ||
-            (as_wide_string[i] == ':') || (as_wide_string[i] == ';'))
-            literal_punct = TRUE;
-    }
-    if (literal_punct) {
-        StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_LiteralPunctuation),
-            "'understand' text cannot contain literal punctuation",
-            "or more specifically cannot contain any of these: . , ! ? : ; since they "
-            "are already used in various ways by the parser, and would not correctly "
-            "match here.");
-        return;
-    }
-
- -

§19.9.2. Reject this if it contains two consecutive commas19.9.2 = -

- -
-    LOOP_THROUGH_WORDING(i, tokenised)
-        if (i < Wordings::last_wn(tokenised))
-            if ((compare_word(i, COMMA_V)) && (compare_word(i+1, COMMA_V))) {
-                StandardProblems::sentence_problem(Task::syntax_tree(),
-                    _p_(PM_UnderstandCommaCommand),
-                    "'understand' as an action cannot involve a comma",
-                    "since a command leading to an action never does. "
-                    "(Although Inform understands commands like 'PETE, LOOK' "
-                    "only the part after the comma is read as an action command: "
-                    "the part before the comma is read as the name of someone, "
-                    "according to the usual rules for parsing a name.) "
-                    "Because of the way Inform processes text with square "
-                    "brackets, this problem message is also sometimes seen "
-                    "if empty square brackets are used, as in 'Understand "
-                    "\"bless []\" as blessing.'");
-                return;
-            }
-
-

§19.10. Make the new CG line19.10 =

@@ -1183,8 +1123,8 @@ and add it to a suitably chosen CG with break; case CG_IS_COMMAND: { wording command_W = EMPTY_WORDING; implies the no verb verb - if (CGTokens::is_literal(tokens)) - command_W = Wordings::first_word(CGTokens::text(tokens)); + if (CGTokens::is_literal(tokens)) + command_W = Wordings::first_word(CGTokens::text(tokens)); LOGIF(GRAMMAR_CONSTRUCTION, "Add to command grammar of command '%W': ", command_W); cg = CommandGrammars::for_command_verb_creating(command_W); break; @@ -1224,7 +1164,7 @@ and add it to a suitably chosen CG with
  • This code is used in §19.
  • diff --git a/docs/if-module/index.html b/docs/if-module/index.html index 7c1c0dff0..3a3725fc7 100644 --- a/docs/if-module/index.html +++ b/docs/if-module/index.html @@ -306,24 +306,9 @@ Command grammars, their lines and their tokens may each "determine" up to two values, and here we provide a way to describe the range of those.

  • -

    - Grammar Properties - - A plugin for the I6 run-time properties needed to support parsing.

    -
  • -
  • -

    - Noun Filter Tokens - - Filters are used to require nouns to have specific kinds or attributes, or to have specific scoping rules: they correspond to Inform 6's |noun=Routine| and |scope=Routine| tokens. Though these are quite different concepts in I6, their common handling seems natural in I7.

    -
  • -
  • -

    - Tokens Parsing Values - - In the argot of Inform 6, GPR stands for General Parsing Routine, and I7 makes heavy use of GPR tokens to achieve its ends. This section is where the necessary I6 routines are compiled.

    -
  • -
  • -

    - General Parsing Routines - - To compile I6 general parsing routines (GPRs) and/or |parse_name| properties as required by the I7 grammar.

    +

    + Property Visibility - + Some properties can be referred to in the player's commands.

  • diff --git a/docs/runtime-module/2-cu.html b/docs/runtime-module/2-cu.html index 0dec6b3fd..68de99156 100644 --- a/docs/runtime-module/2-cu.html +++ b/docs/runtime-module/2-cu.html @@ -182,7 +182,7 @@ but that's now easy, as we just have to read off the annotation made above &mdas

    -compilation_unit *CompilationUnits::find(parse_node *from) {
    +compilation_unit *CompilationUnits::find(parse_node *from) {
         if (from == NULL) return NULL;
         return Node::get_unit(from);
     }
    diff --git a/docs/runtime-module/2-emt.html b/docs/runtime-module/2-emt.html
    index 40dcf8381..33b004868 100644
    --- a/docs/runtime-module/2-emt.html
    +++ b/docs/runtime-module/2-emt.html
    @@ -84,7 +84,7 @@ function togglePopup(material_id) {
     
     inter_tree *I7_generation_tree = NULL;
     
    -inter_tree *Emit::tree(void) {
    +inter_tree *Emit::tree(void) {
         return I7_generation_tree;
     }
     
    @@ -512,7 +512,7 @@ insert them into the Inter stream close to the top.
         return save;
     }
     
    -void Emit::array_iname_entry(inter_name *iname) {
    +void Emit::array_iname_entry(inter_name *iname) {
         if (current_A == NULL) internal_error("entry outside of inter array");
         inter_symbol *alias;
         if (iname == NULL) alias = Site::veneer_symbol(Emit::tree(), NOTHING_VSYMB);
    @@ -667,7 +667,7 @@ insert them into the Inter stream close to the top.
     */
     }
     
    -void Emit::code_comment(text_stream *text) {
    +void Emit::code_comment(text_stream *text) {
     	inter_ti ID = Inter::Warehouse::create_text(Inter::Tree::warehouse(Emit::tree()), Inter::Bookmarks::package(Packaging::at(Emit::tree())));
         Str::copy(Inter::Warehouse::get_text(Inter::Tree::warehouse(Emit::tree()), ID), text);
         Produce::guard(Inter::Comment::new(Produce::at(Emit::tree()), (inter_ti) Produce::level(Emit::tree()), NULL, ID));
    @@ -802,7 +802,7 @@ insert them into the Inter stream close to the top.
         return Packaging::enclosure(Emit::tree());
     }
     
    -packaging_state Emit::unused_packaging_state(void) {
    +packaging_state Emit::unused_packaging_state(void) {
         return Packaging::stateless();
     }
     
    diff --git a/docs/runtime-module/2-hrr.html b/docs/runtime-module/2-hrr.html index b027e795a..bf2b0aac9 100644 --- a/docs/runtime-module/2-hrr.html +++ b/docs/runtime-module/2-hrr.html @@ -1723,11 +1723,11 @@ function togglePopup(material_id) {

    §4.

    -inter_name *Hierarchy::find(int id) {
    +inter_name *Hierarchy::find(int id) {
         return HierarchyLocations::find(Emit::tree(), id);
     }
     
    -void Hierarchy::make_available(inter_tree *I, inter_name *iname) {
    +void Hierarchy::make_available(inter_tree *I, inter_name *iname) {
         text_stream *ma_as = Produce::get_translation(iname);
         if (Str::len(ma_as) == 0) ma_as = Emit::to_text(iname);
         PackageTypes::get(I, I"_linkage");
    @@ -1735,7 +1735,7 @@ function togglePopup(material_id) {
         Inter::Connectors::socket(Emit::tree(), ma_as, S);
     }
     
    -package_request *Hierarchy::package(compilation_unit *C, int hap_id) {
    +package_request *Hierarchy::package(compilation_unit *C, int hap_id) {
         return HierarchyLocations::attach_new_package(Emit::tree(), C, NULL, hap_id);
     }
     
    @@ -1743,7 +1743,7 @@ function togglePopup(material_id) {
         return HierarchyLocations::attach_new_package(Emit::tree(), NULL, NULL, hap_id);
     }
     
    -package_request *Hierarchy::local_package(int hap_id) {
    +package_request *Hierarchy::local_package(int hap_id) {
         return HierarchyLocations::attach_new_package(Emit::tree(), CompilationUnits::find(current_sentence), NULL, hap_id);
     }
     
    @@ -1755,7 +1755,7 @@ function togglePopup(material_id) {
         return HierarchyLocations::attach_new_package(Emit::tree(), NULL, super, hap_id);
     }
     
    -inter_name *Hierarchy::make_iname_in(int id, package_request *P) {
    +inter_name *Hierarchy::make_iname_in(int id, package_request *P) {
         return HierarchyLocations::find_in_package(Emit::tree(), id, P, EMPTY_WORDING, NULL, -1, NULL);
     }
     
    diff --git a/docs/runtime-module/4-epv.html b/docs/runtime-module/4-epv.html
    index 505143647..2f06d146c 100644
    --- a/docs/runtime-module/4-epv.html
    +++ b/docs/runtime-module/4-epv.html
    @@ -292,10 +292,10 @@ the following.
     

    -void RTPropertyValues::emit_iname_has_property(kind *K, inter_name *N, property *prn) {
    +void RTPropertyValues::emit_iname_has_property(kind *K, inter_name *N, property *prn) {
         RTPropertyValues::emit_has_property(K, InterNames::to_symbol(N), prn);
     }
    -void RTPropertyValues::emit_has_property(kind *K, inter_symbol *S, property *prn) {
    +void RTPropertyValues::emit_has_property(kind *K, inter_symbol *S, property *prn) {
         if (RTProperties::implemented_as_attribute(prn)) {
             if (RTProperties::stored_in_negation(prn)) {
                 Produce::inv_primitive(Emit::tree(), NOT_BIP);
    @@ -380,7 +380,7 @@ the property-permission symbol accordingly:
     

    -inter_name *RTPropertyValues::annotate_table_storage(property_permission *pp) {
    +inter_name *RTPropertyValues::annotate_table_storage(property_permission *pp) {
         property_of_value_storage *povs =
             RETRIEVE_POINTER_property_of_value_storage(PropertyPermissions::get_storage_data(pp));
         return povs->storage_table_iname;
    diff --git a/docs/runtime-module/4-ins.html b/docs/runtime-module/4-ins.html
    index 635c9c404..216db97ab 100644
    --- a/docs/runtime-module/4-ins.html
    +++ b/docs/runtime-module/4-ins.html
    @@ -91,7 +91,7 @@ function togglePopup(material_id) {
         I->icd.instance_emitted = FALSE;
     }
     
    -inter_name *RTInstances::iname(instance *I) {
    +inter_name *RTInstances::iname(instance *I) {
         if (I == NULL) return NULL;
         return I->icd.instance_iname;
     }
    diff --git a/docs/runtime-module/4-lpart.html b/docs/runtime-module/4-lpart.html
    index 65c4d0e2e..31778113e 100644
    --- a/docs/runtime-module/4-lpart.html
    +++ b/docs/runtime-module/4-lpart.html
    @@ -88,24 +88,24 @@ if we fail to make a match.
     

    -void RTLiteralPatterns::gpr(gpr_kit *gprk, literal_pattern *lp) {
    +void RTLiteralPatterns::gpr(gpr_kit *gprk, literal_pattern *lp) {
         int label = lp->allocation_id;
         int tc, ec;
         RTLiteralPatterns::comment_use_of_lp(lp);
     
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
    -        Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +        Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
         Produce::up(Emit::tree());
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
    -        Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +        Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
             Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
         Produce::up(Emit::tree());
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
    -        Produce::ref_symbol(Emit::tree(), K_value, gprk->matched_number_s);
    +        Produce::ref_symbol(Emit::tree(), K_value, gprk->matched_number_s);
             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
         Produce::up(Emit::tree());
     
    @@ -126,14 +126,14 @@ if we fail to make a match.
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), EQ_BIP);
                 Produce::down(Emit::tree());
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->mid_word_s);
                     Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
                 Produce::up(Emit::tree());
                 Produce::code(Emit::tree());
                 Produce::down(Emit::tree());
                     Produce::inv_primitive(Emit::tree(), STORE_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_word_s);
    +                    Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_word_s);
                         Produce::inv_call_iname(Emit::tree(), Hierarchy::find(NEXTWORDSTOPPED_HL));
                     Produce::up(Emit::tree());
                     Produce::inv_primitive(Emit::tree(), POSTDECREMENT_BIP);
    @@ -151,7 +151,7 @@ if we fail to make a match.
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), EQ_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_word_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_word_s);
                             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) -1);
                         Produce::up(Emit::tree());
                         Produce::code(Emit::tree());
    @@ -177,7 +177,7 @@ if we fail to make a match.
     
         Produce::inv_primitive(Emit::tree(), IF_BIP);
         Produce::down(Emit::tree());
    -        Produce::val_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +        Produce::val_symbol(Emit::tree(), K_value, gprk->mid_word_s);
             Produce::code(Emit::tree());
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), JUMP_BIP);
    @@ -191,25 +191,25 @@ if we fail to make a match.
         Produce::down(Emit::tree());
             Produce::inv_primitive(Emit::tree(), LT_BIP);
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->sgn_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->sgn_s);
                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
             Produce::up(Emit::tree());
             Produce::code(Emit::tree());
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->matched_number_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->matched_number_s);
                     if (Kinds::FloatingPoint::uses_floating_point(lp->kind_specified)) {
                         Produce::inv_primitive(Emit::tree(), BITWISEOR_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->matched_number_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->matched_number_s);
                             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0x80000000);
                         Produce::up(Emit::tree());
                     } else {
                         Produce::inv_primitive(Emit::tree(), TIMES_BIP);
                         Produce::down(Emit::tree());
                             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) -1);
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->matched_number_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->matched_number_s);
                         Produce::up(Emit::tree());
                     }
                 Produce::up(Emit::tree());
    @@ -219,11 +219,11 @@ if we fail to make a match.
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
             Produce::ref_iname(Emit::tree(), K_object, Hierarchy::find(PARSED_NUMBER_HL));
    -        Produce::val_symbol(Emit::tree(), K_value, gprk->matched_number_s);
    +        Produce::val_symbol(Emit::tree(), K_value, gprk->matched_number_s);
         Produce::up(Emit::tree());
     
         Kinds::Scalings::compile_quanta_to_value(lp->scaling,
    -        Hierarchy::find(PARSED_NUMBER_HL), gprk->sgn_s, gprk->x_s, failed_label);
    +        Hierarchy::find(PARSED_NUMBER_HL), gprk->sgn_s, gprk->x_s, failed_label);
     
         Produce::inv_primitive(Emit::tree(), IFDEBUG_BIP);
         Produce::down(Emit::tree());
    @@ -271,7 +271,7 @@ if we fail to make a match.
     
         Produce::inv_primitive(Emit::tree(), IF_BIP);
         Produce::down(Emit::tree());
    -        Produce::val_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +        Produce::val_symbol(Emit::tree(), K_value, gprk->mid_word_s);
             Produce::code(Emit::tree());
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), JUMP_BIP);
    @@ -285,7 +285,7 @@ if we fail to make a match.
         Produce::down(Emit::tree());
             Produce::inv_primitive(Emit::tree(), NE_BIP);
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->cur_word_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->cur_word_s);
                 TEMPORARY_TEXT(N)
                 WRITE_TO(N, "%N", lp->lp_tokens[tc].token_wn);
                 Produce::val_dword(Emit::tree(), N);
    @@ -321,10 +321,10 @@ if we fail to make a match.
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
                     Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                    Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
                     Produce::up(Emit::tree());
                 Produce::up(Emit::tree());
                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) lower_form);
    @@ -334,10 +334,10 @@ if we fail to make a match.
                 Produce::down(Emit::tree());
                     Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
                         Produce::inv_primitive(Emit::tree(), MINUS_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
                         Produce::up(Emit::tree());
                     Produce::up(Emit::tree());
    @@ -366,7 +366,7 @@ if we fail to make a match.
         if (ec == 1) {
             Produce::inv_primitive(Emit::tree(), STORE_BIP);
             Produce::down(Emit::tree());
    -            Produce::ref_symbol(Emit::tree(), K_value, gprk->sgn_s);
    +            Produce::ref_symbol(Emit::tree(), K_value, gprk->sgn_s);
                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
             Produce::up(Emit::tree());
         }
    @@ -376,8 +376,8 @@ if we fail to make a match.
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                 Produce::up(Emit::tree());
                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) '-');
             Produce::up(Emit::tree());
    @@ -386,12 +386,12 @@ if we fail to make a match.
             if ((lp->number_signed) && (ec == 1)) {
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->sgn_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->sgn_s);
                     Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) -1);
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
                 Produce::up(Emit::tree());
             } else {
                 Produce::inv_primitive(Emit::tree(), JUMP_BIP);
    @@ -415,16 +415,16 @@ if we fail to make a match.
     
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
    -        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
             Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
         Produce::up(Emit::tree());
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
    -        Produce::ref_symbol(Emit::tree(), K_value, gprk->x_s);
    +        Produce::ref_symbol(Emit::tree(), K_value, gprk->x_s);
             Produce::inv_primitive(Emit::tree(), PLUS_BIP);
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
             Produce::up(Emit::tree());
         Produce::up(Emit::tree());
         March forwards through decimal digits1.3.1.1;
    @@ -432,7 +432,7 @@ if we fail to make a match.
         Produce::down(Emit::tree());
             Produce::inv_primitive(Emit::tree(), EQ_BIP);
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
             Produce::up(Emit::tree());
             Produce::code(Emit::tree());
    @@ -448,8 +448,8 @@ if we fail to make a match.
         Produce::down(Emit::tree());
             Produce::inv_primitive(Emit::tree(), EQ_BIP);
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
             Produce::up(Emit::tree());
             Produce::code(Emit::tree());
             Produce::down(Emit::tree());
    @@ -459,7 +459,7 @@ if we fail to make a match.
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_word_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_word_s);
                     Produce::inv_call_iname(Emit::tree(), Hierarchy::find(NEXTWORDSTOPPED_HL));
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
    @@ -475,7 +475,7 @@ if we fail to make a match.
                 Produce::down(Emit::tree());
                     Produce::inv_primitive(Emit::tree(), EQ_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_word_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_word_s);
                         Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(THEN1__WD_HL));
                     Produce::up(Emit::tree());
                     Produce::code(Emit::tree());
    @@ -491,16 +491,16 @@ if we fail to make a match.
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
                             Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
                         Produce::up(Emit::tree());
                         Compile I6 code to enter mid-word parsing if not already in it1.2.1;
                         March forwards through decimal digits1.3.1.1;
    @@ -511,7 +511,7 @@ if we fail to make a match.
     
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
    -        Produce::ref_symbol(Emit::tree(), K_value, gprk->tot_s);
    +        Produce::ref_symbol(Emit::tree(), K_value, gprk->tot_s);
             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
         Produce::up(Emit::tree());
     
    @@ -519,23 +519,23 @@ if we fail to make a match.
         Produce::down(Emit::tree());
             Produce::inv_primitive(Emit::tree(), EQ_BIP);
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
             Produce::up(Emit::tree());
             Produce::code(Emit::tree());
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->tot_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->tot_s);
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_word_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_word_s);
                     Produce::inv_call_iname(Emit::tree(), Hierarchy::find(NEXTWORDSTOPPED_HL));
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
                     Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
                 Produce::up(Emit::tree());
                 Compile I6 code to enter mid-word parsing if not already in it1.2.1;
    @@ -548,15 +548,15 @@ if we fail to make a match.
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), LT_BIP);
                 Produce::down(Emit::tree());
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), EQ_BIP);
                 Produce::down(Emit::tree());
                     Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                     Produce::up(Emit::tree());
                     Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) 'x');
                 Produce::up(Emit::tree());
    @@ -565,43 +565,43 @@ if we fail to make a match.
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
                     Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->tot_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->tot_s);
                         Produce::up(Emit::tree());
                         Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
                     Produce::up(Emit::tree());
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
                 Produce::up(Emit::tree());
     
                 Produce::inv_primitive(Emit::tree(), IF_BIP);
                 Produce::down(Emit::tree());
                     Produce::inv_primitive(Emit::tree(), EQ_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
                     Produce::up(Emit::tree());
                     Produce::code(Emit::tree());
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_word_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_word_s);
                             Produce::inv_call_iname(Emit::tree(), Hierarchy::find(NEXTWORDSTOPPED_HL));
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
                             Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
                         Produce::up(Emit::tree());
                         Compile I6 code to enter mid-word parsing if not already in it1.2.1;
    @@ -616,10 +616,10 @@ if we fail to make a match.
                         Produce::down(Emit::tree());
                             Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 3);
                             Produce::up(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), AND_BIP);
                         Produce::down(Emit::tree());
    @@ -627,8 +627,8 @@ if we fail to make a match.
                             Produce::down(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                                 Produce::up(Emit::tree());
                                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) '1');
                             Produce::up(Emit::tree());
    @@ -638,10 +638,10 @@ if we fail to make a match.
                                 Produce::down(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
                                         Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                                         Produce::down(Emit::tree());
    -                                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                                             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
                                         Produce::up(Emit::tree());
                                     Produce::up(Emit::tree());
    @@ -651,10 +651,10 @@ if we fail to make a match.
                                 Produce::down(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
                                         Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                                         Produce::down(Emit::tree());
    -                                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                                             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 2);
                                         Produce::up(Emit::tree());
                                     Produce::up(Emit::tree());
    @@ -667,19 +667,19 @@ if we fail to make a match.
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
                             Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
                                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 3);
                             Produce::up(Emit::tree());
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
                             Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 3);
                             Produce::up(Emit::tree());
                         Produce::up(Emit::tree());
    @@ -689,8 +689,8 @@ if we fail to make a match.
                             Produce::down(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), LT_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
                                 Produce::up(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), OR_BIP);
                                 Produce::down(Emit::tree());
    @@ -698,8 +698,8 @@ if we fail to make a match.
                                     Produce::down(Emit::tree());
                                         Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                                         Produce::down(Emit::tree());
    -                                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    -                                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                                         Produce::up(Emit::tree());
                                         Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) '+');
                                     Produce::up(Emit::tree());
    @@ -707,8 +707,8 @@ if we fail to make a match.
                                     Produce::down(Emit::tree());
                                         Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                                         Produce::down(Emit::tree());
    -                                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    -                                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                                         Produce::up(Emit::tree());
                                         Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) '-');
                                     Produce::up(Emit::tree());
    @@ -718,11 +718,11 @@ if we fail to make a match.
                             Produce::down(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +                                Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
                                 Produce::up(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                                Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
                                 Produce::up(Emit::tree());
                             Produce::up(Emit::tree());
                         Produce::up(Emit::tree());
    @@ -732,7 +732,7 @@ if we fail to make a match.
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), POSTDECREMENT_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
                         Produce::up(Emit::tree());
                     Produce::up(Emit::tree());
                 Produce::up(Emit::tree());
    @@ -741,11 +741,11 @@ if we fail to make a match.
     
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
    -        Produce::ref_symbol(Emit::tree(), K_value, gprk->x_s);
    +        Produce::ref_symbol(Emit::tree(), K_value, gprk->x_s);
             Produce::inv_call_iname(Emit::tree(), Hierarchy::find(FLOATPARSE_HL));
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->x_s);
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->x_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
                 Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
             Produce::up(Emit::tree());
         Produce::up(Emit::tree());
    @@ -754,7 +754,7 @@ if we fail to make a match.
         Produce::down(Emit::tree());
             Produce::inv_primitive(Emit::tree(), EQ_BIP);
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->x_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->x_s);
                 Produce::val_symbol(Emit::tree(), K_value, Site::veneer_symbol(Emit::tree(), FLOAT_NAN_VSYMB));
             Produce::up(Emit::tree());
             Produce::code(Emit::tree());
    @@ -770,14 +770,14 @@ if we fail to make a match.
         Produce::down(Emit::tree());
             Produce::inv_primitive(Emit::tree(), EQ_BIP);
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
             Produce::up(Emit::tree());
             Produce::code(Emit::tree());
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
                     Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
                 Produce::up(Emit::tree());
             Produce::up(Emit::tree());
    @@ -785,8 +785,8 @@ if we fail to make a match.
     
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
    -        Produce::ref_symbol(Emit::tree(), K_value, gprk->matched_number_s);
    -        Produce::val_symbol(Emit::tree(), K_value, gprk->x_s);
    +        Produce::ref_symbol(Emit::tree(), K_value, gprk->matched_number_s);
    +        Produce::val_symbol(Emit::tree(), K_value, gprk->x_s);
         Produce::up(Emit::tree());
     
    • This code is used in §1.3.
    @@ -800,8 +800,8 @@ if we fail to make a match. Produce::down(Emit::tree()); Produce::inv_primitive(Emit::tree(), LT_BIP); Produce::down(Emit::tree()); - Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s); - Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s); + Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s); + Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s); Produce::up(Emit::tree()); Produce::inv_primitive(Emit::tree(), GE_BIP); Produce::down(Emit::tree()); @@ -809,8 +809,8 @@ if we fail to make a match. Produce::down(Emit::tree()); Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP); Produce::down(Emit::tree()); - Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s); - Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s); + Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s); + Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s); Produce::up(Emit::tree()); Produce::up(Emit::tree()); Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0); @@ -820,11 +820,11 @@ if we fail to make a match. Produce::down(Emit::tree()); Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP); Produce::down(Emit::tree()); - Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s); + Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s); Produce::up(Emit::tree()); Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP); Produce::down(Emit::tree()); - Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s); + Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s); Produce::up(Emit::tree()); Produce::up(Emit::tree()); Produce::up(Emit::tree()); @@ -836,12 +836,12 @@ if we fail to make a match.
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
    -        Produce::ref_symbol(Emit::tree(), K_value, gprk->tot_s);
    +        Produce::ref_symbol(Emit::tree(), K_value, gprk->tot_s);
             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
         Produce::up(Emit::tree());
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
    -        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +        Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
             Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
         Produce::up(Emit::tree());
     
    @@ -851,8 +851,8 @@ if we fail to make a match.
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), LT_BIP);
                 Produce::down(Emit::tree());
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), GE_BIP);
                 Produce::down(Emit::tree());
    @@ -860,8 +860,8 @@ if we fail to make a match.
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                         Produce::up(Emit::tree());
                     Produce::up(Emit::tree());
                     Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
    @@ -871,25 +871,25 @@ if we fail to make a match.
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
                     Produce::inv_call_iname(Emit::tree(), Hierarchy::find(DIGITTOVALUE_HL));
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                         Produce::up(Emit::tree());
                     Produce::up(Emit::tree());
                 Produce::up(Emit::tree());
    -            Kinds::Scalings::compile_scale_and_add(gprk->tot_s, gprk->sgn_s, 10, 0, gprk->f_s, failed_label);
    +            Kinds::Scalings::compile_scale_and_add(gprk->tot_s, gprk->sgn_s, 10, 0, gprk->f_s, failed_label);
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
                     Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
                 Produce::up(Emit::tree());
             Produce::up(Emit::tree());
         Produce::up(Emit::tree());
    @@ -898,7 +898,7 @@ if we fail to make a match.
         Produce::down(Emit::tree());
             Produce::inv_primitive(Emit::tree(), EQ_BIP);
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
                 Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
             Produce::up(Emit::tree());
             Produce::code(Emit::tree());
    @@ -915,7 +915,7 @@ if we fail to make a match.
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), GE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->tot_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->tot_s);
                     Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) lpe->element_range);
                 Produce::up(Emit::tree());
                 Produce::code(Emit::tree());
    @@ -928,11 +928,11 @@ if we fail to make a match.
             Produce::up(Emit::tree());
         }
     
    -    Kinds::Scalings::compile_scale_and_add(gprk->tot_s, gprk->sgn_s, lpe->element_multiplier, 0, gprk->matched_number_s, failed_label);
    +    Kinds::Scalings::compile_scale_and_add(gprk->tot_s, gprk->sgn_s, lpe->element_multiplier, 0, gprk->matched_number_s, failed_label);
         Produce::inv_primitive(Emit::tree(), STORE_BIP);
         Produce::down(Emit::tree());
    -        Produce::ref_symbol(Emit::tree(), K_value, gprk->matched_number_s);
    -        Produce::val_symbol(Emit::tree(), K_value, gprk->tot_s);
    +        Produce::ref_symbol(Emit::tree(), K_value, gprk->matched_number_s);
    +        Produce::val_symbol(Emit::tree(), K_value, gprk->tot_s);
         Produce::up(Emit::tree());
     
         int M = Kinds::Scalings::get_integer_multiplier(lp->scaling);
    @@ -941,8 +941,8 @@ if we fail to make a match.
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), EQ_BIP);
                 Produce::down(Emit::tree());
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
                 Produce::up(Emit::tree());
                 Produce::code(Emit::tree());
                 Produce::down(Emit::tree());
    @@ -952,7 +952,7 @@ if we fail to make a match.
                     Produce::up(Emit::tree());
                     Produce::inv_primitive(Emit::tree(), STORE_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_word_s);
    +                    Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_word_s);
                         Produce::inv_call_iname(Emit::tree(), Hierarchy::find(NEXTWORDSTOPPED_HL));
                     Produce::up(Emit::tree());
                     Produce::inv_primitive(Emit::tree(), STORE_BIP);
    @@ -968,7 +968,7 @@ if we fail to make a match.
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), EQ_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_word_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->cur_word_s);
                             Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(THEN1__WD_HL));
                         Produce::up(Emit::tree());
                         Produce::code(Emit::tree());
    @@ -984,18 +984,18 @@ if we fail to make a match.
                             Produce::up(Emit::tree());
                             Produce::inv_primitive(Emit::tree(), STORE_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +                            Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
                                 Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
                             Produce::up(Emit::tree());
                             Compile I6 code to enter mid-word parsing if not already in it1.2.1;
                             Produce::inv_primitive(Emit::tree(), STORE_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::ref_symbol(Emit::tree(), K_value, gprk->x_s);
    +                            Produce::ref_symbol(Emit::tree(), K_value, gprk->x_s);
                                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
                             Produce::up(Emit::tree());
                             Produce::inv_primitive(Emit::tree(), STORE_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +                            Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
                                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, (inter_ti) M);
                             Produce::up(Emit::tree());
                             Produce::inv_primitive(Emit::tree(), WHILE_BIP);
    @@ -1004,7 +1004,7 @@ if we fail to make a match.
                                 Produce::down(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), GT_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
    +                                    Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
                                         Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 1);
                                     Produce::up(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), AND_BIP);
    @@ -1013,7 +1013,7 @@ if we fail to make a match.
                                         Produce::down(Emit::tree());
                                             Produce::inv_primitive(Emit::tree(), MODULO_BIP);
                                             Produce::down(Emit::tree());
    -                                            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
    +                                            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
                                                 Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 10);
                                             Produce::up(Emit::tree());
                                             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
    @@ -1024,8 +1024,8 @@ if we fail to make a match.
                                             Produce::down(Emit::tree());
                                                 Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                                                 Produce::down(Emit::tree());
    -                                                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    -                                                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                                                Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                                                Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                                                 Produce::up(Emit::tree());
                                             Produce::up(Emit::tree());
                                             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
    @@ -1036,7 +1036,7 @@ if we fail to make a match.
                                 Produce::down(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), STORE_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                    Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
                                         Produce::inv_primitive(Emit::tree(), DIVIDE_BIP);
                                         Produce::down(Emit::tree());
                                             Produce::inv_primitive(Emit::tree(), TIMES_BIP);
    @@ -1045,27 +1045,27 @@ if we fail to make a match.
                                                 Produce::down(Emit::tree());
                                                     Produce::inv_primitive(Emit::tree(), LOOKUPBYTE_BIP);
                                                     Produce::down(Emit::tree());
    -                                                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    -                                                    Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                                                    Produce::val_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                                                    Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
                                                     Produce::up(Emit::tree());
                                                 Produce::up(Emit::tree());
    -                                            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
    +                                            Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
                                             Produce::up(Emit::tree());
                                             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 10);
                                         Produce::up(Emit::tree());
                                     Produce::up(Emit::tree());
    -                                Kinds::Scalings::compile_scale_and_add(gprk->x_s, gprk->sgn_s,
    -                                    1, 0, gprk->w_s, failed_label);
    +                                Kinds::Scalings::compile_scale_and_add(gprk->x_s, gprk->sgn_s,
    +                                    1, 0, gprk->w_s, failed_label);
                                     Produce::inv_primitive(Emit::tree(), POSTINCREMENT_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                                    Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
                                     Produce::up(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), STORE_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
    +                                    Produce::ref_symbol(Emit::tree(), K_value, gprk->f_s);
                                         Produce::inv_primitive(Emit::tree(), DIVIDE_BIP);
                                         Produce::down(Emit::tree());
    -                                        Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
    +                                        Produce::val_symbol(Emit::tree(), K_value, gprk->f_s);
                                             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 10);
                                         Produce::up(Emit::tree());
                                     Produce::up(Emit::tree());
    @@ -1086,24 +1086,24 @@ if we fail to make a match.
         Produce::down(Emit::tree());
             Produce::inv_primitive(Emit::tree(), EQ_BIP);
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->mid_word_s);
                 Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
             Produce::up(Emit::tree());
             Produce::code(Emit::tree());
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
                     Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->wpos_s);
                     Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_addr_s);
                     Produce::inv_call_iname(Emit::tree(), Hierarchy::find(WORDADDRESS_HL));
                     Produce::down(Emit::tree());
                         Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    @@ -1111,7 +1111,7 @@ if we fail to make a match.
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_len_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->cur_len_s);
                     Produce::inv_call_iname(Emit::tree(), Hierarchy::find(WORDLENGTH_HL));
                     Produce::down(Emit::tree());
                         Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    @@ -1129,8 +1129,8 @@ if we fail to make a match.
         Produce::down(Emit::tree());
             Produce::inv_primitive(Emit::tree(), EQ_BIP);
             Produce::down(Emit::tree());
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    -            Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->wpos_s);
    +            Produce::val_symbol(Emit::tree(), K_value, gprk->cur_len_s);
             Produce::up(Emit::tree());
             Produce::code(Emit::tree());
             Produce::down(Emit::tree());
    @@ -1140,7 +1140,7 @@ if we fail to make a match.
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->mid_word_s);
                     Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 0);
                 Produce::up(Emit::tree());
             Produce::up(Emit::tree());
    @@ -1150,7 +1150,7 @@ if we fail to make a match.
     

    §2. Printing the I6 variable |value| out in an LP's notation at run-time.

    -void RTLiteralPatterns::printing_routine(inter_name *iname, literal_pattern *lp_list) {
    +void RTLiteralPatterns::printing_routine(inter_name *iname, literal_pattern *lp_list) {
         packaging_state save = Routines::begin(iname);
     
         literal_pattern_name *lpn;
    @@ -1514,7 +1514,7 @@ the sorting measure.
     

    §3.

    -inter_symbol *RTLiteralPatterns::jump_label(literal_pattern *lp) {
    +inter_symbol *RTLiteralPatterns::jump_label(literal_pattern *lp) {
         if (lp->jump_label == NULL) {
             TEMPORARY_TEXT(N)
             WRITE_TO(N, ".Use_LP_%d", lp->allocation_id);
    @@ -1527,7 +1527,7 @@ the sorting measure.
     

    §4.

    -void RTLiteralPatterns::comment_use_of_lp(literal_pattern *lp) {
    +void RTLiteralPatterns::comment_use_of_lp(literal_pattern *lp) {
         TEMPORARY_TEXT(W)
         WRITE_TO(W, "%W, ", lp->prototype_text);
         Kinds::Scalings::describe(W, lp->scaling);
    diff --git a/docs/runtime-module/4-prp.html b/docs/runtime-module/4-prp.html
    index a8be5cc0f..13b8f8688 100644
    --- a/docs/runtime-module/4-prp.html
    +++ b/docs/runtime-module/4-prp.html
    @@ -157,7 +157,7 @@ property also visits its negation.)
     

    §4.

    -int RTProperties::stored_in_negation(property *prn) {
    +int RTProperties::stored_in_negation(property *prn) {
         if ((prn == NULL) || (prn->either_or_data == NULL)) internal_error("non-EO property");
         return prn->compilation_data.store_in_negation;
     }
    @@ -233,7 +233,7 @@ run-time support code to work.
     

    §6. Emitting to Inter.

    -inter_name *RTProperties::iname(property *prn) {
    +inter_name *RTProperties::iname(property *prn) {
         if (prn == NULL) internal_error("tried to find iname for null property");
         if ((Properties::is_either_or(prn)) && (prn->compilation_data.store_in_negation))
             return RTProperties::iname(EitherOrProperties::get_negation(prn));
    diff --git a/docs/runtime-module/4-rsfk.html b/docs/runtime-module/4-rsfk.html
    index 2dda406d1..2beefb649 100644
    --- a/docs/runtime-module/4-rsfk.html
    +++ b/docs/runtime-module/4-rsfk.html
    @@ -125,7 +125,7 @@ kinds being compiled to an I6 
     
     
    -inter_name *RTKinds::I6_classname(kind *K) {
    +inter_name *RTKinds::I6_classname(kind *K) {
         if (Kinds::Behaviour::is_object(K)) return RTKinds::iname(K);
         internal_error("no I6 classname available");
         return NULL;
    @@ -800,7 +800,7 @@ values for kinds, since both involve tracking constructions uniquely.
     

    -inter_name *RTKinds::get_kind_GPR_iname(kind *K) {
    +inter_name *RTKinds::get_kind_GPR_iname(kind *K) {
         if (K == NULL) return NULL;
         kind_constructor *con = Kinds::get_construct(K);
         if (con->kind_GPR_iname == NULL) {
    @@ -810,7 +810,7 @@ values for kinds, since both involve tracking constructions uniquely.
         return con->kind_GPR_iname;
     }
     
    -inter_name *RTKinds::get_instance_GPR_iname(kind *K) {
    +inter_name *RTKinds::get_instance_GPR_iname(kind *K) {
         if (K == NULL) return NULL;
         kind_constructor *con = Kinds::get_construct(K);
         if (con->instance_GPR_iname == NULL) {
    @@ -984,7 +984,7 @@ how the job is done.
     
     int total_heap_allocation = 0;
     
    -void RTKinds::ensure_basic_heap_present(void) {
    +void RTKinds::ensure_basic_heap_present(void) {
         total_heap_allocation += 256;  enough for the initial free-space block
     }
     
    @@ -1059,7 +1059,7 @@ list of 20 texts. For the cases above, it's always 1. return ha; } -void RTKinds::emit_heap_allocation(heap_allocation ha) { +void RTKinds::emit_heap_allocation(heap_allocation ha) { if (ha.stack_offset >= 0) { inter_name *iname = Hierarchy::find(BLKVALUECREATEONSTACK_HL); Produce::inv_call_iname(Emit::tree(), iname); @@ -1086,7 +1086,7 @@ list of 20 texts. For the cases above, it's always 1. define BLK_FLAG_TRUNCMULT 0x00000010
    -void RTKinds::emit_block_value_header(kind *K, int individual, int size) {
    +void RTKinds::emit_block_value_header(kind *K, int individual, int size) {
         if (individual == FALSE) Emit::array_numeric_entry(0);
         int n = 0, c = 1, w = 4;
         if (TargetVMs::is_16_bit(Task::vm())) w = 2;
    @@ -1108,7 +1108,7 @@ each such kind, and needed at run-time.
     

    -int RTKinds::base_represented_in_inter(kind *K) {
    +int RTKinds::base_represented_in_inter(kind *K) {
         if ((Kinds::Behaviour::is_kind_of_kind(K) == FALSE) &&
             (Kinds::is_proper_constructor(K) == FALSE) &&
             (K != K_void) &&
    @@ -1129,7 +1129,7 @@ each such kind, and needed at run-time.
     
    define MAX_KIND_ARITY 32
     
    -inter_name *RTKinds::iname(kind *K) {
    +inter_name *RTKinds::iname(kind *K) {
         if (RTKinds::base_represented_in_inter(K) == FALSE) {
             kind_interaction *KI;
             LOOP_OVER(KI, kind_interaction)
    @@ -1241,7 +1241,7 @@ each such kind, and needed at run-time.
     
     
     int object_kind_count = 1;
    -inter_name *RTKinds::iname_inner(kind *K) {
    +inter_name *RTKinds::iname_inner(kind *K) {
         if (Kinds::is_proper_constructor(K)) {
             return RTKinds::constructed_kind_name(K);
         }
    @@ -1251,7 +1251,7 @@ each such kind, and needed at run-time.
         return NULL;
     }
     
    -inter_name *RTKinds::assure_iname_exists(kind *K) {
    +inter_name *RTKinds::assure_iname_exists(kind *K) {
         noun *nt = Kinds::Behaviour::get_noun(K);
         if (nt) {
             if (NounIdentifiers::iname_set(nt) == FALSE) {
    @@ -1309,7 +1309,7 @@ each such kind, and needed at run-time.
             }
     }
     
    -void RTKinds::compile_nnci(inter_name *name, int val) {
    +void RTKinds::compile_nnci(inter_name *name, int val) {
         Emit::named_numeric_constant(name, (inter_ti) val);
         Hierarchy::make_available(Emit::tree(), name);
     }
    @@ -2243,7 +2243,7 @@ and it seems best to reject the extra complexity needed.
     

    -void RTKinds::check_can_have_property(kind *K) {
    +void RTKinds::check_can_have_property(kind *K) {
         if (Kinds::Behaviour::is_object(K)) return;
         if (Kinds::Behaviour::definite(K) == FALSE) return;
         property *prn;
    diff --git a/docs/runtime-module/4-rtn.html b/docs/runtime-module/4-rtn.html
    index 625002089..b9848bd53 100644
    --- a/docs/runtime-module/4-rtn.html
    +++ b/docs/runtime-module/4-rtn.html
    @@ -81,7 +81,7 @@ already been set up, or not. Here's not:
     

    -packaging_state Routines::begin(inter_name *name) {
    +packaging_state Routines::begin(inter_name *name) {
         return Routines::begin_framed(name, NULL);
     }
     
    @@ -140,7 +140,7 @@ did not.

    -void Routines::end(packaging_state save) {
    +void Routines::end(packaging_state save) {
         kind *R_kind = LocalVariables::deduced_function_kind(currently_compiling_in_frame);
     
         inter_name *kernel_name = NULL, *public_name = currently_compiling_iname;
    diff --git a/docs/runtime-module/4-ts2.html b/docs/runtime-module/4-ts2.html
    index 2973d7e30..e6aefccba 100644
    --- a/docs/runtime-module/4-ts2.html
    +++ b/docs/runtime-module/4-ts2.html
    @@ -92,7 +92,7 @@ stipulations on place and possessions attached.
         CLASS_DEFINITION
     } test_scenario;
     
    -
    • The structure test_scenario is accessed in 4/rsp, 4/uoart, 4/vrb, 4/prp, 5/sc and here.
    +
    • The structure test_scenario is accessed in 4/rsp, 4/uoart, 4/vrb, 4/prp, 5/sc, 5/gpr and here.

    §2.

    diff --git a/docs/runtime-module/5-act.html b/docs/runtime-module/5-act.html
    index fb5c90969..a53b18468 100644
    --- a/docs/runtime-module/5-act.html
    +++ b/docs/runtime-module/5-act.html
    @@ -502,7 +502,7 @@ infrastructure, and we access it with a single call.
     }
     
    diff --git a/docs/runtime-module/5-ap.html b/docs/runtime-module/5-ap.html index 7a85a2cfa..8b6521198 100644 --- a/docs/runtime-module/5-ap.html +++ b/docs/runtime-module/5-ap.html @@ -911,7 +911,7 @@ and in this case we therefore ignore
  • This code is used in §7.
  • diff --git a/docs/runtime-module/5-bck.html b/docs/runtime-module/5-bck.html index 90f33ffd9..fa6bb3389 100644 --- a/docs/runtime-module/5-bck.html +++ b/docs/runtime-module/5-bck.html @@ -142,7 +142,7 @@
    • This code is used in §2.
    diff --git a/docs/runtime-module/5-bd.html b/docs/runtime-module/5-bd.html index e5dafa601..26cdec9d6 100644 --- a/docs/runtime-module/5-bd.html +++ b/docs/runtime-module/5-bd.html @@ -211,7 +211,7 @@ around it, in byte-accessible memory. }
    diff --git a/docs/runtime-module/5-cg.html b/docs/runtime-module/5-cg.html index 3afacf117..ef621bbd4 100644 --- a/docs/runtime-module/5-cg.html +++ b/docs/runtime-module/5-cg.html @@ -122,7 +122,7 @@ function togglePopup(material_id) { global_compilation_settings.no_verb_verb_exists = TRUE; }
    -
    • The structure cg_compilation_data is private to this section.
    +
    • The structure cg_compilation_data is accessed in 5/gpr and here.

    §2. Phases III and IV: Sort and Compile Grammar. At this highest level phases III and IV are intermingled, in that Phase III always precedes Phase IV for any given list of grammar lines, but each CG goes through both Phase III and IV before the next begins Phase III. So it @@ -161,6 +161,22 @@ in the final I6 output. inter_name *VERB_DIRECTIVE_TOPIC_iname = NULL; inter_name *VERB_DIRECTIVE_MULTIEXCEPT_iname = NULL; +inter_name *RTCommandGrammars::iname_for_I6_parser_token(cg_token *cgt) { + switch (cgt->grammar_token_code) { + case NOUN_TOKEN_GTC: return VERB_DIRECTIVE_NOUN_iname; + case MULTI_TOKEN_GTC: return VERB_DIRECTIVE_MULTI_iname; + case MULTIINSIDE_TOKEN_GTC: return VERB_DIRECTIVE_MULTIINSIDE_iname; + case MULTIHELD_TOKEN_GTC: return VERB_DIRECTIVE_MULTIHELD_iname; + case HELD_TOKEN_GTC: return VERB_DIRECTIVE_HELD_iname; + case CREATURE_TOKEN_GTC: return VERB_DIRECTIVE_CREATURE_iname; + case TOPIC_TOKEN_GTC: return VERB_DIRECTIVE_TOPIC_iname; + case MULTIEXCEPT_TOKEN_GTC: return VERB_DIRECTIVE_MULTIEXCEPT_iname; + default: internal_error("tried to find inter name for invalid GTC"); + } + return NULL; to prevent a gcc error: never reached +} + + inter_name *RTCommandGrammars::grammar_constant(int N, int V) { inter_name *iname = Hierarchy::find(N); Emit::named_numeric_constant(iname, 1); @@ -233,7 +249,7 @@ by exploring each CG in turn.

    -packaging_state RTCommandGrammars::cg_compile_Verb_directive_header(command_grammar *cg, inter_name *array_iname) {
    +packaging_state RTCommandGrammars::cg_compile_Verb_directive_header(command_grammar *cg, inter_name *array_iname) {
         if (cg->cg_is != CG_IS_COMMAND)
             internal_error("tried to compile Verb from non-command CG");
         if (CGLines::list_length(cg) == 0)
    @@ -267,7 +283,7 @@ specified for all things. (This mimics I6 class-to-instance inheritance.)
     

    -void RTCommandGrammars::cg_compile_parse_name_lines(gpr_kit *gprk, command_grammar *cg) {
    +void RTCommandGrammars::cg_compile_parse_name_lines(gpr_kit *gprk, command_grammar *cg) {
         inference_subject *subj = cg->subj_understood;
     
         if (PARSING_DATA_FOR_SUBJ(subj)->understand_as_this_object != cg)
    @@ -291,7 +307,7 @@ specified for all things. (This mimics I6 class-to-instance inheritance.)
     

    -void RTCommandGrammars::cg_compile_lines(gpr_kit *gprk, command_grammar *cg) {
    +void RTCommandGrammars::cg_compile_lines(gpr_kit *gprk, command_grammar *cg) {
         CommandsIndex::list_assert_ownership(cg);  Mark for later indexing
         CommandGrammars::sort_command_grammar(cg);  Phase III for the CGLs in the CG happens here
         RTCommandGrammarLines::sorted_line_list_compile(gprk,
    @@ -313,7 +329,7 @@ next priority, and so on up the hierarchy.
     

    -void RTCommandGrammars::compile(command_grammar *cg) {
    +void RTCommandGrammars::compile(command_grammar *cg) {
         if (CGLines::list_length(cg) == 0) return;
     
         LOGIF(GRAMMAR, "Compiling command grammar $G\n", cg);
    @@ -331,19 +347,19 @@ next priority, and so on up the hierarchy.
                 break;
             }
             case CG_IS_TOKEN: {
    -            gpr_kit gprk = UnderstandValueTokens::new_kit();
    +            gpr_kit gprk = UnderstandValueTokens::new_kit();
                 if (cg->compilation_data.cg_token_iname == NULL) internal_error("cg token not ready");
                 packaging_state save = Routines::begin(cg->compilation_data.cg_token_iname);
    -            UnderstandValueTokens::add_original(&gprk);
    -            UnderstandValueTokens::add_standard_set(&gprk);
    +            UnderstandValueTokens::add_original(&gprk);
    +            UnderstandValueTokens::add_standard_set(&gprk);
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk.original_wn_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk.original_wn_s);
                     Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk.rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk.rv_s);
                     Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_PREPOSITION_HL));
                 Produce::up(Emit::tree());
                 RTCommandGrammars::cg_compile_lines(&gprk, cg);
    @@ -355,25 +371,25 @@ next priority, and so on up the hierarchy.
                 break;
             }
             case CG_IS_CONSULT: {
    -            gpr_kit gprk = UnderstandValueTokens::new_kit();
    -            inter_name *iname = UnderstandGeneralTokens::consult_iname(cg);
    +            gpr_kit gprk = UnderstandValueTokens::new_kit();
    +            inter_name *iname = UnderstandGeneralTokens::consult_iname(cg);
                 packaging_state save = Routines::begin(iname);
    -            UnderstandValueTokens::add_range_calls(&gprk);
    -            UnderstandValueTokens::add_original(&gprk);
    -            UnderstandValueTokens::add_standard_set(&gprk);
    +            UnderstandValueTokens::add_range_calls(&gprk);
    +            UnderstandValueTokens::add_original(&gprk);
    +            UnderstandValueTokens::add_standard_set(&gprk);
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
                     Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                Produce::val_symbol(Emit::tree(), K_value, gprk.range_from_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk.range_from_s);
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk.original_wn_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk.original_wn_s);
                     Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk.rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk.rv_s);
                     Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_PREPOSITION_HL));
                 Produce::up(Emit::tree());
                 RTCommandGrammars::cg_compile_lines(&gprk, cg);
    @@ -385,11 +401,11 @@ next priority, and so on up the hierarchy.
                 break;
             }
             case CG_IS_SUBJECT: {
    -            gpr_kit gprk = UnderstandValueTokens::new_kit();
    +            gpr_kit gprk = UnderstandValueTokens::new_kit();
                 packaging_state save = Emit::unused_packaging_state();
    -            if (UnderstandGeneralTokens::compile_parse_name_head(&save, &gprk, cg->subj_understood, cg, NULL)) {
    +            if (UnderstandGeneralTokens::compile_parse_name_head(&save, &gprk, cg->subj_understood, cg, NULL)) {
                     RTCommandGrammars::cg_compile_parse_name_lines(&gprk, cg);
    -                UnderstandGeneralTokens::compile_parse_name_tail(&gprk);
    +                UnderstandGeneralTokens::compile_parse_name_tail(&gprk);
                     Routines::end(save);
                 }
                 break;
    @@ -398,19 +414,19 @@ next priority, and so on up the hierarchy.
                 internal_error("iv");
                 break;
             case CG_IS_PROPERTY_NAME: {
    -            gpr_kit gprk = UnderstandValueTokens::new_kit();
    +            gpr_kit gprk = UnderstandValueTokens::new_kit();
                 if (cg->compilation_data.cg_prn_iname == NULL) internal_error("PRN PN not ready");
                 packaging_state save = Routines::begin(cg->compilation_data.cg_prn_iname);
    -            UnderstandValueTokens::add_original(&gprk);
    -            UnderstandValueTokens::add_standard_set(&gprk);
    +            UnderstandValueTokens::add_original(&gprk);
    +            UnderstandValueTokens::add_standard_set(&gprk);
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk.original_wn_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk.original_wn_s);
                     Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk.rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk.rv_s);
                     Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_PREPOSITION_HL));
                 Produce::up(Emit::tree());
                 RTCommandGrammars::cg_compile_lines(&gprk, cg);
    @@ -424,7 +440,7 @@ next priority, and so on up the hierarchy.
         }
     }
     
    -void RTCommandGrammars::compile_iv(gpr_kit *gprk, command_grammar *cg) {
    +void RTCommandGrammars::compile_iv(gpr_kit *gprk, command_grammar *cg) {
         if (CGLines::list_length(cg) > 0) {
             LOGIF(GRAMMAR, "Compiling command grammar $G\n", cg);
             current_sentence = cg->where_cg_created;
    @@ -434,12 +450,12 @@ next priority, and so on up the hierarchy.
         }
     }
     
    -void RTCommandGrammars::emit_determination_type(determination_type *gty) {
    +void RTCommandGrammars::emit_determination_type(determination_type *gty) {
         Specifications::Compiler::emit_as_val(K_value, gty->term[0].what);
     }
     
    diff --git a/docs/runtime-module/5-cgl.html b/docs/runtime-module/5-cgl.html index bd63a548c..087e4a02d 100644 --- a/docs/runtime-module/5-cgl.html +++ b/docs/runtime-module/5-cgl.html @@ -169,7 +169,7 @@ the mistake. inter_name *MistakeAction_iname = NULL; -int RTCommandGrammarLines::cgl_compile_result_of_mistake(gpr_kit *gprk, cg_line *cgl) { +int RTCommandGrammarLines::cgl_compile_result_of_mistake(gpr_kit *gprk, cg_line *cgl) { if (cgl->mistaken) { if (MistakeAction_iname == NULL) internal_error("no MistakeAction yet"); Emit::array_iname_entry(VERB_DIRECTIVE_RESULT_iname); @@ -280,7 +280,7 @@ the mistake. } } -void RTCommandGrammarLines::cgl_compile_extra_token_for_condition(gpr_kit *gprk, cg_line *cgl, +void RTCommandGrammarLines::cgl_compile_extra_token_for_condition(gpr_kit *gprk, cg_line *cgl, int cg_is, inter_symbol *current_label) { if (CGLines::conditional(cgl)) { if (cgl->compilation_data.cond_token_iname == NULL) internal_error("CGL cond token not ready"); @@ -322,7 +322,7 @@ of the name pro

    -void RTCommandGrammarLines::sorted_line_list_compile(gpr_kit *gprk,
    +void RTCommandGrammarLines::sorted_line_list_compile(gpr_kit *gprk,
         int cg_is, command_grammar *cg, int genuinely_verbal) {
         LOG_INDENT;
         LOOP_THROUGH_SORTED_CG_LINES(cgl, cg)
    @@ -355,7 +355,7 @@ command CGs) have not yet been type-checked, whereas all others have.
     

    -void RTCommandGrammarLines::compile_cg_line(gpr_kit *gprk, cg_line *cgl, int cg_is, command_grammar *cg,
    +void RTCommandGrammarLines::compile_cg_line(gpr_kit *gprk, cg_line *cgl, int cg_is, command_grammar *cg,
         int genuinely_verbal) {
         int i;
         int token_values;
    @@ -415,7 +415,7 @@ command CGs) have not yet been type-checked, whereas all others have.
             Produce::down(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), EQ_BIP);
                 Produce::down(Emit::tree());
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->instance_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->instance_s);
                     RTCommandGrammars::emit_determination_type(&(cgl->cgl_type));
                 Produce::up(Emit::tree());
                 Produce::code(Emit::tree());
    @@ -453,18 +453,18 @@ command CGs) have not yet been type-checked, whereas all others have.
             case CG_IS_TOKEN:
                 Produce::inv_primitive(Emit::tree(), RETURN_BIP);
                 Produce::down(Emit::tree());
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                 Produce::up(Emit::tree());
                 Produce::place_label(Emit::tree(), fail_label);
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                     Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_PREPOSITION_HL));
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
                     Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->original_wn_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->original_wn_s);
                 Produce::up(Emit::tree());
                 break;
             case CG_IS_CONSULT:
    @@ -474,7 +474,7 @@ command CGs) have not yet been type-checked, whereas all others have.
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), EQ_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->range_words_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->range_words_s);
                             Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), EQ_BIP);
    @@ -482,16 +482,16 @@ command CGs) have not yet been type-checked, whereas all others have.
                             Produce::inv_primitive(Emit::tree(), MINUS_BIP);
                             Produce::down(Emit::tree());
                                 Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->range_from_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->range_from_s);
                             Produce::up(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->range_words_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->range_words_s);
                         Produce::up(Emit::tree());
                     Produce::up(Emit::tree());
                     Produce::code(Emit::tree());
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), RETURN_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                         Produce::up(Emit::tree());
                     Produce::up(Emit::tree());
                 Produce::up(Emit::tree());
    @@ -499,17 +499,17 @@ command CGs) have not yet been type-checked, whereas all others have.
                 Produce::place_label(Emit::tree(), fail_label);
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                     Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_PREPOSITION_HL));
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
                     Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->original_wn_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->original_wn_s);
                 Produce::up(Emit::tree());
                 break;
             case CG_IS_SUBJECT:
    -            UnderstandGeneralTokens::after_gl_failed(gprk, fail_label, cgl->pluralised);
    +            UnderstandGeneralTokens::after_gl_failed(gprk, fail_label, cgl->pluralised);
                 break;
             case CG_IS_VALUE:
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
    @@ -525,7 +525,7 @@ command CGs) have not yet been type-checked, whereas all others have.
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
                     Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->original_wn_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->original_wn_s);
                 Produce::up(Emit::tree());
                 break;
         }
    @@ -552,7 +552,7 @@ command CGs) have not yet been type-checked, whereas all others have.
     

    §7.

    -void RTCommandGrammarLines::compile_token_line(gpr_kit *gprk, int code_mode, cg_token *cgt, cg_token *cgt_to, int cg_is, int consult_mode,
    +void RTCommandGrammarLines::compile_token_line(gpr_kit *gprk, int code_mode, cg_token *cgt, cg_token *cgt_to, int cg_is, int consult_mode,
         int *token_values, kind **token_value_kinds, inter_symbol *group_wn_s, inter_symbol *fail_label) {
         int lexeme_equivalence_class = 0;
         int alternative_number = 0;
    @@ -563,7 +563,7 @@ command CGs) have not yet been type-checked, whereas all others have.
         LOG_INDENT;
         for (; cgt; cgt = cgt->next_token) {
             LOGIF(GRAMMAR_CONSTRUCTION, "Compiling token $c\n", cgt);
    -        if ((cgt->grammar_token_code == TOPIC_TOKEN_GTC) && (cgt->next_token) &&
    +        if ((CGTokens::is_topic(cgt)) && (cgt->next_token) &&
                 (CGTokens::is_literal(cgt->next_token) == FALSE)) {
                 StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_TextFollowedBy),
                     "a '[text]' token must either match the end of some text, or "
    @@ -602,8 +602,6 @@ command CGs) have not yet been type-checked, whereas all others have.
                 alternative_number = 1;
             }
     
    -if (empty_text_allowed_in_lexeme) LOG("empty_text_allowed_in_lexeme!\n");
    -
             inter_symbol *jump_on_fail = fail_label;
     
             if (lexeme_equivalence_class > 0) {
    @@ -611,7 +609,7 @@ command CGs) have not yet been type-checked, whereas all others have.
                     if (first_token_in_lexeme) {
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->group_wn_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->group_wn_s);
                             Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
                         Produce::up(Emit::tree());
                     }
    @@ -624,7 +622,7 @@ command CGs) have not yet been type-checked, whereas all others have.
                     Produce::inv_primitive(Emit::tree(), STORE_BIP);
                     Produce::down(Emit::tree());
                         Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->group_wn_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->group_wn_s);
                     Produce::up(Emit::tree());
     
                     if ((last_token_in_lexeme == FALSE) || (empty_text_allowed_in_lexeme)) {
    @@ -671,7 +669,7 @@ command CGs) have not yet been type-checked, whereas all others have.
                             Produce::inv_primitive(Emit::tree(), STORE_BIP);
                             Produce::down(Emit::tree());
                                 Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->group_wn_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->group_wn_s);
                             Produce::up(Emit::tree());
                         }
                         if (eog_reserved_label) Produce::place_label(Emit::tree(), eog_reserved_label);
    @@ -712,11 +710,11 @@ command CGs) have not yet been type-checked, whereas all others have.
         slash_gpr *sgpr;
         LOOP_OVER(sgpr, slash_gpr) {
             packaging_state save = Routines::begin(sgpr->sgpr_iname);
    -        gpr_kit gprk = UnderstandValueTokens::new_kit();
    -        UnderstandValueTokens::add_original(&gprk);
    -        UnderstandValueTokens::add_standard_set(&gprk);
    +        gpr_kit gprk = UnderstandValueTokens::new_kit();
    +        UnderstandValueTokens::add_original(&gprk);
    +        UnderstandValueTokens::add_standard_set(&gprk);
     
    -        RTCommandGrammarLines::compile_token_line(&gprk, TRUE, sgpr->first_choice, sgpr->last_choice, CG_IS_TOKEN, FALSE, NULL, NULL, gprk.group_wn_s, NULL);
    +        RTCommandGrammarLines::compile_token_line(&gprk, TRUE, sgpr->first_choice, sgpr->last_choice, CG_IS_TOKEN, FALSE, NULL, NULL, gprk.group_wn_s, NULL);
             Produce::inv_primitive(Emit::tree(), RETURN_BIP);
             Produce::down(Emit::tree());
                 Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_PREPOSITION_HL));
    @@ -758,7 +756,7 @@ nothing else.
     
     
     int ol_loop_counter = 0;
    -kind *RTCommandGrammarLines::compile_token(gpr_kit *gprk, cg_token *cgt, int code_mode,
    +kind *RTCommandGrammarLines::compile_token(gpr_kit *gprk, cg_token *cgt, int code_mode,
         inter_symbol *failure_label, int consult_mode) {
         int wn = Wordings::first_wn(CGTokens::text(cgt));
         parse_node *spec;
    @@ -792,7 +790,7 @@ nothing else.
             Produce::inv_call_iname(Emit::tree(), Hierarchy::find(ARTICLEDESCRIPTORS_HL));
             Produce::inv_primitive(Emit::tree(), STORE_BIP);
             Produce::down(Emit::tree());
    -            Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
    +            Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
                 Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
             Produce::up(Emit::tree());
             if (bp == R_containment) {
    @@ -850,11 +848,11 @@ nothing else.
     
                 Produce::inv_primitive(Emit::tree(), OBJECTLOOP_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                     Produce::val_iname(Emit::tree(), K_value, RTKinds::I6_classname(K_object));
                     Produce::inv_primitive(Emit::tree(), IN_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                         Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
                     Produce::up(Emit::tree());
                     Produce::code(Emit::tree());
    @@ -864,7 +862,7 @@ nothing else.
                             Produce::down(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), HAS_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                                     Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(P_worn));
                                 Produce::up(Emit::tree());
                                 Produce::code(Emit::tree());
    @@ -880,7 +878,7 @@ nothing else.
                                 Produce::down(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), HAS_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                    Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                                         Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(P_worn));
                                     Produce::up(Emit::tree());
                                 Produce::up(Emit::tree());
    @@ -893,17 +891,17 @@ nothing else.
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
                             Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
                             Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
                             Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                 Produce::inv_call_iname(Emit::tree(), Hierarchy::find(TRYGIVENOBJECT_HL));
                                 Produce::down(Emit::tree());
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                                     Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
                                 Produce::up(Emit::tree());
                             Produce::up(Emit::tree());
    @@ -913,7 +911,7 @@ nothing else.
                             Produce::inv_primitive(Emit::tree(), GT_BIP);
                             Produce::down(Emit::tree());
                                 Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                             Produce::up(Emit::tree());
                             Produce::code(Emit::tree());
                             Produce::down(Emit::tree());
    @@ -927,14 +925,14 @@ nothing else.
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                     Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
                 Produce::up(Emit::tree());
                 Jump to our doom10.2;
                 Produce::place_label(Emit::tree(), exit_label);
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                     Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
                 Produce::up(Emit::tree());
             } else if (bp == R_incorporation) {
    @@ -944,7 +942,7 @@ nothing else.
                 DISCARD_TEXT(L)
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                     Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
                     Produce::down(Emit::tree());
                         Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
    @@ -953,23 +951,23 @@ nothing else.
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), WHILE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                     Produce::code(Emit::tree());
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
                             Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
                             Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
                             Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                 Produce::inv_call_iname(Emit::tree(), Hierarchy::find(TRYGIVENOBJECT_HL));
                                 Produce::down(Emit::tree());
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                                     Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
                                 Produce::up(Emit::tree());
                             Produce::up(Emit::tree());
    @@ -979,7 +977,7 @@ nothing else.
                             Produce::inv_primitive(Emit::tree(), GT_BIP);
                             Produce::down(Emit::tree());
                                 Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                             Produce::up(Emit::tree());
                             Produce::code(Emit::tree());
                             Produce::down(Emit::tree());
    @@ -991,10 +989,10 @@ nothing else.
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                             Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                                 Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(COMPONENT_SIBLING_HL));
                             Produce::up(Emit::tree());
                         Produce::up(Emit::tree());
    @@ -1002,14 +1000,14 @@ nothing else.
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                     Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
                 Produce::up(Emit::tree());
                 Jump to our doom10.2;
                 Produce::place_label(Emit::tree(), exit_label);
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                     Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
                 Produce::up(Emit::tree());
             } else if (bp == R_equality) {
    @@ -1054,7 +1052,7 @@ nothing else.
                 }
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                     Produce::inv_call(Emit::tree(), Site::veneer_symbol(Emit::tree(), PARENT_VSYMB));
                     Produce::down(Emit::tree());
                         Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
    @@ -1064,17 +1062,17 @@ nothing else.
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
                     Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
                     Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
                     Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                         Produce::inv_call_iname(Emit::tree(), Hierarchy::find(TRYGIVENOBJECT_HL));
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                             Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
                         Produce::up(Emit::tree());
                     Produce::up(Emit::tree());
    @@ -1084,14 +1082,14 @@ nothing else.
                     Produce::inv_primitive(Emit::tree(), EQ_BIP);
                     Produce::down(Emit::tree());
                         Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                     Produce::up(Emit::tree());
                     Then jump to our doom10.1;
                 Produce::up(Emit::tree());
             } else if (BinaryPredicates::get_reversal(bp) == R_incorporation) {
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
    -                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                     Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
                     Produce::down(Emit::tree());
                         Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
    @@ -1101,17 +1099,17 @@ nothing else.
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
                     Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                 Produce::up(Emit::tree());
                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                 Produce::down(Emit::tree());
                     Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
                     Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                         Produce::inv_call_iname(Emit::tree(), Hierarchy::find(TRYGIVENOBJECT_HL));
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                             Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
                         Produce::up(Emit::tree());
                     Produce::up(Emit::tree());
    @@ -1121,7 +1119,7 @@ nothing else.
                     Produce::inv_primitive(Emit::tree(), EQ_BIP);
                     Produce::down(Emit::tree());
                         Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                     Produce::up(Emit::tree());
                     Then jump to our doom10.1;
                 Produce::up(Emit::tree());
    @@ -1144,7 +1142,7 @@ nothing else.
                         LOGIF(GRAMMAR_CONSTRUCTION, "Term 1 of BP is %u\n", K);
                         Produce::inv_primitive(Emit::tree(), OBJECTLOOPX_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                             Produce::val_iname(Emit::tree(), K_value, RTKinds::I6_classname(K));
                             Produce::code(Emit::tree());
                             Produce::down(Emit::tree());
    @@ -1153,7 +1151,7 @@ nothing else.
                                     Produce::inv_primitive(Emit::tree(), EQ_BIP);
                                     Produce::down(Emit::tree());
                                         pcalc_term rv_term = Terms::new_constant(
    -                                        Lvalues::new_LOCAL_VARIABLE(EMPTY_WORDING, gprk->rv_lv));
    +                                        Lvalues::new_LOCAL_VARIABLE(EMPTY_WORDING, gprk->rv_lv));
                                         pcalc_term self_term = Terms::new_constant(
                                             Rvalues::new_self_object_constant());
                                         if (reverse)
    @@ -1194,7 +1192,7 @@ nothing else.
     
                                     Produce::inv_primitive(Emit::tree(), STORE_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                    Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                                         Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
                                         Produce::down(Emit::tree());
                                             Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
    @@ -1205,7 +1203,7 @@ nothing else.
                                     Produce::down(Emit::tree());
                                         Produce::inv_primitive(Emit::tree(), EQ_BIP);
                                         Produce::down(Emit::tree());
    -                                        Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                        Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
     
                             continue_loop_on_fail = FALSE;
                         } else {
    @@ -1227,7 +1225,7 @@ nothing else.
                             }
                             Produce::inv_primitive(Emit::tree(), OBJECTLOOPX_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                            Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                                 Produce::val_iname(Emit::tree(), K_value, RTKinds::I6_classname(K));
                                 Produce::code(Emit::tree());
                                 Produce::down(Emit::tree());
    @@ -1239,14 +1237,14 @@ nothing else.
                                             Produce::down(Emit::tree());
                                                 Produce::inv_primitive(Emit::tree(), PROVIDES_BIP);
                                                 Produce::down(Emit::tree());
    -                                                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                                Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                                                     Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(prn));
                                                 Produce::up(Emit::tree());
                                                 Produce::inv_primitive(Emit::tree(), EQ_BIP);
                                                 Produce::down(Emit::tree());
                                                     Produce::inv_primitive(Emit::tree(), PROPERTYVALUE_BIP);
                                                     Produce::down(Emit::tree());
    -                                                    Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                                    Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                                                         Produce::val_iname(Emit::tree(), K_value, RTProperties::iname(prn));
                                                     Produce::up(Emit::tree());
                                                     Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SELF_HL));
    @@ -1283,17 +1281,17 @@ nothing else.
                             Produce::inv_primitive(Emit::tree(), STORE_BIP);
                             Produce::down(Emit::tree());
                                 Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                             Produce::up(Emit::tree());
                             Produce::inv_primitive(Emit::tree(), STORE_BIP);
                             Produce::down(Emit::tree());
                                 Produce::ref_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
                                 Produce::inv_primitive(Emit::tree(), PLUS_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                     Produce::inv_call_iname(Emit::tree(), Hierarchy::find(TRYGIVENOBJECT_HL));
                                     Produce::down(Emit::tree());
    -                                    Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                    Produce::val_symbol(Emit::tree(), K_value, gprk->rv_s);
                                         Produce::val(Emit::tree(), K_truth_state, LITERAL_IVAL, 1);
                                     Produce::up(Emit::tree());
                                 Produce::up(Emit::tree());
    @@ -1309,7 +1307,7 @@ nothing else.
                                 Produce::inv_primitive(Emit::tree(), GT_BIP);
                                 Produce::down(Emit::tree());
                                     Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(WN_HL));
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                 Produce::up(Emit::tree());
                                 Produce::code(Emit::tree());
                                 Produce::down(Emit::tree());
    @@ -1324,24 +1322,22 @@ nothing else.
                     Produce::up(Emit::tree());
                     Produce::inv_primitive(Emit::tree(), STORE_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                    Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                         Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
                     Produce::up(Emit::tree());
                     Jump to our doom10.2;
                     Produce::place_label(Emit::tree(), exit_label);
                     Produce::inv_primitive(Emit::tree(), STORE_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                    Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                         Produce::val(Emit::tree(), K_number, LITERAL_IVAL, 0);
                     Produce::up(Emit::tree());
                 }
                 return NULL;
             }
     
    -    spec = cgt->grammar_value;
    -    if (spec == NULL) CGTokens::determine(cgt, 10, NULL);
    -    spec = cgt->grammar_value;
    -    if (spec == NULL) internal_error("NULL result of non-preposition token");
    +    spec = cgt->what_token_describes;
    +    if (cgt->defined_by) spec = ParsingPlugin::rvalue_from_command_grammar(cgt->defined_by);
     
         if (Specifications::is_kind_like(spec)) {
             kind *K = Node::get_kind_of_value(spec);
    @@ -1353,7 +1349,7 @@ nothing else.
                     if (code_mode) {
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
                             Produce::inv_call_iname(Emit::tree(), Hierarchy::find(PARSETOKENSTOPPED_HL));
                             Produce::down(Emit::tree());
                                 Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_TT_HL));
    @@ -1367,14 +1363,14 @@ nothing else.
                         Produce::down(Emit::tree());
                             Produce::inv_primitive(Emit::tree(), NE_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                 Produce::val_iname(Emit::tree(), K_number, Hierarchy::find(GPR_NUMBER_HL));
                             Produce::up(Emit::tree());
                             Then jump to our doom10.1;
                         Produce::up(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                        Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                             Produce::val_iname(Emit::tree(), K_number, Hierarchy::find(GPR_NUMBER_HL));
                         Produce::up(Emit::tree());
                     } else {
    @@ -1402,12 +1398,11 @@ nothing else.
             return K_object;
         } else {
             kind *K = NULL;
    -        int gtc = cgt->grammar_token_code;
    -        if (gtc < 0) {
    -            inter_name *i6_token_iname = CGTokens::iname_for_special_token(gtc);
    -            K = CGTokens::kind_for_special_token(gtc);
    +        if (CGTokens::is_I6_parser_token(cgt)) {
    +            inter_name *i6_token_iname = RTCommandGrammars::iname_for_I6_parser_token(cgt);
    +            K = Descriptions::explicit_kind(cgt->what_token_describes);
                 if (code_mode) {
    -                if ((consult_mode) && (gtc == TOPIC_TOKEN_GTC)) {
    +                if ((consult_mode) && (CGTokens::is_topic(cgt))) {
                         StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_TextTokenRestricted),
                             "the '[text]' token is not allowed with 'matches' "
                             "or in table columns",
    @@ -1418,7 +1413,7 @@ nothing else.
                     }
                     Produce::inv_primitive(Emit::tree(), STORE_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
    +                    Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
                         Produce::inv_call_iname(Emit::tree(), Hierarchy::find(PARSETOKENSTOPPED_HL));
                         Produce::down(Emit::tree());
                             Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(ELEMENTARY_TT_HL));
    @@ -1429,15 +1424,15 @@ nothing else.
                     Produce::down(Emit::tree());
                         Produce::inv_primitive(Emit::tree(), EQ_BIP);
                         Produce::down(Emit::tree());
    -                        Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                        Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                             Produce::val_iname(Emit::tree(), K_number, Hierarchy::find(GPR_FAIL_HL));
                         Produce::up(Emit::tree());
                         Then jump to our doom10.1;
                     Produce::up(Emit::tree());
                     Produce::inv_primitive(Emit::tree(), STORE_BIP);
                     Produce::down(Emit::tree());
    -                    Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    -                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                    Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                     Produce::up(Emit::tree());
                 } else {
                     Emit::array_iname_entry(i6_token_iname);
    @@ -1449,28 +1444,28 @@ nothing else.
                         if (code_mode) {
                             Produce::inv_primitive(Emit::tree(), STORE_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
    +                            Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
                                 Produce::inv_call_iname(Emit::tree(), Hierarchy::find(PARSETOKENSTOPPED_HL));
                                 Produce::down(Emit::tree());
    -                                UnderstandFilterTokens::compile_id(gtc);
    +                                UnderstandFilterTokens::compile_id(cgt->noun_filter);
                                 Produce::up(Emit::tree());
                             Produce::up(Emit::tree());
                             Produce::inv_primitive(Emit::tree(), IF_BIP);
                             Produce::down(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), EQ_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                     Produce::val_iname(Emit::tree(), K_number, Hierarchy::find(GPR_FAIL_HL));
                                 Produce::up(Emit::tree());
                                 Then jump to our doom10.1;
                             Produce::up(Emit::tree());
                             Produce::inv_primitive(Emit::tree(), STORE_BIP);
                             Produce::down(Emit::tree());
    -                            Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    -                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                            Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                            Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                             Produce::up(Emit::tree());
                         } else {
    -                        UnderstandFilterTokens::emit_id(gtc);
    +                        UnderstandFilterTokens::emit_id(cgt->noun_filter);
                         }
                     } else {
                         if (Kinds::Behaviour::offers_I6_GPR(K)) {
    @@ -1478,7 +1473,7 @@ nothing else.
                             if (code_mode) {
                                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
                                     Produce::inv_call_iname(Emit::tree(), Hierarchy::find(PARSETOKENSTOPPED_HL));
                                     Produce::down(Emit::tree());
                                         Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_TT_HL));
    @@ -1492,14 +1487,14 @@ nothing else.
                                 Produce::down(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), NE_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                         Produce::val_iname(Emit::tree(), K_number, Hierarchy::find(GPR_NUMBER_HL));
                                     Produce::up(Emit::tree());
                                     Then jump to our doom10.1;
                                 Produce::up(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
                                     Produce::val_iname(Emit::tree(), K_number, Hierarchy::find(GPR_NUMBER_HL));
                                 Produce::up(Emit::tree());
                             } else {
    @@ -1512,40 +1507,39 @@ nothing else.
                             if (code_mode) {
                                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
                                     Produce::inv_call_iname(Emit::tree(), Hierarchy::find(PARSETOKENSTOPPED_HL));
                                     Produce::down(Emit::tree());
    -                                    UnderstandFilterTokens::compile_id(gtc);
    +                                    UnderstandFilterTokens::compile_id(cgt->noun_filter);
                                     Produce::up(Emit::tree());
                                 Produce::up(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), IF_BIP);
                                 Produce::down(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), EQ_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                         Produce::val_iname(Emit::tree(), K_number, Hierarchy::find(GPR_FAIL_HL));
                                     Produce::up(Emit::tree());
                                     Then jump to our doom10.1;
                                 Produce::up(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                 Produce::up(Emit::tree());
                             } else {
    -                            UnderstandFilterTokens::emit_id(gtc);
    +                            UnderstandFilterTokens::emit_id(cgt->noun_filter);
                             }
                             K = K_object;
                         } else internal_error("no token for description");
                     }
                 } else {
    -                if (Node::is(spec, CONSTANT_NT)) {
    -                    if ((K_understanding) && (Rvalues::is_CONSTANT_of_kind(spec, K_understanding))) {
    -                        cg = ParsingPlugin::rvalue_to_command_grammar(spec);
    +                    if (cgt->defined_by) {
    +                        cg = cgt->defined_by;
                             if (code_mode) {
                                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
                                     Produce::inv_call_iname(Emit::tree(), Hierarchy::find(PARSETOKENSTOPPED_HL));
                                     Produce::down(Emit::tree());
                                         Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_TT_HL));
    @@ -1556,7 +1550,7 @@ nothing else.
                                 Produce::down(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), EQ_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                         Produce::val_iname(Emit::tree(), K_number, Hierarchy::find(GPR_FAIL_HL));
                                     Produce::up(Emit::tree());
                                     Then jump to our doom10.1;
    @@ -1566,15 +1560,15 @@ nothing else.
                                 Produce::down(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), NE_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                         Produce::val_iname(Emit::tree(), K_number, Hierarchy::find(GPR_PREPOSITION_HL));
                                     Produce::up(Emit::tree());
                                     Produce::code(Emit::tree());
                                     Produce::down(Emit::tree());
                                         Produce::inv_primitive(Emit::tree(), STORE_BIP);
                                         Produce::down(Emit::tree());
    -                                        Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    -                                        Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                        Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                        Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                         Produce::up(Emit::tree());
                                     Produce::up(Emit::tree());
                                 Produce::up(Emit::tree());
    @@ -1582,33 +1576,34 @@ nothing else.
                                 Emit::array_iname_entry(RTCommandGrammars::i6_token_as_iname(cg));
                             }
                             K = CommandGrammars::get_kind_matched(cg);
    -                    }
    +                    } else
    +                if (Node::is(spec, CONSTANT_NT)) {
                         if (Rvalues::is_object(spec)) {
                             if (code_mode) {
                                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s);
                                     Produce::inv_call_iname(Emit::tree(), Hierarchy::find(PARSETOKENSTOPPED_HL));
                                     Produce::down(Emit::tree());
    -                                    UnderstandFilterTokens::compile_id(gtc);
    +                                    UnderstandFilterTokens::compile_id(cgt->noun_filter);
                                     Produce::up(Emit::tree());
                                 Produce::up(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), IF_BIP);
                                 Produce::down(Emit::tree());
                                     Produce::inv_primitive(Emit::tree(), EQ_BIP);
                                     Produce::down(Emit::tree());
    -                                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                    Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                         Produce::val_iname(Emit::tree(), K_number, Hierarchy::find(GPR_FAIL_HL));
                                     Produce::up(Emit::tree());
                                     Then jump to our doom10.1;
                                 Produce::up(Emit::tree());
                                 Produce::inv_primitive(Emit::tree(), STORE_BIP);
                                 Produce::down(Emit::tree());
    -                                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    -                                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
    +                                Produce::ref_symbol(Emit::tree(), K_value, gprk->rv_s);
    +                                Produce::val_symbol(Emit::tree(), K_value, gprk->w_s);
                                 Produce::up(Emit::tree());
                             } else {
    -                            UnderstandFilterTokens::emit_id(gtc);
    +                            UnderstandFilterTokens::emit_id(cgt->noun_filter);
                             }
                             K = K_object;
                         }
    @@ -1640,7 +1635,7 @@ nothing else.
     
    diff --git a/docs/runtime-module/5-ef.html b/docs/runtime-module/5-ef.html index e7ae5ab14..2cc082aea 100644 --- a/docs/runtime-module/5-ef.html +++ b/docs/runtime-module/5-ef.html @@ -129,7 +129,7 @@
    • The structure external_file_compilation_data is private to this section.
    diff --git a/docs/runtime-module/5-fgr.html b/docs/runtime-module/5-fgr.html index f5aba0aeb..f57e07260 100644 --- a/docs/runtime-module/5-fgr.html +++ b/docs/runtime-module/5-fgr.html @@ -77,7 +77,7 @@ }
    diff --git a/docs/runtime-module/5-gng.html b/docs/runtime-module/5-gng.html index 0e9bcc2e2..e605a6cd6 100644 --- a/docs/runtime-module/5-gng.html +++ b/docs/runtime-module/5-gng.html @@ -134,7 +134,7 @@ }
    diff --git a/docs/runtime-module/5-los.html b/docs/runtime-module/5-los.html index 8e776f5ee..928c06c14 100644 --- a/docs/runtime-module/5-los.html +++ b/docs/runtime-module/5-los.html @@ -149,7 +149,7 @@ function togglePopup(material_id) {
    • This code is used in §2.
    diff --git a/docs/runtime-module/5-nap.html b/docs/runtime-module/5-nap.html index 9d15f36a9..d79f4aa1b 100644 --- a/docs/runtime-module/5-nap.html +++ b/docs/runtime-module/5-nap.html @@ -112,7 +112,7 @@ function togglePopup(material_id) {
    • The structure nap_compilation_data is private to this section.
    diff --git a/docs/runtime-module/5-nmn.html b/docs/runtime-module/5-nmn.html index 30632ed98..993ce656b 100644 --- a/docs/runtime-module/5-nmn.html +++ b/docs/runtime-module/5-nmn.html @@ -186,7 +186,7 @@ function togglePopup(material_id) {
    • The structure short_name_notice is private to this section.
    diff --git a/docs/runtime-module/5-prs.html b/docs/runtime-module/5-prs.html index 69cd63b2b..ed88462c6 100644 --- a/docs/runtime-module/5-prs.html +++ b/docs/runtime-module/5-prs.html @@ -151,7 +151,7 @@ for the kinds we inherit from. return Rvalues::from_iname(name_array); } -inter_name *RTParsing::name_iname(void) { +inter_name *RTParsing::name_iname(void) { return RTProperties::iname(ParsingPlugin::name_property()); }
    @@ -166,7 +166,7 @@ for the kinds we inherit from. } cached_understanding; -void RTParsing::compile_understanding(inter_ti *val1, inter_ti *val2, wording W) { +void RTParsing::compile_understanding(inter_ti *val1, inter_ti *val2, wording W) { if (<subject-pronoun>(W)) { *val1 = LITERAL_IVAL; *val2 = 0; } else { cached_understanding *cu; @@ -176,7 +176,7 @@ for the kinds we inherit from. return; } command_grammar *cg = Understand::consultation(W); - inter_name *iname = UnderstandGeneralTokens::consult_iname(cg); + inter_name *iname = UnderstandGeneralTokens::consult_iname(cg); if (iname) { cu = CREATE(cached_understanding); cu->understanding_text = W; @@ -188,7 +188,7 @@ for the kinds we inherit from.
    • The structure cached_understanding is private to this section.
    diff --git a/docs/runtime-module/5-rgn.html b/docs/runtime-module/5-rgn.html index b19b45e7c..dbf6fb4fc 100644 --- a/docs/runtime-module/5-rgn.html +++ b/docs/runtime-module/5-rgn.html @@ -108,7 +108,7 @@ function togglePopup(material_id) { }
    diff --git a/docs/runtime-module/5-sc.html b/docs/runtime-module/5-sc.html index 7ac1c9569..4e336c10b 100644 --- a/docs/runtime-module/5-sc.html +++ b/docs/runtime-module/5-sc.html @@ -440,7 +440,7 @@ turn by turn.
    • This code is used in §4.2.
    diff --git a/docs/runtime-module/5-scn.html b/docs/runtime-module/5-scn.html index 5fbe2a4f8..c4f25ea57 100644 --- a/docs/runtime-module/5-scn.html +++ b/docs/runtime-module/5-scn.html @@ -782,7 +782,7 @@ actually running: }
    diff --git a/docs/runtime-module/5-se.html b/docs/runtime-module/5-se.html index f592d4ec8..d7648a762 100644 --- a/docs/runtime-module/5-se.html +++ b/docs/runtime-module/5-se.html @@ -77,7 +77,7 @@ }
    diff --git a/docs/runtime-module/5-spt.html b/docs/runtime-module/5-spt.html index ff12092dd..7f34edac4 100644 --- a/docs/runtime-module/5-spt.html +++ b/docs/runtime-module/5-spt.html @@ -142,7 +142,7 @@ be compiled, so this code is never used. }
    diff --git a/docs/runtime-module/5-tm.html b/docs/runtime-module/5-tm.html index 432933285..8a8d00779 100644 --- a/docs/runtime-module/5-tm.html +++ b/docs/runtime-module/5-tm.html @@ -341,7 +341,7 @@ identifier names for instance have not yet been settled. }
    diff --git a/docs/runtime-module/5-tp.html b/docs/runtime-module/5-tp.html index 6df8405eb..06c5da6b6 100644 --- a/docs/runtime-module/5-tp.html +++ b/docs/runtime-module/5-tp.html @@ -114,7 +114,7 @@ the function ChangePlayer}
    diff --git a/docs/runtime-module/5-ts.html b/docs/runtime-module/5-ts.html index 2a45def9d..ed7ee5f69 100644 --- a/docs/runtime-module/5-ts.html +++ b/docs/runtime-module/5-ts.html @@ -88,7 +88,7 @@ }
    diff --git a/docs/runtime-module/index.html b/docs/runtime-module/index.html index 41277e32e..df1c3bf53 100644 --- a/docs/runtime-module/index.html +++ b/docs/runtime-module/index.html @@ -404,6 +404,21 @@ Command Grammar Lines - Runtime support for CGLs.

    +
  • +

    + Noun Filter Tokens - + Filters are used to require nouns to have specific kinds or attributes, or to have specific scoping rules: they correspond to Inform 6's |noun=Routine| and |scope=Routine| tokens. Though these are quite different concepts in I6, their common handling seems natural in I7.

    +
  • +
  • +

    + Tokens Parsing Values - + In the argot of Inform 6, GPR stands for General Parsing Routine, and I7 makes heavy use of GPR tokens to achieve its ends. This section is where the necessary I6 routines are compiled.

    +
  • +
  • +

    + General Parsing Routines - + To compile I6 general parsing routines (GPRs) and/or |parse_name| properties as required by the I7 grammar.

    +
  • diff --git a/inform7/Figures/memory-diagnostics.txt b/inform7/Figures/memory-diagnostics.txt index cca834ec5..c91ae4a79 100644 --- a/inform7/Figures/memory-diagnostics.txt +++ b/inform7/Figures/memory-diagnostics.txt @@ -1,10 +1,10 @@ Total memory consumption was 259375K = 253 MB -62.6% was used for 1338636 objects, in 278659 frames in 203 x 800K = 162400K = 158 MB: +62.6% was used for 1338639 objects, in 278662 frames in 203 x 800K = 162400K = 158 MB: 9.7% inter_tree_node_array 36 x 8192 = 294912 objects, 25953408 bytes 5.5% text_stream_array 2595 x 100 = 259500 objects, 14615040 bytes - 3.8% parse_node 129403 objects, 10352240 bytes + 3.8% parse_node 129406 objects, 10352480 bytes 2.7% verb_conjugation 160 objects, 7425280 bytes 2.5% parse_node_annotation_array 429 x 500 = 214500 objects, 6877728 bytes 2.4% linked_list 11793 objects, 6604080 bytes @@ -64,12 +64,12 @@ Total memory consumption was 259375K = 253 MB ---- pcalc_func_array 1 x 1000 objects, 56032 bytes ---- ph_stack_frame_box 577 objects, 55392 bytes ---- kind_constructor 77 objects, 54824 bytes + ---- cg_token 603 objects, 53064 bytes ---- property_inference_data 1315 objects, 52600 bytes ---- ap_clause_array 2 x 400 = 800 objects, 51264 bytes ---- text_substitution 436 objects, 48832 bytes ---- cg_line 230 objects, 47840 bytes ---- table 7 objects, 45528 bytes - ---- cg_token 603 objects, 43416 bytes ---- inter_node_list 750 objects, 42000 bytes ---- activity_list_array 1 x 1000 objects, 40032 bytes ---- anl_clause_array 1 x 1000 objects, 40032 bytes @@ -232,7 +232,7 @@ Total memory consumption was 259375K = 253 MB 37.3% was used for memory not allocated for objects: - 15.9% text stream storage 42247756 bytes in 265816 claims + 15.9% text stream storage 42247456 bytes in 265816 claims 3.4% dictionary storage 9278976 bytes in 16372 claims ---- sorting 1056 bytes in 3 claims 2.7% source text 7200000 bytes in 3 claims @@ -248,5 +248,5 @@ Total memory consumption was 259375K = 253 MB ---- emitter array storage 12320 bytes in 8 claims ---- code generation workspace for objects 9200 bytes in 9 claims -20.3% was overhead - 53951768 bytes = 52687K = 51 MB +20.3% was overhead - 53941880 bytes = 52677K = 51 MB diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt index beb7d20f0..36f1f7987 100644 --- a/inform7/Figures/timings-diagnostics.txt +++ b/inform7/Figures/timings-diagnostics.txt @@ -1,36 +1,37 @@ 100.0% in inform7 run - 67.1% in compilation to Inter - 25.6% in //Phrases::Manager::compile_first_block// - 8.7% in //Phrases::Manager::compile_as_needed// + 66.7% in compilation to Inter + 25.8% in //Phrases::Manager::compile_first_block// + 8.4% in //Phrases::Manager::compile_as_needed// 6.8% in //Strings::compile_responses// - 6.3% in //InferenceSubjects::emit_all// - 4.2% in //MajorNodes::pre_pass// - 3.3% in //MajorNodes::pass_1// - 2.0% in //Phrases::Manager::RulePrintingRule_routine// - 1.8% in //Phrases::Manager::rulebooks_array// - 0.9% in //RTVerbs::ConjugateVerb// + 6.1% in //InferenceSubjects::emit_all// + 4.1% in //MajorNodes::pre_pass// + 3.2% in //MajorNodes::pass_1// + 1.9% in //Phrases::Manager::RulePrintingRule_routine// + 1.9% in //Phrases::Manager::rulebooks_array// + 1.0% in //RTVerbs::ConjugateVerb// 0.7% in //Phrases::Manager::traverse// + 0.5% in //Phrases::Manager::compile_rulebooks// 0.5% in //World::stage_V// 0.3% in //MajorNodes::pass_2// - 0.3% in //Phrases::Manager::compile_rulebooks// 0.3% in //Phrases::Manager::parse_rule_parameters// 0.3% in //RTRelations::compile_defined_relations// 0.1% in //RTCommandGrammars::compile_all// 0.1% in //RTKinds::compile_data_type_support_routines// 0.1% in //Task::make_built_in_kind_constructors// 0.1% in //World::stages_II_and_III// - 3.7% not specifically accounted for - 30.4% in running Inter pipeline - 10.0% in step preparation - 9.6% in inter step 2/12: link - 7.2% in inter step 12/12: generate inform6 -> auto.inf + 3.4% not specifically accounted for + 30.8% in running Inter pipeline + 10.1% in step preparation + 9.9% in inter step 2/12: link + 7.0% in inter step 12/12: generate inform6 -> auto.inf 0.3% in inter step 9/12: make-identifiers-unique 0.1% in inter step 10/12: reconcile-verbs 0.1% in inter step 11/12: eliminate-redundant-labels + 0.1% in inter step 4/12: parse-linked-matter 0.1% in inter step 5/12: resolve-conditional-compilation 0.1% in inter step 6/12: assimilate 0.1% in inter step 7/12: resolve-external-symbols 0.1% in inter step 8/12: inspect-plugs 2.1% not specifically accounted for - 2.0% in supervisor + 1.9% in supervisor 0.4% not specifically accounted for diff --git a/inform7/Tests/Groups/commands.testgroup b/inform7/Tests/Groups/commands.testgroup index e5f8b0307..5556d54f3 100644 --- a/inform7/Tests/Groups/commands.testgroup +++ b/inform7/Tests/Groups/commands.testgroup @@ -1,3 +1,4 @@ +AwkwardParseNames InstanceParsing SilentMistake SlashDashDash diff --git a/inform7/Tests/Test Problems/PM_GrammarObjectlessRelation.txt b/inform7/Tests/Test Problems/PM_GrammarObjectlessRelation.txt index 29fc9549e..e6f760a80 100644 --- a/inform7/Tests/Test Problems/PM_GrammarObjectlessRelation.txt +++ b/inform7/Tests/Test Problems/PM_GrammarObjectlessRelation.txt @@ -1,3 +1,3 @@ Xanadu is a room. -Understand "box of [something related by containment]" as 10. +Understand "box of [something related by containment]" as "[fish]". diff --git a/inform7/Tests/Test Problems/_Results_Ideal/PM_GrammarObjectlessRelation.txt b/inform7/Tests/Test Problems/_Results_Ideal/PM_GrammarObjectlessRelation.txt index bcc6d0cf5..26028ade2 100644 --- a/inform7/Tests/Test Problems/_Results_Ideal/PM_GrammarObjectlessRelation.txt +++ b/inform7/Tests/Test Problems/_Results_Ideal/PM_GrammarObjectlessRelation.txt @@ -1,10 +1,11 @@ -Inform 7.10.1 build 6N67 has started. +Inform 7 v10.1.0 has started. I've now read your source text, which is 13 words long. -I've also read Standard Rules by Graham Nelson, which is 43240 words long. +I've also read Basic Inform by Graham Nelson, which is 7687 words long. I've also read English Language by Graham Nelson, which is 2328 words long. +I've also read Standard Rules by Graham Nelson, which is 32067 words long. Problem__ PM_GrammarObjectlessRelation - >--> You wrote 'Understand "box of [something related by containment]" as 10' - (source text, line 3): but a grammar token in an 'Understand...' can only - be based on a relation if it is to understand the name of a room or thing, - since otherwise there is nothing for the relation to be with. -Inform 7 has finished: 146 centiseconds used. + >--> You wrote 'Understand "box of [something related by containment]" as + "[fish]"' (source text, line 3): but a grammar token in an 'Understand...' + can only be based on a relation if it is to understand the name of a room + or thing, since otherwise there is nothing for the relation to be with. +Inform 7 has finished. diff --git a/inform7/if-module/Chapter 5/Command Grammar Lines.w b/inform7/if-module/Chapter 5/Command Grammar Lines.w index 08465b4e9..923879982 100644 --- a/inform7/if-module/Chapter 5/Command Grammar Lines.w +++ b/inform7/if-module/Chapter 5/Command Grammar Lines.w @@ -312,7 +312,8 @@ definition no effect, and disappears without trace in this process. cg_token *class_start = NULL; LOOP_THROUGH_CG_TOKENS(cgt, cgl) { if ((cgt->next_token) && (Wordings::length(CGTokens::text(cgt->next_token)) == 1) && - (Lexer::word(Wordings::first_wn(CGTokens::text(cgt->next_token))) == FORWARDSLASH_V)) { + (Lexer::word(Wordings::first_wn(CGTokens::text(cgt->next_token))) == + FORWARDSLASH_V)) { if (cgt->slash_class == 0) { class_start = cgt; alternatives_group++; /* start new equiv class */ class_start->slash_dash_dash = FALSE; @@ -322,11 +323,12 @@ definition no effect, and disappears without trace in this process. cgt->next_token->next_token->slash_class = alternatives_group; if ((cgt->next_token->next_token) && (Wordings::length(CGTokens::text(cgt->next_token->next_token)) == 1) && - (Lexer::word(Wordings::first_wn(CGTokens::text(cgt->next_token->next_token))) == DOUBLEDASH_V)) { + (Lexer::word(Wordings::first_wn(CGTokens::text(cgt->next_token->next_token))) == + DOUBLEDASH_V)) { class_start->slash_dash_dash = TRUE; - cgt->next_token = cgt->next_token->next_token->next_token; /* excise slash and dash-dash */ + cgt->next_token = cgt->next_token->next_token->next_token; /* excise both */ } else { - cgt->next_token = cgt->next_token->next_token; /* excise the slash from the token list */ + cgt->next_token = cgt->next_token->next_token; /* excise slash */ } } } @@ -417,9 +419,9 @@ void CGLines::cgl_determine(cg_line *cgl, command_grammar *cg, int depth) { } @ The general sort bonus is $Rs_0 + s_1$, where $R$ is the |CGL_SCORE_TOKEN_RANGE| -and $s_0$, $s_1$ are the scores for the first and second tokens describing values; -or if none of the $n$ tokens describes a value, it is $R^2n$, which is guaranteed -to be larger. +and $s_0$, $s_1$ are the scores for the first and second tokens describing values, +which are such that $0\leq s_i = int nulls_count = 0, pos = 0; - for (cg_token *cgtt = first; cgtt; cgtt = cgtt->next_token) { - int score = 0; - parse_node *spec = CGTokens::determine(cgtt, depth, &score); + for (cg_token *cgt = first; cgt; cgt = cgt->next_token) { + parse_node *spec = CGTokens::determine(cgt, depth); + int score = CGTokens::score_bonus(cgt); + if ((score < 0) || (score >= CGL_SCORE_TOKEN_RANGE)) + internal_error("token score out of range"); LOGIF(GRAMMAR_CONSTRUCTION, "token %d/%d: <%W> --> $P (score %d)\n", - pos+1, line_length, CGTokens::text(cgtt), spec, score); + pos+1, line_length, CGTokens::text(cgt), spec, score); if (spec) { @; int score_multiplier = 1; if (DeterminationTypes::get_no_values_described(&(cgl->cgl_type)) == 0) score_multiplier = CGL_SCORE_TOKEN_RANGE; DeterminationTypes::add_term(&(cgl->cgl_type), spec, - CGTokens::is_multiple(cgtt)); + CGTokens::is_multiple(cgt)); cgl->general_sort_bonus += score*score_multiplier; } else nulls_count++; - if (CGTokens::is_multiple(cgtt)) multiples++; + if (CGTokens::is_multiple(cgt)) multiples++; pos++; } if (nulls_count == line_length) @@ -479,7 +484,6 @@ which parses to a |K_understanding| match. cgl->understanding_sort_bonus += usb_contribution; } - @h Sorting the lines in a grammar. The CGLs in a grammar are insertion sorted into a sorted version. This is not the controversial part: //CGLines::cg_line_must_precede// is the part diff --git a/inform7/if-module/Chapter 5/Command Grammar Tokens.w b/inform7/if-module/Chapter 5/Command Grammar Tokens.w index c68cb7323..0ad713f33 100644 --- a/inform7/if-module/Chapter 5/Command Grammar Tokens.w +++ b/inform7/if-module/Chapter 5/Command Grammar Tokens.w @@ -2,41 +2,246 @@ CGs are list of CG lines, which are lists of CG tokens. -@ +@h Introduction. +Until 2021, CG tokens were held as parse nodes in the syntax tree, with a +special type |TOKEN_NT| and a set of annotations, but as cute as that was +it was also obfuscatory, and now each CG token corresponds to a //cg_token// +object as follows: = typedef struct cg_token { struct wording text_of_token; - int is_literal; - int slash_class; - int slash_dash_dash; int grammar_token_code; - struct parse_node *grammar_value; /* 0 or else one of the |*_GTC| values */ + struct parse_node *what_token_describes; /* 0 or else one of the |*_GTC| values */ struct binary_predicate *token_relation; - struct cg_token *next_token; + struct noun_filter_token *noun_filter; + struct command_grammar *defined_by; + int slash_class; /* used in slashing: see //CGLines::slash// */ + int slash_dash_dash; /* ditto */ + struct cg_token *next_token; /* in the list for a CG line */ CLASS_DEFINITION } cg_token; +cg_token *CGTokens::cgt_of(wording W, int lit) { + cg_token *cgt = CREATE(cg_token); + cgt->text_of_token = W; + cgt->slash_dash_dash = FALSE; + cgt->slash_class = 0; + cgt->what_token_describes = NULL; + cgt->grammar_token_code = lit?LITERAL_GTC:0; + cgt->token_relation = NULL; + cgt->noun_filter = NULL; + cgt->defined_by = NULL; + cgt->next_token = NULL; + return cgt; +} + +@h Text to a CG token list. +Tokens are created when text such as "drill [something] with [something]" +is parsed, from an Understand sentence or elsewhere. What happens is much +the same as when text with substitutions is read: the text is retokenised +by the lexer to produce the following, in which the square brackets have +become commas: += (text) +"drill" , something , "with" , something += +In fact we use a different punctuation set from the lexer's default, because +we want forward slashes to break words, so that we need |/| to be a punctuation +mark: thus "get away/off/out" becomes += (text) +"get" "away" / "off" / "out" += + +@d GRAMMAR_PUNCTUATION_MARKS L".,:;?!(){}[]/" /* note the slash */ + += +cg_token *CGTokens::tokenise(wording W) { + wchar_t *as_wide_string = Lexer::word_text(Wordings::first_wn(W)); + @; + wording TW = Feeds::feed_C_string_full(as_wide_string, TRUE, + GRAMMAR_PUNCTUATION_MARKS); + @; + + cg_token *tokens = CGTokens::break_into_tokens(TW); + if (tokens == NULL) { + StandardProblems::sentence_problem(Task::syntax_tree(), + _p_(PM_UnderstandEmptyText), + "'understand' should be followed by text which contains at least " + "one word or square-bracketed token", + "so for instance 'understand \"take [something]\" as taking' is fine, " + "but 'understand \"\" as the fog' is not. The same applies to the contents " + "of 'topic' columns in tables, since those are also instructions for " + "understanding."); + } + return tokens; +} + +@ = + int skip = FALSE, literal_punct = FALSE; + for (int i=0; as_wide_string[i]; i++) { + if (as_wide_string[i] == '[') skip = TRUE; + if (as_wide_string[i] == ']') skip = FALSE; + if (skip) continue; + if ((as_wide_string[i] == '.') || (as_wide_string[i] == ',') || + (as_wide_string[i] == '!') || (as_wide_string[i] == '?') || + (as_wide_string[i] == ':') || (as_wide_string[i] == ';')) + literal_punct = TRUE; + } + if (literal_punct) { + StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_LiteralPunctuation), + "'understand' text cannot contain literal punctuation", + "or more specifically cannot contain any of these: . , ! ? : ; since they " + "are already used in various ways by the parser, and would not correctly " + "match here."); + return NULL; + } + +@ = + LOOP_THROUGH_WORDING(i, TW) + if (i < Wordings::last_wn(TW)) + if ((compare_word(i, COMMA_V)) && (compare_word(i+1, COMMA_V))) { + StandardProblems::sentence_problem(Task::syntax_tree(), + _p_(PM_UnderstandCommaCommand), + "'understand' as an action cannot involve a comma", + "since a command leading to an action never does. " + "(Although Inform understands commands like 'PETE, LOOK' " + "only the part after the comma is read as an action command: " + "the part before the comma is read as the name of someone, " + "according to the usual rules for parsing a name.) " + "Because of the way Inform processes text with square " + "brackets, this problem message is also sometimes seen " + "if empty square brackets are used, as in 'Understand " + "\"bless []\" as blessing.'"); + return NULL; + } + +@ The following tiny Preform grammar is then used to break up the resulting +text at commas: += + ::= + ... , ... | ==> { NOT_APPLICABLE, - } + | ==> { TRUE, - } + ... ==> { FALSE, - } + +@ The following function takes a wording and turns it into a linked list of +CG tokens, divided by commas: + += +cg_token *CGTokens::break_into_tokens(wording W) { + return CGTokens::break_into_tokens_r(NULL, W); +} +cg_token *CGTokens::break_into_tokens_r(cg_token *list, wording W) { + (W); + switch (<>) { + case NOT_APPLICABLE: { + wording LW = GET_RW(, 1); + wording RW = GET_RW(, 2); + list = CGTokens::break_into_tokens_r(list, LW); + list = CGTokens::break_into_tokens_r(list, RW); + break; + } + case TRUE: + Word::dequote(Wordings::first_wn(W)); + if (*(Lexer::word_text(Wordings::first_wn(W))) == 0) return list; + W = Feeds::feed_C_string_full(Lexer::word_text(Wordings::first_wn(W)), + FALSE, GRAMMAR_PUNCTUATION_MARKS); + LOOP_THROUGH_WORDING(i, W) { + cg_token *cgt = CGTokens::cgt_of(Wordings::one_word(i), TRUE); + list = CGTokens::add_to_list(cgt, list); + } + break; + case FALSE: { + cg_token *cgt = CGTokens::cgt_of(W, FALSE); + list = CGTokens::add_to_list(cgt, list); + break; + } + } + return list; +} + +@ If |list| represents the head of the list (and is |NULL| for an empty list), +this adds |cgt| at the end and returns the new head. + += +cg_token *CGTokens::add_to_list(cg_token *cgt, cg_token *list) { + if (list == NULL) return cgt; + if (cgt == NULL) return list; + cg_token *x = list; + while (x->next_token) x = x->next_token; + x->next_token = cgt; + return list; +} + +@ As the above shows, the text of a token is not necessarily a single word, +unless it's a literal. + += wording CGTokens::text(cg_token *cgt) { return cgt?(cgt->text_of_token):(EMPTY_WORDING); } -@ Tokens with a nonzero |grammar_token_code| correspond closely to what are -also called "tokens" in the runtime command parser. +@h The GTC. +The GTC, or grammar token code, is a sort of type indicator for tokens. As +produced by the tokeniser above, tokens initially have GTC either |UNDETERMINED_GTC| +or |LITERAL_GTC|. Differentiation of non-literal tokens into other types happens +in //CGTokens::determine//. -@d NAMED_TOKEN_GTC 1 /* these positive values are used only in parsing */ +Note that there are two sets of GTC values, one set positive, one negative. The +negative ones correspond closely to command-parser grammar reserved tokens in +the old I6 compiler, and this is indeed what they compile to if we are +generating I6 code. + +@d NAMED_TOKEN_GTC 1 @d RELATED_GTC 2 @d STUFF_GTC 3 @d ANY_STUFF_GTC 4 @d ANY_THINGS_GTC 5 -@d NOUN_TOKEN_GTC -1 /* I6 |noun| */ -@d MULTI_TOKEN_GTC -2 /* I6 |multi| */ -@d MULTIINSIDE_TOKEN_GTC -3 /* I6 |multiinside| */ -@d MULTIHELD_TOKEN_GTC -4 /* I6 |multiheld| */ -@d HELD_TOKEN_GTC -5 /* I6 |held| */ -@d CREATURE_TOKEN_GTC -6 /* I6 |creature| */ -@d TOPIC_TOKEN_GTC -7 /* I6 |topic| */ -@d MULTIEXCEPT_TOKEN_GTC -8 /* I6 |multiexcept| */ +@d LITERAL_GTC 6 + +@d UNDETERMINED_GTC 0 + +@d NOUN_TOKEN_GTC -1 /* like I6 |noun| */ +@d MULTI_TOKEN_GTC -2 /* like I6 |multi| */ +@d MULTIINSIDE_TOKEN_GTC -3 /* like I6 |multiinside| */ +@d MULTIHELD_TOKEN_GTC -4 /* like I6 |multiheld| */ +@d HELD_TOKEN_GTC -5 /* like I6 |held| */ +@d CREATURE_TOKEN_GTC -6 /* like I6 |creature| */ +@d TOPIC_TOKEN_GTC -7 /* like I6 |topic| */ +@d MULTIEXCEPT_TOKEN_GTC -8 /* like I6 |multiexcept| */ + += +int CGTokens::is_literal(cg_token *cgt) { + if ((cgt) && (cgt->grammar_token_code == LITERAL_GTC)) return TRUE; + return FALSE; +} + +int CGTokens::is_I6_parser_token(cg_token *cgt) { + if ((cgt) && (cgt->grammar_token_code < 0)) return TRUE; + return FALSE; +} + +int CGTokens::is_topic(cg_token *cgt) { + if ((cgt) && (cgt->grammar_token_code == TOPIC_TOKEN_GTC)) return TRUE; + return FALSE; +} + +@ A multiple token is one which permits multiple matches in the run-time command +parser: for instance, the player can type ALL where a |MULTI_TOKEN_GTC| is +expected. + += +int CGTokens::is_multiple(cg_token *cgt) { + switch (cgt->grammar_token_code) { + case MULTI_TOKEN_GTC: + case MULTIINSIDE_TOKEN_GTC: + case MULTIHELD_TOKEN_GTC: + case MULTIEXCEPT_TOKEN_GTC: + return TRUE; + } + return FALSE; +} + +@h Logging. = void CGTokens::log(cg_token *cgt) { @@ -64,237 +269,49 @@ void CGTokens::log(cg_token *cgt) { } } -@ +@h Parsing nonliteral tokens. +Unless a token is literal and in double-quotes, it will start out as having +|UNDETERMINED_GTC| until we investigate what the words in it mean, which we +will do with the following Preform grammar. -|is_literal| is set for literal words such as |"into"| -and clear for square-bracketed tokens such as |"[something]"|. - -The |grammar_token_code| annotation is meaningful only for parse nodes -with an evaluation of type |DESCRIPTION|. These are tokens which describe a -range of objects. Examples include "[open container]", which compiles to an -I6 noun filter, "[any container]", which compiles to an I6 scope filter, or -"[things]", one of a small number of special cases compiling to primitive I6 -parser tokens. The annotation holds the allocation ID for the noun/scope -filter structure built for the occasion in the former cases, and one of the -following constants in the latter case. (These must all have negative values -in order not to clash with allocation IDs 0, 1, 2, ..., and clearly must all -be different, but otherwise the values are not significant and there is no -preferred order.) - -For tokens with any other evaluation, |general_purpose| is always 0, so -that the special values below cannot arise. - -@ Tokens are created when text such as "drill [something] with [something]" -is parsed, from an Understand sentence or elsewhere. What happens is much -the same as when text with substitutions is read: that produces - ->> "drill", something, "with", something - -and the following little grammar is used to divide this text up into its -four constituent tokens. - -= - ::= - ... , ... | ==> { NOT_APPLICABLE, - } - | ==> { TRUE, - } - ... ==> { FALSE, - } - -@ We use a different punctuation set, in which forward slashes break words, -to handle such as: - ->> Understand "get away/off/out" as exiting. - -Inform would ordinarily lex the text away/off/out as one single word -- so that -something like "on/off switch" would be regarded as two words not four -- -but with slash treated as a punctuation mark, we instead read "away / off / -out", a sequence of five lexical words. - -@d GRAMMAR_PUNCTUATION_MARKS L".,:;?!(){}[]/" /* note the slash... */ - -= -cg_token *CGTokens::break_into_tokens(cg_token *from, wording W) { - (W); - switch (<>) { - case NOT_APPLICABLE: { - wording LW = GET_RW(, 1); - wording RW = GET_RW(, 2); - from = CGTokens::break_into_tokens(from, LW); - from = CGTokens::break_into_tokens(from, RW); - break; - } - case TRUE: - Word::dequote(Wordings::first_wn(W)); - if (*(Lexer::word_text(Wordings::first_wn(W))) == 0) return from; - W = Feeds::feed_C_string_full(Lexer::word_text(Wordings::first_wn(W)), FALSE, GRAMMAR_PUNCTUATION_MARKS); - LOOP_THROUGH_WORDING(i, W) { - cg_token *cgt = CGTokens::cgt_of(Wordings::one_word(i), TRUE); - from = CGTokens::graft(cgt, from); - } - break; - case FALSE: { - cg_token *cgt = CGTokens::cgt_of(W, FALSE); - from = CGTokens::graft(cgt, from); - break; - } - } - return from; -} - -cg_token *CGTokens::cgt_of(wording W, int lit) { - cg_token *cgt = CREATE(cg_token); - cgt->text_of_token = W; - cgt->is_literal = lit; - cgt->slash_dash_dash = FALSE; - cgt->slash_class = 0; - cgt->grammar_value = NULL; - cgt->grammar_token_code = 0; - cgt->token_relation = NULL; - cgt->next_token = NULL; - return cgt; -} - -cg_token *CGTokens::graft(cg_token *cgt, cg_token *list) { - if (list == NULL) return cgt; - if (cgt == NULL) return list; - cg_token *x = list; - while (x->next_token) x = x->next_token; - x->next_token = cgt; - return list; -} - -int CGTokens::is_literal(cg_token *cgt) { - return (cgt)?(cgt->is_literal):FALSE; -} - -@h Multiple tokens. -A multiple token is one which permits multiple matches in the I6 parser: for -instance, permits the use of "all". - -= -int CGTokens::is_multiple(cg_token *cgt) { - switch (cgt->grammar_token_code) { - case MULTI_TOKEN_GTC: - case MULTIINSIDE_TOKEN_GTC: - case MULTIHELD_TOKEN_GTC: - case MULTIEXCEPT_TOKEN_GTC: - return TRUE; - } - return FALSE; -} - -@h The special tokens. -Do not change any of these GTC numbers without first checking and updating -the discussion of CGL sorting in //Command Grammar Lines//: - -= -int CGTokens::gsb_for_special_token(int gtc) { - switch(gtc) { - case NOUN_TOKEN_GTC: return 0; - case MULTI_TOKEN_GTC: return 0; - case MULTIINSIDE_TOKEN_GTC: return 1; - case MULTIHELD_TOKEN_GTC: return 2; - case HELD_TOKEN_GTC: return 3; - case CREATURE_TOKEN_GTC: return 0; - case TOPIC_TOKEN_GTC: return -1; - case MULTIEXCEPT_TOKEN_GTC: return 2; - default: internal_error("tried to find GSB for invalid GTC"); - } - return 0; /* to prevent a gcc error: never reached */ -} - -@ These translate into I6 as follows: - -= -char *CGTokens::i6_token_for_special_token(int gtc) { - switch(gtc) { - case NOUN_TOKEN_GTC: return "noun"; - case MULTI_TOKEN_GTC: return "multi"; - case MULTIINSIDE_TOKEN_GTC: return "multiinside"; - case MULTIHELD_TOKEN_GTC: return "multiheld"; - case HELD_TOKEN_GTC: return "held"; - case CREATURE_TOKEN_GTC: return "creature"; - case TOPIC_TOKEN_GTC: return "topic"; - case MULTIEXCEPT_TOKEN_GTC: return "multiexcept"; - default: internal_error("tried to find I6 token for invalid GTC"); - } - return ""; /* to prevent a gcc error: never reached */ -} - -inter_name *CGTokens::iname_for_special_token(int gtc) { - switch(gtc) { - case NOUN_TOKEN_GTC: return VERB_DIRECTIVE_NOUN_iname; - case MULTI_TOKEN_GTC: return VERB_DIRECTIVE_MULTI_iname; - case MULTIINSIDE_TOKEN_GTC: return VERB_DIRECTIVE_MULTIINSIDE_iname; - case MULTIHELD_TOKEN_GTC: return VERB_DIRECTIVE_MULTIHELD_iname; - case HELD_TOKEN_GTC: return VERB_DIRECTIVE_HELD_iname; - case CREATURE_TOKEN_GTC: return VERB_DIRECTIVE_CREATURE_iname; - case TOPIC_TOKEN_GTC: return VERB_DIRECTIVE_TOPIC_iname; - case MULTIEXCEPT_TOKEN_GTC: return VERB_DIRECTIVE_MULTIEXCEPT_iname; - default: internal_error("tried to find inter name for invalid GTC"); - } - return NULL; /* to prevent a gcc error: never reached */ -} - -char *CGTokens::i6_constant_for_special_token(int gtc) { - switch(gtc) { - case NOUN_TOKEN_GTC: return "NOUN_TOKEN"; - case MULTI_TOKEN_GTC: return "MULTI_TOKEN"; - case MULTIINSIDE_TOKEN_GTC: return "MULTIINSIDE_TOKEN"; - case MULTIHELD_TOKEN_GTC: return "MULTIHELD_TOKEN"; - case HELD_TOKEN_GTC: return "HELD_TOKEN"; - case CREATURE_TOKEN_GTC: return "CREATURE_TOKEN"; - case TOPIC_TOKEN_GTC: return "TOPIC_TOKEN"; - case MULTIEXCEPT_TOKEN_GTC: return "MULTIEXCEPT_TOKEN"; - default: internal_error("tried to find I6 constant for invalid GTC"); - } - return ""; /* to prevent a gcc error: never reached */ -} - -@ The special tokens all return a value in I6 which needs a kind -to be used in I7: these are defined by the following routine. - -= -kind *CGTokens::kind_for_special_token(int gtc) { - if ((K_understanding) && (gtc == TOPIC_TOKEN_GTC)) return K_understanding; - return K_object; -} - -@ The tokens which aren't literal words in double-quotes are parsed as follows: +Note that always matches any text, even if it sometimes throws +a problem message on the way. Its return integer is a valid GTC, and its +return pointer is a (non-null) description of what the token matches. = ::= - | ==> { NAMED_TOKEN_GTC, -, <> = RP[1] } - any things | ==> { ANY_THINGS_GTC, -, <> = Specifications::from_kind(K_thing) } - any | ==> { ANY_STUFF_GTC, -, <> = RP[1] } - anything | ==> { ANY_STUFF_GTC, -, <> = Specifications::from_kind(K_thing) } - anybody | ==> { ANY_STUFF_GTC, -, <> = Specifications::from_kind(K_person) } - anyone | ==> { ANY_STUFF_GTC, -, <> = Specifications::from_kind(K_person) } - anywhere | ==> { ANY_STUFF_GTC, -, <> = Specifications::from_kind(K_room) } - something related by reversed | ==> { RELATED_GTC, BinaryPredicates::get_reversal(RP[1]) } - something related by | ==> { RELATED_GTC, RP[1] } - something related by ... | ==> @ - | ==> { R[1], NULL } - | ==> { STUFF_GTC, -, <> = Specifications::from_kind(RP[2]) } - | ==> { STUFF_GTC, -, <> = RP[1] } - | ==> @ - ... ==> @ + | ==> @ + any things | ==> { ANY_THINGS_GTC, Specifications::from_kind(K_thing) } + any | ==> { ANY_STUFF_GTC, RP[1] } + anything | ==> { ANY_STUFF_GTC, Specifications::from_kind(K_thing) } + anybody | ==> { ANY_STUFF_GTC, Specifications::from_kind(K_person) } + anyone | ==> { ANY_STUFF_GTC, Specifications::from_kind(K_person) } + anywhere | ==> { ANY_STUFF_GTC, Specifications::from_kind(K_room) } + something related by reversed | ==> @ + something related by | ==> @ + something related by ... | ==> @ + | ==> { pass 1 } + | ==> { STUFF_GTC, Specifications::from_kind(RP[2]) } + | ==> { STUFF_GTC, RP[1] } + | ==> @ + ... ==> @ ::= - something | ==> { NOUN_TOKEN_GTC, - } - things | ==> { MULTI_TOKEN_GTC, - } - things inside | ==> { MULTIINSIDE_TOKEN_GTC, - } - things preferably held | ==> { MULTIHELD_TOKEN_GTC, - } - something preferably held | ==> { HELD_TOKEN_GTC, - } - other things | ==> { MULTIEXCEPT_TOKEN_GTC, - } - someone | ==> { CREATURE_TOKEN_GTC, - } - somebody | ==> { CREATURE_TOKEN_GTC, - } - text | ==> { TOPIC_TOKEN_GTC, - } - topic | ==> @ - a topic | ==> @ - object | ==> @ - an object | ==> @ - something held | ==> @ - things held ==> @ + something | ==> { NOUN_TOKEN_GTC, Specifications::from_kind(K_object) } + things | ==> { MULTI_TOKEN_GTC, Specifications::from_kind(K_object) } + things inside | ==> { MULTIINSIDE_TOKEN_GTC, Specifications::from_kind(K_object) } + things preferably held | ==> { MULTIHELD_TOKEN_GTC, Specifications::from_kind(K_object) } + something preferably held | ==> { HELD_TOKEN_GTC, Specifications::from_kind(K_object) } + other things | ==> { MULTIEXCEPT_TOKEN_GTC, Specifications::from_kind(K_object) } + someone | ==> { CREATURE_TOKEN_GTC, Specifications::from_kind(K_object) } + somebody | ==> { CREATURE_TOKEN_GTC, Specifications::from_kind(K_object) } + text | ==> { TOPIC_TOKEN_GTC, Specifications::from_kind(K_understanding) } + topic | ==> @ + a topic | ==> @ + object | ==> @ + an object | ==> @ + something held | ==> @ + things held ==> @ internal { command_grammar *cg = CommandGrammars::named_token_by_name(W); @@ -305,6 +322,15 @@ kind *CGTokens::kind_for_special_token(int gtc) { ==> { fail nonterminal }; } +@ = + ==> { NAMED_TOKEN_GTC, ParsingPlugin::rvalue_from_command_grammar(RP[1]) } + +@ = + ==> { RELATED_GTC, Rvalues::from_binary_predicate(BinaryPredicates::get_reversal(RP[1])) } + +@ = + ==> { RELATED_GTC, Rvalues::from_binary_predicate(RP[1]) } + @ = Problems::quote_source(1, current_sentence); Problems::quote_wording(2, W); @@ -314,7 +340,7 @@ kind *CGTokens::kind_for_special_token(int gtc) { "invites me to understand names of related things, " "but the relation is not one that I know."); Problems::issue_problem_end(); - ==> { RELATED_GTC, NULL }; + ==> { RELATED_GTC, Rvalues::from_binary_predicate(R_equality) } @ = Problems::quote_source(1, current_sentence); @@ -331,7 +357,7 @@ kind *CGTokens::kind_for_special_token(int gtc) { "or in descriptions of actions or in table columns; it's really " "intended only for defining new commands."); Problems::issue_problem_end(); - ==> { TOPIC_TOKEN_GTC, NULL }; + ==> { TOPIC_TOKEN_GTC, Specifications::from_kind(K_understanding) }; @ = Problems::quote_source(1, current_sentence); @@ -343,17 +369,41 @@ kind *CGTokens::kind_for_special_token(int gtc) { "all here', but Inform uses the special syntax '[thing]' " "for that. (Or '[things]' if multiple objects are allowed.)"); Problems::issue_problem_end(); - ==> { MULTI_TOKEN_GTC, NULL }; + ==> { MULTI_TOKEN_GTC, Specifications::from_kind(K_object) } @ = CGTokens::incompatible_change_problem( "something held", "something", "something preferably held"); - ==> { HELD_TOKEN_GTC, NULL }; + ==> { HELD_TOKEN_GTC, Specifications::from_kind(K_object) } @ = CGTokens::incompatible_change_problem( "things held", "things", "things preferably held"); - ==> { MULTIHELD_TOKEN_GTC, NULL }; + ==> { MULTIHELD_TOKEN_GTC, Specifications::from_kind(K_object) } + +@ = + LOG("$T", current_sentence); + Problems::quote_source(1, current_sentence); + Problems::quote_wording(2, W); + Problems::quote_kind_of(3, RP[1]); + StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_BizarreToken)); + Problems::issue_problem_segment( + "The grammar token '%2' in the sentence %1 looked to me as " + "if it might be %3, but this isn't something allowed in " + "parsing grammar."); + Problems::issue_problem_end(); + ==> { STUFF_GTC, Specifications::from_kind(K_thing) } + +@ = + LOG("$T", current_sentence); + Problems::quote_source(1, current_sentence); + Problems::quote_wording(2, W); + StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_UnknownToken)); + Problems::issue_problem_segment( + "I was unable to understand what you meant by the grammar token '%2' " + "in the sentence %1."); + Problems::issue_problem_end(); + ==> { STUFF_GTC, Specifications::from_kind(K_thing) } @ Something of an extended mea culpa: but it had the desired effect, in that nobody complained about what might have been a controversial change. @@ -385,106 +435,114 @@ void CGTokens::incompatible_change_problem(char *token_tried, char *token_instea Problems::issue_problem_end(); } -@ = - LOG("$T", current_sentence); - Problems::quote_source(1, current_sentence); - Problems::quote_wording(2, W); - Problems::quote_kind_of(3, RP[1]); - StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_BizarreToken)); - Problems::issue_problem_segment( - "The grammar token '%2' in the sentence %1 looked to me as " - "if it might be %3, but this isn't something allowed in " - "parsing grammar."); - Problems::issue_problem_end(); - ==> { STUFF_GTC, - }; - -@ = - LOG("$T", current_sentence); - Problems::quote_source(1, current_sentence); - Problems::quote_wording(2, W); - StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_UnknownToken)); - Problems::issue_problem_segment( - "I was unable to understand what you meant by the grammar token '%2' " - "in the sentence %1."); - Problems::issue_problem_end(); - ==> { STUFF_GTC, - }; - @h Determining. +To calculate a description of what is being described by a token, then, we +call the following function, which delegates to above. +In the two cases |NAMED_TOKEN_GTC| and |RELATED_GTC| the pointer result is +a temporary one telling us which named token, and which relation, respectively: +we then convert those into the result. In all other cases, the |parse_node| +pointer returned by is the result. = -parse_node *CGTokens::determine(cg_token *cgt, int depth, int *score) { +parse_node *CGTokens::determine(cg_token *cgt, int depth) { if (CGTokens::is_literal(cgt)) return NULL; - <> = NULL; - parse_node *spec = NULL; (CGTokens::text(cgt)); - switch (<>) { - case NAMED_TOKEN_GTC: @; break; - case ANY_STUFF_GTC: @; break; - case ANY_THINGS_GTC: @; break; - case RELATED_GTC: @; break; - case STUFF_GTC: @; break; - default: @; break; + cgt->grammar_token_code = <>; + parse_node *result = <>; + + switch (cgt->grammar_token_code) { + case NAMED_TOKEN_GTC: + cgt->defined_by = ParsingPlugin::rvalue_to_command_grammar(result); + result = CommandGrammars::determine(cgt->defined_by, depth+1); + break; + case ANY_STUFF_GTC: + @; + cgt->noun_filter = UnderstandFilterTokens::nft_new(result, TRUE, FALSE); + break; + case ANY_THINGS_GTC: + @; + cgt->noun_filter = UnderstandFilterTokens::nft_new(result, TRUE, TRUE); + break; + case RELATED_GTC: + cgt->token_relation = Rvalues::to_binary_predicate(result); + kind *K = BinaryPredicates::term_kind(cgt->token_relation, 0); + if (K == NULL) K = K_object; + result = Specifications::from_kind(K); + break; + case STUFF_GTC: + @; + cgt->noun_filter = UnderstandFilterTokens::nft_new(result, FALSE, FALSE); + break; + default: + Node::set_text(result, CGTokens::text(cgt)); + break; } - if (spec) @; - return spec; + + if (result) @; + cgt->what_token_describes = result; + return cgt->what_token_describes; } -@ = - parse_node *val = ParsingPlugin::rvalue_from_command_grammar(<>); - spec = CommandGrammars::determine(<>, depth+1); - cgt->grammar_value = val; +@ If the token determines an actual constant value -- as it can when it is a +named token which always refers to a specific thing, for example -- it is +possible for |result| not to be a description. Otherwise, though, it has to +be a description which is true or false for any given value, so: -@ = - spec = <>; - if (Specifications::is_description(spec)) { - int any_things = FALSE; - if (<> == ANY_THINGS_GTC) any_things = TRUE; - cgt->grammar_token_code = UnderstandFilterTokens::new_id(spec, TRUE, any_things); - cgt->grammar_value = spec; +@ = + pcalc_prop *prop = Specifications::to_proposition(result); + if ((prop) && (Binding::number_free(prop) != 1)) { + LOG("So $P and $D\n", result, prop); + StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_FilterQuantified), + "the [any ...] doesn't clearly give a description in the '...' part", + "where I was expecting something like '[any vehicle]'."); + result = Specifications::from_kind(K_object); } -@ = - binary_predicate *bp = <>; - if (bp) cgt->token_relation = bp; - -@ = - spec = <>; - cgt->grammar_value = spec; - if (Specifications::is_description_like(spec)) { - *score = 5; - cgt->grammar_token_code = UnderstandFilterTokens::new_id(spec, FALSE, FALSE); - } - -@ = - int p = <>; - kind *K = CGTokens::kind_for_special_token(p); - spec = Specifications::from_kind(K); - Node::set_text(spec, CGTokens::text(cgt)); - *score = CGTokens::gsb_for_special_token(p); - cgt->grammar_value = spec; - cgt->grammar_token_code = p; - -@ = - if (Specifications::is_description(spec)) { - kind *K = Specifications::to_kind(spec); +@ = + if (Specifications::is_description(result)) { + kind *K = Specifications::to_kind(result); if ((K_understanding) && (Kinds::Behaviour::is_object(K) == FALSE) && (Kinds::eq(K, K_understanding) == FALSE) && (Kinds::Behaviour::request_I6_GPR(K) == FALSE)) { Problems::quote_source(1, current_sentence); Problems::quote_wording(2, CGTokens::text(cgt)); - StandardProblems::handmade_problem(Task::syntax_tree(), - _p_(PM_UnparsableKind)); + StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_UnparsableKind)); Problems::issue_problem_segment( - "The grammar token '%2' in the sentence %1 " - "invites me to understand values typed by the player during " - "play but for a kind of value which is beyond my ability. " - "Generally speaking, the allowable kinds of value are " - "number, time, text and any new kind of value you may " - "have created - but not, for instance, scene or rule."); + "The grammar token '%2' in the sentence %1 invites me to understand " + "values typed by the player during play but for a kind of value which " + "is beyond my ability. Generally speaking, the allowable kinds of value " + "are number, time, text and any new kind of value you may have created - " + "but not, for instance, scene or rule."); Problems::issue_problem_end(); - spec = NULL; + result = Specifications::from_kind(K_object); } } + +@h Scoring. +This score is needed when sorting CG lines in order of applicability: see the +discussion at //CGLines::cgl_determine//. The function must return a value +which is at least 0 but strictly less than |CGL_SCORE_TOKEN_RANGE|. The +general idea is that higher scores cause tokens to take precedence over lower +ones. + += +int CGTokens::score_bonus(cg_token *cgt) { + if (cgt == NULL) internal_error("no cgt"); + if (cgt->grammar_token_code == UNDETERMINED_GTC) internal_error("undetermined"); + int gtc = cgt->grammar_token_code; + switch(gtc) { + case STUFF_GTC: return 5; + case NOUN_TOKEN_GTC: return 1; + case MULTI_TOKEN_GTC: return 1; + case MULTIINSIDE_TOKEN_GTC: return 2; + case MULTIHELD_TOKEN_GTC: return 3; + case HELD_TOKEN_GTC: return 4; + case CREATURE_TOKEN_GTC: return 1; + case TOPIC_TOKEN_GTC: return 0; + case MULTIEXCEPT_TOKEN_GTC: return 3; + } + return 1; +} diff --git a/inform7/if-module/Chapter 5/Grammar Properties.w b/inform7/if-module/Chapter 5/Grammar Properties.w deleted file mode 100644 index ec03c4227..000000000 --- a/inform7/if-module/Chapter 5/Grammar Properties.w +++ /dev/null @@ -1,118 +0,0 @@ -[Visibility::] Grammar Properties. - -A plugin for the I6 run-time properties needed to support parsing. - -@h Definitions. - -@ - -= (early code) -property *P_parse_name = NULL; - - -@ And every property permission likewise: - -= -typedef struct parsing_pp_data { - int visibility_level_in_parser; /* if so, does the run-time I6 parser recognise it? */ - struct wording visibility_condition; /* (at least if...?) */ - struct parse_node *visibility_sentence; /* where this is specified */ - CLASS_DEFINITION -} parsing_pp_data; - -@h Initialising. - -= -parsing_data *Visibility::new_data(inference_subject *subj) { - parsing_data *pd = CREATE(parsing_data); - pd->understand_as_this_object = NULL; - return pd; -} - -parsing_pp_data *Visibility::new_pp_data(property_permission *pp) { - parsing_pp_data *pd = CREATE(parsing_pp_data); - pd->visibility_level_in_parser = 0; - pd->visibility_condition = EMPTY_WORDING; - pd->visibility_sentence = NULL; - return pd; -} - -int Visibility::new_permission_notify(property_permission *new_pp) { - CREATE_PLUGIN_PP_DATA(parsing, new_pp, Visibility::new_pp_data); - return FALSE; -} - -@h Visible properties. -A visible property is one which can be used to describe an object: for -instance, if colour is a visible property of a car, then it can be called -"green car" if and only if the current value of the colour of the car is -"green". - -Properly speaking it is not the property which is visible, but the -combination of property and object (or kind): thus the following test -depends on a property permission and not a mere property. - -= -int Visibility::seek(property *pr, inference_subject *subj, - int level, wording WHENW) { - int parity, upto = 1; - if (Properties::is_either_or(pr) == FALSE) upto = 0; - for (parity = 0; parity <= upto; parity++) { - property *seek_prn = (parity == 0)?pr:(EitherOrProperties::get_negation(pr)); - if (seek_prn == NULL) continue; - if (PropertyPermissions::find(subj, seek_prn, TRUE) == NULL) continue; - property_permission *pp = PropertyPermissions::grant(subj, seek_prn, FALSE); - PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser = level; - PP_PLUGIN_DATA(parsing, pp)->visibility_sentence = current_sentence; - PP_PLUGIN_DATA(parsing, pp)->visibility_condition = WHENW; - return TRUE; - } - return FALSE; -} - -int Visibility::any_property_visible_to_subject(inference_subject *subj, int allow_inheritance) { - property *pr; - LOOP_OVER(pr, property) { - property_permission *pp = - PropertyPermissions::find(subj, pr, allow_inheritance); - if ((pp) && (PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser > 0)) - return TRUE; - } - return FALSE; -} - -int Visibility::get_level(property_permission *pp) { - return PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser; -} - -parse_node *Visibility::get_condition(property_permission *pp) { - parse_node *spec; - if (Wordings::empty(PP_PLUGIN_DATA(parsing, pp)->visibility_condition)) return NULL; - spec = NULL; - if ((PP_PLUGIN_DATA(parsing, pp)->visibility_condition)) spec = <>; - else spec = Specifications::new_UNKNOWN(PP_PLUGIN_DATA(parsing, pp)->visibility_condition); - if (Dash::validate_conditional_clause(spec) == FALSE) { - LOG("$T", spec); - current_sentence = PP_PLUGIN_DATA(parsing, pp)->visibility_sentence; - StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_BadVisibilityWhen), - "the condition after 'when' makes no sense to me", - "although otherwise this worked - it is only the part after 'when' " - "which I can't follow."); - PP_PLUGIN_DATA(parsing, pp)->visibility_condition = EMPTY_WORDING; - return NULL; - } - return spec; -} - -void Visibility::log_parsing_visibility(inference_subject *infs) { - LOG("Permissions for $j:\n", infs); - property_permission *pp = NULL; - LOOP_OVER_PERMISSIONS_FOR_INFS(pp, infs) { - LOG("$Y: visibility %d, condition %W\n", - PropertyPermissions::get_property(pp), - PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser, - PP_PLUGIN_DATA(parsing, pp)->visibility_condition); - } - if (InferenceSubjects::narrowest_broader_subject(infs)) - Visibility::log_parsing_visibility(InferenceSubjects::narrowest_broader_subject(infs)); -} diff --git a/inform7/if-module/Chapter 5/Parsing Plugin.w b/inform7/if-module/Chapter 5/Parsing Plugin.w index b186ecd1c..0e8337078 100644 --- a/inform7/if-module/Chapter 5/Parsing Plugin.w +++ b/inform7/if-module/Chapter 5/Parsing Plugin.w @@ -66,8 +66,14 @@ typedef struct parsing_data { CLASS_DEFINITION } parsing_data; +parsing_data *ParsingPlugin::new_data(inference_subject *subj) { + parsing_data *pd = CREATE(parsing_data); + pd->understand_as_this_object = NULL; + return pd; +} + int ParsingPlugin::new_subject_notify(inference_subject *subj) { - ATTACH_PLUGIN_DATA_TO_SUBJECT(parsing, subj, Visibility::new_data(subj)); + ATTACH_PLUGIN_DATA_TO_SUBJECT(parsing, subj, ParsingPlugin::new_data(subj)); return FALSE; } @@ -164,7 +170,7 @@ get the |name| property. int ParsingPlugin::complete_model(int stage) { if (stage == WORLD_STAGE_V) { instance *I; - P_parse_name = ValueProperties::new_nameless(I"parse_name", K_value); + property *P_parse_name = ValueProperties::new_nameless(I"parse_name", K_value); LOOP_OVER_INSTANCES(I, K_object) { inference_subject *subj = Instances::as_subject(I); diff --git a/inform7/if-module/Chapter 5/Property Visibility.w b/inform7/if-module/Chapter 5/Property Visibility.w new file mode 100644 index 000000000..ecd77113d --- /dev/null +++ b/inform7/if-module/Chapter 5/Property Visibility.w @@ -0,0 +1,123 @@ +[Visibility::] Property Visibility. + +Some properties can be referred to in the player's commands. + +@ "Visible" properties can be used to describe an object: for example, if +colour is a visible property of a car, then an individual instance of |K_car| +can be referred to by the player as GREEN CAR if and only if that instance has +the colour value "green". + +Properly speaking it is not the property itself which is visible, but the +combination of property and its owner. So we record visibility by attaching +the following blob of data to a |property_permission|: + +@d NO_VISIBILITY_LEVEL 0 +@d REFERRING_TO_VISIBILITY_LEVEL 1 +@d DESCRIBING_VISIBILITY_LEVEL 2 + += +typedef struct parsing_pp_data { + int visibility_level_in_parser; /* one of the |*_VISIBILITY_LEVEL| values above */ + struct wording visibility_condition; /* (at least if...?) */ + struct parse_node *visibility_sentence; /* where this is specified */ + CLASS_DEFINITION +} parsing_pp_data; + +parsing_pp_data *Visibility::new_pp_data(property_permission *pp) { + parsing_pp_data *pd = CREATE(parsing_pp_data); + pd->visibility_level_in_parser = NO_VISIBILITY_LEVEL; + pd->visibility_condition = EMPTY_WORDING; + pd->visibility_sentence = NULL; + return pd; +} + +int Visibility::new_permission_notify(property_permission *new_pp) { + CREATE_PLUGIN_PP_DATA(parsing, new_pp, Visibility::new_pp_data); + return FALSE; +} + +@ The following function sets the visibility level and condition for a given +property and owner, returning |FALSE| if the owner cannot in fact have that +property. There's a little dance here because perhaps we want to set visibility +for "open" when its negation "closed" has the permission, or vice versa. + += +int Visibility::set(property *pr, inference_subject *subj, int level, wording WHENW) { + int upto = 1; + if (Properties::is_either_or(pr) == FALSE) upto = 0; + for (int parity = 0; parity <= upto; parity++) { + property *seek_prn = (parity == 0)?pr:(EitherOrProperties::get_negation(pr)); + if ((seek_prn) && (PropertyPermissions::find(subj, seek_prn, TRUE))) { + property_permission *pp = PropertyPermissions::grant(subj, seek_prn, FALSE); + PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser = level; + PP_PLUGIN_DATA(parsing, pp)->visibility_condition = WHENW; + PP_PLUGIN_DATA(parsing, pp)->visibility_sentence = current_sentence; + return TRUE; + } + } + return FALSE; +} + +@ Does the property owner |subj| have any visible properties? + += +int Visibility::any_property_visible_to_subject(inference_subject *subj, + int allow_inheritance) { + property *pr; + LOOP_OVER(pr, property) { + property_permission *pp = PropertyPermissions::find(subj, pr, allow_inheritance); + if ((pp) && (PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser > 0)) + return TRUE; + } + return FALSE; +} + +@ For what these levels actually mean, see the code for the run-time command parser +at //CommandParserKit: Parser//. + += +int Visibility::get_level(property_permission *pp) { + return PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser; +} + +@ The condition text, if supplied, says that the property is only visible +if some condition holds. + +For timing reasons, we don't parse this when it is first declared, but only +when we need it, which is now: + += +parse_node *Visibility::get_condition(property_permission *pp) { + wording W = PP_PLUGIN_DATA(parsing, pp)->visibility_condition; + if (Wordings::empty(W)) return NULL; + parse_node *spec = NULL; + if ((W)) spec = <>; + else spec = Specifications::new_UNKNOWN(W); + if (Dash::validate_conditional_clause(spec) == FALSE) { + current_sentence = PP_PLUGIN_DATA(parsing, pp)->visibility_sentence; + StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_BadVisibilityWhen), + "the condition after 'when' makes no sense to me", + "although otherwise this worked - it is only the part after 'when' " + "which I can't follow."); + PP_PLUGIN_DATA(parsing, pp)->visibility_condition = EMPTY_WORDING; + return NULL; + } + return spec; +} + +@ Though currently unused, this function may be useful for debugging: + += +void Visibility::log_parsing_visibility(inference_subject *infs) { + LOG("Permissions for $j:\n", infs); + property_permission *pp = NULL; + LOOP_OVER_PERMISSIONS_FOR_INFS(pp, infs) { + LOG("$Y: visibility %d, condition %W\n", + PropertyPermissions::get_property(pp), + PP_PLUGIN_DATA(parsing, pp)->visibility_level_in_parser, + PP_PLUGIN_DATA(parsing, pp)->visibility_condition); + } + if (InferenceSubjects::narrowest_broader_subject(infs)) + Visibility::log_parsing_visibility( + InferenceSubjects::narrowest_broader_subject(infs)); +} diff --git a/inform7/if-module/Chapter 5/Understand Sentences.w b/inform7/if-module/Chapter 5/Understand Sentences.w index 701be4e53..f9312af1d 100644 --- a/inform7/if-module/Chapter 5/Understand Sentences.w +++ b/inform7/if-module/Chapter 5/Understand Sentences.w @@ -404,8 +404,8 @@ Once again, the object can't be a list. ==> { R[1], RP[1] } ::= - referring to | ==> { 1, RP[1] } - describing | ==> { 2, RP[1] } + referring to | ==> { REFERRING_TO_VISIBILITY_LEVEL, RP[1] } + describing | ==> { DESCRIBING_VISIBILITY_LEVEL, RP[1] } ... ==> @ ::= @@ -565,7 +565,7 @@ it, one at a time, by previous Understand sentences. } @h Property blocks. -Again, some semantic checks, but the real work is delegated to //Visibility::seek//. +Again, some semantic checks, but the real work is delegated to //Visibility::set//. = void Understand::property_block(property *pr, int level, inference_subject *subj, wording WHENW) { @@ -596,7 +596,7 @@ void Understand::property_block(property *pr, int level, inference_subject *subj "of day, or units; but certain built-into-Inform kinds of value " "(like snippet or rulebook, for instance) I can't use."); } - if (Visibility::seek(pr, subj, level, WHENW) == FALSE) { + if (Visibility::set(pr, subj, level, WHENW) == FALSE) { StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_UnknownUnpermittedProperty), "that property is not allowed for the thing or kind in question", @@ -801,10 +801,12 @@ void Understand::text_block(wording W, understanding_reference *ur) { (Kinds::Behaviour::is_subkind_of_object(Specifications::to_kind(spec)) == FALSE) && (Descriptions::number_of_adjectives_applied_to(spec) == 1) && (AdjectivalPredicates::parity( - Propositions::first_unary_predicate(Specifications::to_proposition(spec), NULL)))) { + Propositions::first_unary_predicate( + Specifications::to_proposition(spec), NULL)))) { adjective *aph = AdjectivalPredicates::to_adjective( - Propositions::first_unary_predicate(Specifications::to_proposition(spec), NULL)); + Propositions::first_unary_predicate( + Specifications::to_proposition(spec), NULL)); instance *q = AdjectiveAmbiguity::has_enumerative_meaning(aph); if (q) { ur->cg_result = CG_IS_VALUE; @@ -833,63 +835,9 @@ void Understand::text_block(wording W, understanding_reference *ur) { } @ = - wchar_t *as_wide_string = Lexer::word_text(Wordings::first_wn(W)); - @; - wording tokenised = Feeds::feed_C_string_full(as_wide_string, TRUE, - GRAMMAR_PUNCTUATION_MARKS); - @; - - tokens = CGTokens::break_into_tokens(NULL, tokenised); - if (tokens == NULL) { - StandardProblems::sentence_problem(Task::syntax_tree(), - _p_(PM_UnderstandEmptyText), - "'understand' should be followed by text which contains at least " - "one word or square-bracketed token", - "so for instance 'understand \"take [something]\" as taking' is fine, " - "but 'understand \"\" as the fog' is not. The same applies to the contents " - "of 'topic' columns in tables, since those are also instructions for " - "understanding."); - return; - } - -@ = - int skip = FALSE, literal_punct = FALSE; - for (int i=0; as_wide_string[i]; i++) { - if (as_wide_string[i] == '[') skip = TRUE; - if (as_wide_string[i] == ']') skip = FALSE; - if (skip) continue; - if ((as_wide_string[i] == '.') || (as_wide_string[i] == ',') || - (as_wide_string[i] == '!') || (as_wide_string[i] == '?') || - (as_wide_string[i] == ':') || (as_wide_string[i] == ';')) - literal_punct = TRUE; - } - if (literal_punct) { - StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_LiteralPunctuation), - "'understand' text cannot contain literal punctuation", - "or more specifically cannot contain any of these: . , ! ? : ; since they " - "are already used in various ways by the parser, and would not correctly " - "match here."); - return; - } - -@ = - LOOP_THROUGH_WORDING(i, tokenised) - if (i < Wordings::last_wn(tokenised)) - if ((compare_word(i, COMMA_V)) && (compare_word(i+1, COMMA_V))) { - StandardProblems::sentence_problem(Task::syntax_tree(), - _p_(PM_UnderstandCommaCommand), - "'understand' as an action cannot involve a comma", - "since a command leading to an action never does. " - "(Although Inform understands commands like 'PETE, LOOK' " - "only the part after the comma is read as an action command: " - "the part before the comma is read as the name of someone, " - "according to the usual rules for parsing a name.) " - "Because of the way Inform processes text with square " - "brackets, this problem message is also sometimes seen " - "if empty square brackets are used, as in 'Understand " - "\"bless []\" as blessing.'"); - return; - } + int np = problem_count; + tokens = CGTokens::tokenise(W); + if (problem_count > np) return; @ = cgl = CGLines::new(W, ur->an_reference, tokens, diff --git a/inform7/if-module/Contents.w b/inform7/if-module/Contents.w index 8f2b98f1d..f604e0c97 100644 --- a/inform7/if-module/Contents.w +++ b/inform7/if-module/Contents.w @@ -60,7 +60,4 @@ Chapter 5: Command Parser Command Grammar Lines Command Grammar Tokens Determination Types - Grammar Properties - Noun Filter Tokens - Tokens Parsing Values - General Parsing Routines + Property Visibility diff --git a/inform7/runtime-module/Chapter 5/Command Grammar Lines.w b/inform7/runtime-module/Chapter 5/Command Grammar Lines.w index 4293603b6..225972d2f 100644 --- a/inform7/runtime-module/Chapter 5/Command Grammar Lines.w +++ b/inform7/runtime-module/Chapter 5/Command Grammar Lines.w @@ -479,7 +479,7 @@ void RTCommandGrammarLines::compile_token_line(gpr_kit *gprk, int code_mode, cg_ LOG_INDENT; for (; cgt; cgt = cgt->next_token) { LOGIF(GRAMMAR_CONSTRUCTION, "Compiling token $c\n", cgt); - if ((cgt->grammar_token_code == TOPIC_TOKEN_GTC) && (cgt->next_token) && + if ((CGTokens::is_topic(cgt)) && (cgt->next_token) && (CGTokens::is_literal(cgt->next_token) == FALSE)) { StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_TextFollowedBy), "a '[text]' token must either match the end of some text, or " @@ -518,8 +518,6 @@ void RTCommandGrammarLines::compile_token_line(gpr_kit *gprk, int code_mode, cg_ alternative_number = 1; } -if (empty_text_allowed_in_lexeme) LOG("empty_text_allowed_in_lexeme!\n"); - inter_symbol *jump_on_fail = fail_label; if (lexeme_equivalence_class > 0) { @@ -1248,10 +1246,8 @@ kind *RTCommandGrammarLines::compile_token(gpr_kit *gprk, cg_token *cgt, int cod return NULL; } - spec = cgt->grammar_value; - if (spec == NULL) CGTokens::determine(cgt, 10, NULL); - spec = cgt->grammar_value; - if (spec == NULL) internal_error("NULL result of non-preposition token"); + spec = cgt->what_token_describes; + if (cgt->defined_by) spec = ParsingPlugin::rvalue_from_command_grammar(cgt->defined_by); if (Specifications::is_kind_like(spec)) { kind *K = Node::get_kind_of_value(spec); @@ -1312,12 +1308,11 @@ kind *RTCommandGrammarLines::compile_token(gpr_kit *gprk, cg_token *cgt, int cod return K_object; } else { kind *K = NULL; - int gtc = cgt->grammar_token_code; - if (gtc < 0) { - inter_name *i6_token_iname = CGTokens::iname_for_special_token(gtc); - K = CGTokens::kind_for_special_token(gtc); + if (CGTokens::is_I6_parser_token(cgt)) { + inter_name *i6_token_iname = RTCommandGrammars::iname_for_I6_parser_token(cgt); + K = Descriptions::explicit_kind(cgt->what_token_describes); if (code_mode) { - if ((consult_mode) && (gtc == TOPIC_TOKEN_GTC)) { + if ((consult_mode) && (CGTokens::is_topic(cgt))) { StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_TextTokenRestricted), "the '[text]' token is not allowed with 'matches' " "or in table columns", @@ -1362,7 +1357,7 @@ kind *RTCommandGrammarLines::compile_token(gpr_kit *gprk, cg_token *cgt, int cod Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s); Produce::inv_call_iname(Emit::tree(), Hierarchy::find(PARSETOKENSTOPPED_HL)); Produce::down(Emit::tree()); - UnderstandFilterTokens::compile_id(gtc); + UnderstandFilterTokens::compile_id(cgt->noun_filter); Produce::up(Emit::tree()); Produce::up(Emit::tree()); Produce::inv_primitive(Emit::tree(), IF_BIP); @@ -1380,7 +1375,7 @@ kind *RTCommandGrammarLines::compile_token(gpr_kit *gprk, cg_token *cgt, int cod Produce::val_symbol(Emit::tree(), K_value, gprk->w_s); Produce::up(Emit::tree()); } else { - UnderstandFilterTokens::emit_id(gtc); + UnderstandFilterTokens::emit_id(cgt->noun_filter); } } else { if (Kinds::Behaviour::offers_I6_GPR(K)) { @@ -1425,7 +1420,7 @@ kind *RTCommandGrammarLines::compile_token(gpr_kit *gprk, cg_token *cgt, int cod Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s); Produce::inv_call_iname(Emit::tree(), Hierarchy::find(PARSETOKENSTOPPED_HL)); Produce::down(Emit::tree()); - UnderstandFilterTokens::compile_id(gtc); + UnderstandFilterTokens::compile_id(cgt->noun_filter); Produce::up(Emit::tree()); Produce::up(Emit::tree()); Produce::inv_primitive(Emit::tree(), IF_BIP); @@ -1443,15 +1438,14 @@ kind *RTCommandGrammarLines::compile_token(gpr_kit *gprk, cg_token *cgt, int cod Produce::val_symbol(Emit::tree(), K_value, gprk->w_s); Produce::up(Emit::tree()); } else { - UnderstandFilterTokens::emit_id(gtc); + UnderstandFilterTokens::emit_id(cgt->noun_filter); } K = K_object; } else internal_error("no token for description"); } } else { - if (Node::is(spec, CONSTANT_NT)) { - if ((K_understanding) && (Rvalues::is_CONSTANT_of_kind(spec, K_understanding))) { - cg = ParsingPlugin::rvalue_to_command_grammar(spec); + if (cgt->defined_by) { + cg = cgt->defined_by; if (code_mode) { Produce::inv_primitive(Emit::tree(), STORE_BIP); Produce::down(Emit::tree()); @@ -1492,7 +1486,8 @@ kind *RTCommandGrammarLines::compile_token(gpr_kit *gprk, cg_token *cgt, int cod Emit::array_iname_entry(RTCommandGrammars::i6_token_as_iname(cg)); } K = CommandGrammars::get_kind_matched(cg); - } + } else + if (Node::is(spec, CONSTANT_NT)) { if (Rvalues::is_object(spec)) { if (code_mode) { Produce::inv_primitive(Emit::tree(), STORE_BIP); @@ -1500,7 +1495,7 @@ kind *RTCommandGrammarLines::compile_token(gpr_kit *gprk, cg_token *cgt, int cod Produce::ref_symbol(Emit::tree(), K_value, gprk->w_s); Produce::inv_call_iname(Emit::tree(), Hierarchy::find(PARSETOKENSTOPPED_HL)); Produce::down(Emit::tree()); - UnderstandFilterTokens::compile_id(gtc); + UnderstandFilterTokens::compile_id(cgt->noun_filter); Produce::up(Emit::tree()); Produce::up(Emit::tree()); Produce::inv_primitive(Emit::tree(), IF_BIP); @@ -1518,7 +1513,7 @@ kind *RTCommandGrammarLines::compile_token(gpr_kit *gprk, cg_token *cgt, int cod Produce::val_symbol(Emit::tree(), K_value, gprk->w_s); Produce::up(Emit::tree()); } else { - UnderstandFilterTokens::emit_id(gtc); + UnderstandFilterTokens::emit_id(cgt->noun_filter); } K = K_object; } diff --git a/inform7/runtime-module/Chapter 5/Command Grammars.w b/inform7/runtime-module/Chapter 5/Command Grammars.w index c4348e63c..0d94f884e 100644 --- a/inform7/runtime-module/Chapter 5/Command Grammars.w +++ b/inform7/runtime-module/Chapter 5/Command Grammars.w @@ -85,6 +85,22 @@ inter_name *VERB_DIRECTIVE_CREATURE_iname = NULL; inter_name *VERB_DIRECTIVE_TOPIC_iname = NULL; inter_name *VERB_DIRECTIVE_MULTIEXCEPT_iname = NULL; +inter_name *RTCommandGrammars::iname_for_I6_parser_token(cg_token *cgt) { + switch (cgt->grammar_token_code) { + case NOUN_TOKEN_GTC: return VERB_DIRECTIVE_NOUN_iname; + case MULTI_TOKEN_GTC: return VERB_DIRECTIVE_MULTI_iname; + case MULTIINSIDE_TOKEN_GTC: return VERB_DIRECTIVE_MULTIINSIDE_iname; + case MULTIHELD_TOKEN_GTC: return VERB_DIRECTIVE_MULTIHELD_iname; + case HELD_TOKEN_GTC: return VERB_DIRECTIVE_HELD_iname; + case CREATURE_TOKEN_GTC: return VERB_DIRECTIVE_CREATURE_iname; + case TOPIC_TOKEN_GTC: return VERB_DIRECTIVE_TOPIC_iname; + case MULTIEXCEPT_TOKEN_GTC: return VERB_DIRECTIVE_MULTIEXCEPT_iname; + default: internal_error("tried to find inter name for invalid GTC"); + } + return NULL; /* to prevent a gcc error: never reached */ +} + + inter_name *RTCommandGrammars::grammar_constant(int N, int V) { inter_name *iname = Hierarchy::find(N); Emit::named_numeric_constant(iname, 1); diff --git a/inform7/if-module/Chapter 5/General Parsing Routines.w b/inform7/runtime-module/Chapter 5/General Parsing Routines.w similarity index 99% rename from inform7/if-module/Chapter 5/General Parsing Routines.w rename to inform7/runtime-module/Chapter 5/General Parsing Routines.w index adf63ab80..af8da95a5 100644 --- a/inform7/if-module/Chapter 5/General Parsing Routines.w +++ b/inform7/runtime-module/Chapter 5/General Parsing Routines.w @@ -7,8 +7,8 @@ properties as required by the I7 grammar. = typedef struct parse_name_notice { - inter_name *pnn_iname; - inference_subject *parse_subject; + struct inter_name *pnn_iname; + struct inference_subject *parse_subject; CLASS_DEFINITION } parse_name_notice; diff --git a/inform7/if-module/Chapter 5/Noun Filter Tokens.w b/inform7/runtime-module/Chapter 5/Noun Filter Tokens.w similarity index 82% rename from inform7/if-module/Chapter 5/Noun Filter Tokens.w rename to inform7/runtime-module/Chapter 5/Noun Filter Tokens.w index 2d9f313ed..ef17f9239 100644 --- a/inform7/if-module/Chapter 5/Noun Filter Tokens.w +++ b/inform7/runtime-module/Chapter 5/Noun Filter Tokens.w @@ -24,15 +24,6 @@ their names (used as I6 tokens), and compile their routines. = noun_filter_token *UnderstandFilterTokens::nft_new(parse_node *spec, int global_scope, int any_things) { - pcalc_prop *prop = Specifications::to_proposition(spec); - if ((prop) && (Binding::number_free(prop) != 1)) { - LOG("So $P and $D\n", spec, prop); - StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_FilterQuantified), - "the [any ...] doesn't clearly give a description in the '...' part", - "where I was expecting something like '[any vehicle]'."); - spec = Specifications::from_kind(K_object); - } - noun_filter_token *nft = CREATE(noun_filter_token); nft->the_filter = spec; nft->global_scope_flag = global_scope; @@ -251,50 +242,28 @@ the |parse_node| structure can't conveniently be annotated with pointers, that's why.) = -int too_late_for_further_NFTs = FALSE; - -int UnderstandFilterTokens::new_id(parse_node *spec, int global_scope, int any_things) { - if (too_late_for_further_NFTs) - StandardProblems::sentence_problem(Task::syntax_tree(), _p_(BelievedImpossible), - "complicated instructions on understanding the player's command " - "are not allowed in the past tense", - "for instance by being applied to several previous turns in a row."); - - kind *K = Specifications::to_kind(spec); - if ((Kinds::Behaviour::is_object(K) == FALSE) && (Kinds::Behaviour::request_I6_GPR(K) == FALSE) && (global_scope)) - StandardProblems::sentence_problem(Task::syntax_tree(), _p_(BelievedImpossible), - "this is a kind of value I can't understand in command grammar", - "so the '[any ...]' part will have to go."); - - return UnderstandFilterTokens::nft_new(spec, global_scope, any_things)->allocation_id; +void UnderstandFilterTokens::compile_id(noun_filter_token *nft) { + if (nft) { + if (nft->parse_using_gpr) Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_TT_HL)); + else if (nft->global_scope_flag) Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SCOPE_TT_HL)); + else Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(ROUTINEFILTER_TT_HL)); + Produce::val_iname(Emit::tree(), K_value, nft->nft_iname); + } } -void UnderstandFilterTokens::compile_id(int id) { - noun_filter_token *nft; - LOOP_OVER(nft, noun_filter_token) - if (nft->allocation_id == id) { - if (nft->parse_using_gpr) Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(GPR_TT_HL)); - else if (nft->global_scope_flag) Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(SCOPE_TT_HL)); - else Produce::val_iname(Emit::tree(), K_value, Hierarchy::find(ROUTINEFILTER_TT_HL)); - Produce::val_iname(Emit::tree(), K_value, nft->nft_iname); - } -} - -void UnderstandFilterTokens::emit_id(int id) { - noun_filter_token *nft; - LOOP_OVER(nft, noun_filter_token) - if (nft->allocation_id == id) { - inter_ti annot = 0; - if (nft->parse_using_gpr == FALSE) { - if (nft->global_scope_flag) annot = SCOPE_FILTER_IANN; - else annot = NOUN_FILTER_IANN; - } - inter_name *iname = UnderstandFilterTokens::nft_compile_routine_iname(nft); - if (annot != 0) - if (Produce::read_annotation(iname, annot) != 1) - Produce::annotate_i(iname, annot, 1); - Emit::array_iname_entry(iname); +void UnderstandFilterTokens::emit_id(noun_filter_token *nft) { + if (nft) { + inter_ti annot = 0; + if (nft->parse_using_gpr == FALSE) { + if (nft->global_scope_flag) annot = SCOPE_FILTER_IANN; + else annot = NOUN_FILTER_IANN; } + inter_name *iname = UnderstandFilterTokens::nft_compile_routine_iname(nft); + if (annot != 0) + if (Produce::read_annotation(iname, annot) != 1) + Produce::annotate_i(iname, annot, 1); + Emit::array_iname_entry(iname); + } } @h Compiling everything. @@ -309,5 +278,4 @@ void UnderstandFilterTokens::compile(void) { UnderstandFilterTokens::nft_compile_routine(nft); nft->nft_compiled = TRUE; } - /* too_late_for_further_NFTs = TRUE; */ } diff --git a/inform7/if-module/Chapter 5/Tokens Parsing Values.w b/inform7/runtime-module/Chapter 5/Tokens Parsing Values.w similarity index 100% rename from inform7/if-module/Chapter 5/Tokens Parsing Values.w rename to inform7/runtime-module/Chapter 5/Tokens Parsing Values.w diff --git a/inform7/runtime-module/Contents.w b/inform7/runtime-module/Contents.w index df875aaa1..1b6065824 100644 --- a/inform7/runtime-module/Contents.w +++ b/inform7/runtime-module/Contents.w @@ -80,3 +80,6 @@ Chapter 5: Plugin Support Going Command Grammars Command Grammar Lines + Noun Filter Tokens + Tokens Parsing Values + General Parsing Routines