1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-06-17 07:40:47 +03:00

Changeover to new Preform notation 1

This commit is contained in:
Graham Nelson 2020-07-28 09:57:58 +01:00
parent f3781d3e97
commit bd86a9f9ea
28 changed files with 137 additions and 134 deletions

View file

@ -86,8 +86,8 @@ word "Include", which might e.g. be "Locksmith by Emily Short".
<extension-unversioned> ==> -1
<extension-unversioned> ::=
<extension-unversioned-inner> ( ... ) | ==> 0
<extension-unversioned-inner> ==> 0
<extension-unversioned-inner> ( ... ) | ==> { 0, - }
<extension-unversioned-inner> ==> { 0, - }
<extension-unversioned-inner> ::=
<quoted-text> *** | ==> @<Issue PM_IncludeExtQuoted problem@>

View file

@ -240,11 +240,11 @@ and here goes:
<extension-end-marker-sentence> ==> R[1]
<heading> ::=
volume ... | ==> 1
book ... | ==> 2
part ... | ==> 3
chapter ... | ==> 4
section ... ==> 5
volume ... | ==> { 1, - }
book ... | ==> { 2, - }
part ... | ==> { 3, - }
chapter ... | ==> { 4, - }
section ... ==> { 5, - }
<extension-end-marker-sentence> ::=
... begin/begins here | ==> -1; @<Check we can begin an extension here@>;

View file

@ -1,37 +1,43 @@
100.0% in inform7 run
67.1% in compilation to Inter
25.8% in //Phrases::Manager::compile_first_block//
9.1% in //Phrases::Manager::compile_as_needed//
6.8% in //Strings::compile_responses//
5.9% in //World::Compile::compile//
3.5% in //Assertions::Traverse::traverse1//
3.2% in //Sentences::VPs::traverse//
66.7% in compilation to Inter
25.0% in //Phrases::Manager::compile_first_block//
9.0% in //Phrases::Manager::compile_as_needed//
7.1% in //Strings::compile_responses//
6.5% in //World::Compile::compile//
3.3% in //Assertions::Traverse::traverse1//
3.3% in //Sentences::VPs::traverse//
2.0% in //Phrases::Manager::RulePrintingRule_routine//
1.8% in //Phrases::Manager::rulebooks_array//
1.0% in //NewVerbs::ConjugateVerb//
1.9% in //Phrases::Manager::rulebooks_array//
0.9% in //NewVerbs::ConjugateVerb//
0.8% in //Phrases::Manager::traverse//
0.5% in //Phrases::Manager::parse_rule_parameters//
0.3% in //Phrases::Manager::compile_rulebooks//
0.4% in //Phrases::Manager::compile_rulebooks//
0.3% in //Assertions::Traverse::traverse2//
0.3% in //Phrases::Manager::traverse_for_names//
0.3% in //Relations::compile_defined_relations//
0.1% in //Assertions::Traverse::traverse2//
0.2% in //Task::load_types//
0.2% in //World::complete//
0.1% in //Emit::begin//
0.1% in //Index::DocReferences::read_xrefs//
0.1% in //Kinds::Knowledge::include_templates_for_kinds//
0.1% in //PL::Parsing::Verbs::compile_all//
0.1% in //Phrases::Manager::add_rules_to_rulebooks//
0.1% in //Sentences::Rearrangement::tidy_up_ofs_and_froms//
0.1% in //Sentences::RuleSubtrees::register_recently_lexed_phrases//
0.1% in //Task::load_types//
0.1% in //World::complete//
4.3% not specifically accounted for
30.4% in running Inter pipeline
10.9% in step preparation
9.8% in inter step 2/12: link
7.1% in inter step 12/12: generate inform6 -> auto.inf
0.1% in //World::complete_additions//
3.0% not specifically accounted for
31.0% in running Inter pipeline
10.7% in step preparation
10.1% in inter step 2/12: link
7.2% in inter step 12/12: generate inform6 -> auto.inf
0.3% in inter step 10/12: reconcile-verbs
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.2% in inter step 11/12: eliminate-redundant-labels
0.2% in inter step 6/12: assimilate
0.2% in inter step 7/12: resolve-external-symbols
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
1.0% not specifically accounted for
2.0% in supervisor
0.4% not specifically accounted for
1.2% not specifically accounted for
1.9% in supervisor
0.3% not specifically accounted for

View file

@ -122,12 +122,12 @@ testing the existence of something.
=
<s-nonexistential-phrase-to-decide> ::=
<existential-verb-phrase> | ==> NULL; return FAIL_NONTERMINAL;
<existential-verb-phrase> | ==> { fail }
<s-phrase-to-decide> | ==> RP[1]
not <s-phrase-to-decide> ==> Conditions::negate(RP[1])
<s-existential-phrase-to-decide> ::=
^<existential-verb-phrase> | ==> NULL; return FAIL_NONTERMINAL;
^<existential-verb-phrase> | ==> { fail }
<s-phrase-to-decide> | ==> RP[1]
not <s-phrase-to-decide> ==> Conditions::negate(RP[1])
@ -225,7 +225,7 @@ typechecking to choose between much later on.
<s-text-substitution> ==> RP[1]
<s-adaptive-text> ::=
<s-local-variable> | ==> NULL; return FAIL_NONTERMINAL
<s-local-variable> | ==> { fail }
<adaptive-verb> verb | ==> ExParser::say_verb(RP[1], R[1], NULL, W)
<adaptive-adjective> adjective | ==> ExParser::say_adjective(RP[1], W)
<adaptive-verb> | ==> ExParser::say_verb(RP[1], R[1], NULL, W)

View file

@ -41,7 +41,7 @@ placeholder to stand for a missing noun phrase:
@<Make SV@> =
ExParser::Subtrees::correct_for_adjectives(RP[1], RP[2]);
*XP = ExParser::Subtrees::to_specification(TRUE, W, RP[1], RP[2]);
==> { -, ExParser::Subtrees::to_specification(TRUE, W, RP[1], RP[2]) }
@ An ugly trick, invisible from the grammar itself, is that we forbid the
object to be a value. This removes cases like "if there is 21", but in fact
@ -54,8 +54,8 @@ so ambiguous -- a bad decision in about 2003.)
parse_node *op = RP[2];
parse_node *test = op->down;
if (Node::is(test, AMBIGUITY_NT)) test = test->down;
if (Specifications::is_description_like(test) == FALSE) return FAIL_NONTERMINAL;
*XP = ExParser::Subtrees::to_specification(TRUE, W, NULL, op);
if (Specifications::is_description_like(test) == FALSE) { ==> { fail } }
==> { -, ExParser::Subtrees::to_specification(TRUE, W, NULL, op) }
@ More generally, the tail syntax splits according to the verb in question. The
copular verb "to be" has special syntactic rules for its object phrase (for
@ -240,21 +240,18 @@ is the same as that matched by <s-value>.
@ Finally, the following is needed for conditions ("if fixed in place
scenery, ...") where the object referred to is understood from context.
=
<s-descriptive-np> ::=
( <s-descriptive-np> ) | ==> RP[1]
<cardinal-number> | ==> @<Reject a bare number as descriptive@>
<s-description> | ==> @<Construct a descriptive SN subtree@>
<s-adjective-list-as-desc> ==> @<Construct a descriptive SN subtree@>
@ The reason a literal number is explicitly not allowed to be a condition is
The reason a literal number is explicitly not allowed to be a condition is
that if something is created called (say) "Room 62" then "62" might be read
by <s-description> as an abbreviated reference to that room. (This doesn't
happen with non-descriptive NPs because then literal values are tried earlier,
pre-empting descriptions.)
@<Reject a bare number as descriptive@> =
return FAIL_NONTERMINAL;
=
<s-descriptive-np> ::=
( <s-descriptive-np> ) | ==> RP[1]
<cardinal-number> | ==> { fail }
<s-description> | ==> @<Construct a descriptive SN subtree@>
<s-adjective-list-as-desc> ==> @<Construct a descriptive SN subtree@>
@<Construct a descriptive SN subtree@> =
parse_node *sn = RP[1];

View file

@ -132,9 +132,9 @@ void Equations::visit_to_create(parse_node *p) {
=
<equation-name> ::=
equation {<cardinal-number>} - ... | ==> 3
equation {<cardinal-number>} | ==> 1
equation - ... | ==> 2
equation {<cardinal-number>} - ... | ==> { 3, - }
equation {<cardinal-number>} | ==> { 1, - }
equation - ... | ==> { 2, - }
equation *** ==> @<Issue PM_EquationMisnumbered problem@>
@ The above catches all of the named expressions written out in the
@ -372,12 +372,12 @@ mass, too.
=
<equation-where-list> ::=
... | ==> 0; eq_symbol_wn = Wordings::first_wn(W); return preform_lookahead_mode; /* match only when looking ahead */
<equation-where-setting-entry> <equation-where-tail> | ==> 0
<equation-where-setting-entry> ==> 0
<equation-where-setting-entry> <equation-where-tail> | ==> { 0, - }
<equation-where-setting-entry> ==> { 0, - }
<equation-where-tail> ::=
, _and <equation-where-list> | ==> 0
_,/and <equation-where-list> ==> 0
, _and <equation-where-list> | ==> { 0, - }
_,/and <equation-where-list> ==> { 0, - }
<equation-where-setting-entry> ::=
<equation-where-setting> ==> 0; if (!preform_lookahead_mode) Equations::eqn_dec_var(equation_being_declared, Wordings::one_word(eq_symbol_wn), R[1], RP[1]);

View file

@ -97,13 +97,13 @@ can be what rulebook does if it none of its rules cause an outcome.
=
<rulebook-default-outcome> ::=
<rule-outcome> | ==> @<Make this the rulebook's new default@>
... ==> @<Issue PM_BadDefaultOutcome problem@>
<rule-outcome> | ==> @<Make this the rulebook's new default@>
... ==> @<Issue PM_BadDefaultOutcome problem@>
<rule-outcome> ::=
success | ==> SUCCESS_OUTCOME
failure | ==> FAILURE_OUTCOME
no outcome ==> NO_OUTCOME
success | ==> { SUCCESS_OUTCOME, - }
failure | ==> { FAILURE_OUTCOME, - }
no outcome ==> { NO_OUTCOME, - }
@<Make this the rulebook's new default@> =
if (outcomes_being_parsed->default_outcome_declared) {
@ -135,12 +135,12 @@ The following parses a declaration of named outcomes. For example:
=
<rulebook-outcome-list> ::=
... | ==> 0; return preform_lookahead_mode; /* match only when looking ahead */
<rulebook-outcome-setting-entry> <rulebook-outcome-tail> | ==> 0
<rulebook-outcome-setting-entry> ==> 0
<rulebook-outcome-setting-entry> <rulebook-outcome-tail> | ==> { 0, - }
<rulebook-outcome-setting-entry> ==> { 0, - }
<rulebook-outcome-tail> ::=
, _and/or <rulebook-outcome-list> | ==> 0
_,/and/or <rulebook-outcome-list> ==> 0
, _and/or <rulebook-outcome-list> | ==> { 0, - }
_,/and/or <rulebook-outcome-list> ==> { 0, - }
<rulebook-outcome-setting-entry> ::=
<form-of-named-rule-outcome> ==> 0; if (!preform_lookahead_mode) @<Adopt this new named rule outcome@>

View file

@ -155,7 +155,7 @@ phrase definitions and timed events don't open the rulebook name.
at *** | ==> @<Issue PM_RulebookWithAt problem@>
to *** | ==> @<Issue PM_RulebookWithTo problem@>
definition *** | ==> @<Issue PM_RulebookWithDefinition problem@>
... ==> 0
... ==> { 0, - }
@<Issue PM_RulebookWithAt problem@> =
StandardProblems::sentence_problem(Task::syntax_tree(), _p_(PM_RulebookWithAt),

View file

@ -129,9 +129,9 @@ and the second and third pieces used as headings and subheadings respectively.
{<heading-name-hyphenated>}
<heading-name-hyphenated> ::=
... - ... - ... | ==> 3
... - ... | ==> 2
... ==> 1
... - ... - ... | ==> { 3, - }
... - ... | ==> { 2, - }
... ==> { 1, - }
@ We then extract "Control phrases" as the "clue".

View file

@ -105,8 +105,8 @@ test_scenario *ts_being_parsed = NULL;
<test-case-circumstance-list> ::=
... | ==> 0; return preform_lookahead_mode;
<test-case-circumstance-list> <test-case-circumstance> | ==> 0
<test-case-circumstance> ==> 0
<test-case-circumstance-list> <test-case-circumstance> | ==> { 0, - }
<test-case-circumstance> ==> { 0, - }
<test-case-circumstance> ::=
in <instance-of-object> | ==> @<Process the in-test requirement@>

View file

@ -144,8 +144,8 @@ option name is taken from the |...| or |###| as appropriate:
<use-sentence-object> ::=
... of at least <cardinal-number-unlimited> | ==> R[1]
### of <cardinal-number-unlimited> | ==> -R[1]
<definite-article> ... | ==> 0
... ==> 0
<definite-article> ... | ==> { 0, - }
... ==> { 0, - }
<use-inter-pipeline> ::=
inter pipeline {<quoted-text>} ==> TRUE

View file

@ -270,7 +270,7 @@ int NewVerbs::new_verb_SMF(int task, parse_node *V, wording *NPs) {
<verb-means-sentence-subject-unarticled> ==> R[1]; *XP = RP[1]
<verb-means-sentence-subject-unarticled> ::=
verb to | ==> FALSE; return FAIL_NONTERMINAL;
verb to | ==> { fail }
verb <np-unparsed> in the imperative | ==> TRUE; *XP = RP[1]
verb <np-unparsed> ==> FALSE; *XP = RP[1]

View file

@ -325,7 +325,7 @@ to be the name of a kind, possibly in the plural.
<relation-term-basic> ::=
one ... | ==> ONE_RBIT
various ... | ==> VAR_RBIT
... ==> 0
... ==> { 0, - }
@h The parsing phase.
Our aims here are:

View file

@ -509,8 +509,8 @@ Problem message than the one they will otherwise receive later on.
... <bad-nonstructural-sentence-diagnosis-tail>
<bad-nonstructural-sentence-diagnosis-tail> ::=
<relative-clause-marker> <certainty> <meaningful-nonimperative-verb> ... | ==> 0; return FAIL_NONTERMINAL + Wordings::first_wn(WR[1]) - Wordings::first_wn(W);
<relative-clause-marker> <meaningful-nonimperative-verb> ... | ==> 0; return FAIL_NONTERMINAL + Wordings::first_wn(WR[1]) - Wordings::first_wn(W);
<relative-clause-marker> <certainty> <meaningful-nonimperative-verb> ... | ==> { advance Wordings::delta(WR[1], W) }
<relative-clause-marker> <meaningful-nonimperative-verb> ... | ==> { advance Wordings::delta(WR[1], W) }
<past-tense-verb> ... | ==> @<Issue PM_NonPresentTense problem@>
<negated-verb> ... ==> @<Issue PM_NegatedVerb1 problem@>

View file

@ -217,7 +217,7 @@ property names before they can do any damage.)
{_,/and} <has-properties-called-sentence-object>
<has-property-name> ::=
<bad-property-name-diagnosis> | ==> 0
<bad-property-name-diagnosis> | ==> { 0, - }
... ==> 0; Properties::Valued::obtain(W);
<bad-property-name-diagnosis> ::=

View file

@ -1192,10 +1192,10 @@ to parse the list.
=
<verify-expanded-text-substitution> ::=
*** . *** | ==> @<Issue PM_TSWithPunctuation problem@>; return FAIL_NONTERMINAL
, *** | ==> @<Issue PM_EmptySubstitution problem@>; return FAIL_NONTERMINAL
*** , | ==> @<Issue PM_EmptySubstitution problem@>; return FAIL_NONTERMINAL
*** , , *** | ==> @<Issue PM_EmptySubstitution problem@>; return FAIL_NONTERMINAL
*** . *** | ==> @<Issue PM_TSWithPunctuation problem@>; ==> { fail }
, *** | ==> @<Issue PM_EmptySubstitution problem@>; ==> { fail }
*** , | ==> @<Issue PM_EmptySubstitution problem@>; ==> { fail }
*** , , *** | ==> @<Issue PM_EmptySubstitution problem@>; ==> { fail }
...
@ So now just the problem messages:

View file

@ -389,9 +389,9 @@ property of something.
=
<newfound-property-of> ::=
in the presence of ... | ==> 0; return FAIL_NONTERMINAL + Wordings::first_wn(WR[1]) - Wordings::first_wn(W);
... that varies | ==> 0; return FAIL_NONTERMINAL + Wordings::first_wn(WR[1]) - Wordings::first_wn(W);
... variable | ==> 0; return FAIL_NONTERMINAL + Wordings::first_wn(WR[1]) - Wordings::first_wn(W);
in the presence of ... | ==> { advance Wordings::delta(WR[1], W) }
... that varies | ==> { advance Wordings::delta(WR[1], W) }
... variable | ==> { advance Wordings::delta(WR[1], W) }
{<property-name-v>} of ... ==> 0; *XP = RP[1]
@<Act on a newly-discovered property of something@> =

View file

@ -107,7 +107,7 @@ operands.
doing something/anything except <anl-excluded> | ==> FALSE; *XP = RP[1];
doing something/anything to/with <anl-to-tail> | ==> TRUE; *XP = RP[1];
doing something/anything | ==> @<Construct ANL for anything@>
doing something/anything ... | ==> TRUE; *XP = NULL; return FAIL_NONTERMINAL;
doing something/anything ... | ==> { fail }
<anl> ==> TRUE; *XP = RP[1];
<anl-excluded> ::=
@ -115,8 +115,8 @@ operands.
<anl> ==> TRUE; *XP = PL::Actions::Lists::flip_anl_parity(RP[1], FALSE);
<anl-minimal-common-operand> ::=
_,/or ... | ==> FALSE; return FAIL_NONTERMINAL;
... to/with ... | ==> FALSE; return FAIL_NONTERMINAL;
_,/or ... | ==> { fail }
... to/with ... | ==> { fail }
... ==> TRUE;
@<Construct ANL for anything@> =
@ -145,8 +145,8 @@ for instance, we don't want to count the "in" from "fixed in place".
... ==> @<Construct ANL for anything applied@>
<anl-in-tail> ::=
fixed in place *** | ==> FALSE; return FAIL_NONTERMINAL + Wordings::first_wn(WR[1]) - Wordings::first_wn(W);
is/are/was/were/been/listed in *** | ==> FALSE; return FAIL_NONTERMINAL + Wordings::first_wn(WR[1]) - Wordings::first_wn(W);
fixed in place *** | ==> { advance Wordings::delta(WR[1], W) }
is/are/was/were/been/listed in *** | ==> { advance Wordings::delta(WR[1], W) }
in ... ==> TRUE
@<Augment ANL with in clause@> =

View file

@ -811,8 +811,8 @@ here -- a constant, a description, a table entry, a variable, and so on.
=
<action-parameter> ::=
^<if-nonconstant-action-context> <s-local-variable> | ==> TRUE; return FAIL_NONTERMINAL
^<if-nonconstant-action-context> <s-global-variable> | ==> TRUE; return FAIL_NONTERMINAL
^<if-nonconstant-action-context> <s-local-variable> | ==> { fail }
^<if-nonconstant-action-context> <s-global-variable> | ==> { fail }
<s-local-variable> | ==> TRUE; *XP = RP[1]
<s-global-variable> | ==> TRUE; *XP = RP[1]
<s-type-expression-or-value> ==> TRUE; *XP = RP[1]

View file

@ -800,7 +800,7 @@ It's convenient to define a single action clause first:
requiring light ==> LIGHT_ACT_CLAUSE
<action-applications> ::=
nothing | ==> 0
nothing | ==> { 0, - }
one <act-req> and one <act-req> | ==> 2; <<kind:op1>> = RP[1]; <<ac1>> = R[1]; <<kind:op2>> = RP[2]; <<ac2>> = R[2]
one <act-req> and <act-req> | ==> 2; <<kind:op1>> = RP[1]; <<ac1>> = R[1]; <<kind:op2>> = RP[2]; <<ac2>> = R[2]
<act-req> and one <act-req> | ==> 2; <<kind:op1>> = RP[1]; <<ac1>> = R[1]; <<kind:op2>> = RP[2]; <<ac2>> = R[2]
@ -824,7 +824,7 @@ It's convenient to define a single action clause first:
=
<action-sentence-object> ::=
<action-clauses> | ==> 0
<action-clauses> | ==> { 0, - }
... ==> @<Issue PM_ActionClauseUnknown problem@>
<action-clauses> ::=

View file

@ -84,12 +84,12 @@ the Standard Rules or, in the case of "the X understood", by Inform itself.
=
<notable-parsing-variables> ::=
<k-kind> understood | ==> 0; <<kind:understood>> = RP[1]
noun | ==> 1
location | ==> 2
actor-location | ==> 3
second noun | ==> 4
person asked | ==> 5
maximum score ==> 6
noun | ==> { 1, - }
location | ==> { 2, - }
actor-location | ==> { 3, - }
second noun | ==> { 4, - }
person asked | ==> { 5, - }
maximum score ==> { 6, - }
@ =
int PL::Parsing::Visibility::parsing_new_variable_notify(nonlocal_variable *var) {

View file

@ -351,7 +351,7 @@ Here the grammar is very simple, and the object can't be a list.
=
<understand-command-sentence-object> ::=
... when/while ... | ==> @<Issue PM_UnderstandCommandWhen problem@>
something new | ==> 0
something new | ==> { 0, - }
<quoted-text> | ==> Wordings::first_wn(W)
... ==> @<Issue PM_NotOldCommand problem@>

View file

@ -59,8 +59,8 @@ matches successfully and sets the level to 2 and the name to the word range
=
<extension-documentation-heading> ::=
chapter : ... | ==> 1
section : ... ==> 2
chapter : ... | ==> { 1, - }
section : ... ==> { 2, - }
@ =
int DocumentationRenderer::extension_documentation_heading(wording W, int *level, wording *HW) {
@ -92,13 +92,13 @@ text of three asterisks in a row.
=
<extension-example-header> ::=
example : <row-of-asterisks> ... - ... | ==> R[1]
example : ... - ... ==> 0
example : ... - ... ==> { 0, - }
<row-of-asterisks> ::=
* | ==> 1
** | ==> 2
\*** | ==> 3
**** ==> 4
* | ==> { 1, - }
** | ==> { 2, - }
\*** | ==> { 3, - }
**** ==> { 4, - }
@ =
int DocumentationRenderer::extension_documentation_example(wording W,

View file

@ -10,16 +10,16 @@ match any text.
=
<dividing-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
... ==> { fail }
<structural-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
... ==> { fail }
<language-modifying-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
... ==> { fail }
<comma-divisible-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
... ==> { fail }
@h Loading from a file.
The following function reads a file whose name is in |arg|, feeds it into

View file

@ -13,17 +13,17 @@ any text but then fail.
=
<dividing-sentence> ::=
chapter ... | ==> 1
section ... ==> 2
chapter ... | ==> { 1, - }
section ... ==> { 2, - }
<structural-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
... ==> { fail }
<language-modifying-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
... ==> { fail }
<comma-divisible-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
... ==> { fail }
@ =
<scan-individual-phrase> ::=

View file

@ -8,17 +8,17 @@ any text but then fail.
=
<dividing-sentence> ::=
chapter ... | ==> 1
section ... ==> 2
chapter ... | ==> { 1, - }
section ... ==> { 2, - }
<structural-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
... ==> { fail }
<language-modifying-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
... ==> { fail }
<comma-divisible-sentence> ::=
... ==> TRUE; return FAIL_NONTERMINAL;
... ==> { fail }
@h Syntax tree.

View file

@ -94,7 +94,7 @@ three" with result 5.
Or consider the following refinement of <competitor>:
= (text as Preform)
<competitor> ::=
the pacemaker | ==> 1
the pacemaker | ==> { 1, - }
<ordinal-number> runner | ==> R[1]
runner no <cardinal-number> ==> R[1]
=
@ -125,7 +125,7 @@ Another convenient notation is the caret |^|, which negates the effect of
a token. For example,
= (text as Preform)
<competitor> ::=
the ^adjudicator ==> 1
the ^adjudicator ==> { 1, - }
=
matches "the pacemaker", "the cyclist", etc. -- the anything at all, but not
"the adjudicator".
@ -196,7 +196,7 @@ definition are normally given the internal numbers 0, 1, 2, 3... in the
order in which they appear. For example, in
= (text as Preform)
<competitor> ::=
the pacemaker | ==> 1
the pacemaker | ==> { 1, - }
<ordinal-number> runner | ==> R[1]
runner no <cardinal-number> ==> R[1]
=
@ -205,17 +205,17 @@ and so on. Those "match numbers" have little outward significance, but help
to determine the result when a successful match is made. Consider:
= (text as Preform)
<letter-score> ::=
alpha | ==> 10
beta | ==> 20
gamma ==> 30
alpha | ==> { 10, - }
beta | ==> { 20, - }
gamma ==> { 30, - }
=
Here, matching against "beta" produces 20 -- the result on the same row. But
we can mess with that:
= (text as Preform)
<letter-score> ::=
/c/ alpha | ==> 10
/a/ beta | ==> 20
/b/ gamma ==> 30
/c/ alpha | ==> { 10, - }
/a/ beta | ==> { 20, - }
/b/ gamma ==> { 30, - }
=
The special notation |/X/|, where |X| is a lower-case letter, marks the row
as having a different number from the obvious one. |/a/| means 0, |/b/| means
@ -223,9 +223,9 @@ as having a different number from the obvious one. |/a/| means 0, |/b/| means
of this:
= (text as Preform)
<letter-score> ::=
beta | ==> 10
gamma | ==> 20
alpha ==> 30
beta | ==> { 10, - }
gamma | ==> { 20, - }
alpha ==> { 30, - }
=
That might seem a stupidly obfuscatory thing to do, and indeed it is, when
done in the main Inform source code -- which is why we never do it. But

View file

@ -41,7 +41,7 @@ it; the name of which is the nonterminal's name with a |C| suffix. For example,
suppose //inweb// sees the following in the web it is tangling:
= (text as Preform)
<competitor> ::=
the pacemaker | ==> 1
the pacemaker | ==> { 1, - }
<ordinal-number> runner | ==> R[1]
runner no <cardinal-number> ==> R[1]
=