§1.4. Information Only

One last preliminary: a handful of the examples do not show how to do anything at all, but are really sidebars of information. Those examples are gathered below, since they contribute nothing by way of recipes.


arrow-up.pngStart of Chapter 1: How to Use The Recipe Book
arrow-left.pngBack to §1.3. Disenchantment Bay
arrow-right.pngOnward to Chapter 2: Adaptive Prose: §2.1. Varying What Is Written

*ExampleAbout Inform's regular expression support
Some footnotes on Inform's regular expressions, and how they compare to those of other programming languages.

***ExampleFormal syntax of sentences
A more formal description of the sentence grammar used by Inform for both assertions and conditions.

***ExampleMathematical view of relations
Some notes on relations from a mathematical point of view, provided only to clarify some technicalities for those who are interested.

***ExampleGraph-theory view of relations
Some notes on relations from the point of view of graph theory.

Backus-Naur form, or BNF, is a standard notation used by computer scientists to specify more or less precisely what the valid programs are for a given programming language. It tends to provide a good description for a language such as C or Pascal, where contextual rules are limited, but the authors of Inform are doubtful that it is such a good tool for a natural-language system. For those who are interested, though, the following gives a formal specification for Inform's rules.

<rule> ::=
    Definition : A/an <kind> is <new adjectival name> if/unless <definition>
    | <preamble> : <phrases>
    | <preamble> , <phrase> (* only allowed for a few cases: see below)

<definition> ::=
    <condition>
    | its/his/her/their <value property name> is/are <value> or less/more
    | : <phrases>

<preamble> ::=
    To <phrase template>
    | To decide if/whether <phrase template>
    | To decide which/what <kind of value> is <phrase template>
    | This is the <rule name>
    | [[A] Rule for] <circumstances> [(this is the <rule name>)]

<circumstances> ::=
    At <time>
    | When <event name>
    | [<placement>] <rulebook reference> [while/when <condition>] [during <scene name>]

<rulebook reference> ::=
    <rulebook name> [about/for/of/on/rule] [<action pattern>]
    | <object-based-rulebook name> [about/for/of/on/rule] [<description>]

<placement> ::=
    a/an
    | [the] first
    | [the] last

<phrases> ::=
    <phrase>
    | <phrases> ; <phrase>

The following examples show how Inform breaks down some typical rules using the system above:

<rule> = At 2:09 PM: increase the score by 2; say "Progress!"
    <preamble> = At 2:09 PM
        <circumstances> = At 2:09 PM
            At
            <time> = 2:09 PM
    :
    <phrases> = increase the score by 2; say "Progress!"
        <phrase> = increase the score by 2
        ;
        <phrase> = say "Progress"

<rule> = Instead of eating the ostrich during Formal Dinner (this is the cuisine rule), say "It's greasy!"
    <preamble> = Instead of eating the ostrich during Formal Dinner (this is the cuisine rule)
        <circumstances> = Instead of eating the ostrich during Formal Dinner
            <rulebook reference> = Instead of eating the ostrich
                <rulebook name> = Instead
                of
                <action pattern> = eating the ostrich
            during
            <scene name> = Formal Dinner
        (
        this
        is
        the
        <rule name> = cuisine rule
        )
    ,
    <phrases> = say "It's greasy!"
        <phrase> = say "It's greasy!"

<rule> = After printing the name of a container: say "!"
    <preamble> = After printing the name of a container
        <circumstances> = After printing the name of a container
            <rulebook reference> = After printing the name of a container
                <object-based-rulebook name> = After printing the name
                of
                <description> = a container
    :
    <phrases> = say "!"
        <phrase> = say "!"

(*) The colon dividing a rule preamble from its definition can be replaced by a comma only if the preamble begins with the words "Instead of", "Before", "After", "Every turn" or "When", and if the definition consists only of a single phrase.

***ExampleBackus-Naur form for rules
The full grammar Inform uses to parse rule definitions, in a standard computer-science notation.

Backus-Naur form, or BNF, is a standard notation used by computer scientists to specify more or less precisely what the valid programs are for a given programming language. It tends to provide a good description for a language such as C or Pascal, where contextual rules are limited, but the authors of Inform are doubtful that it is such a good tool for a natural-language system. For those who are interested, though, the following gives a formal specification for Inform's rules.

<rule> ::=
    Definition : A/an <kind> is <new adjectival name> if/unless <definition>
    | <preamble> : <phrases>
    | <preamble> , <phrase> (* only allowed for a few cases: see below)

<definition> ::=
    <condition>
    | its/his/her/their <value property name> is/are <value> or less/more
    | : <phrases>

<preamble> ::=
    To <phrase template>
    | To decide if/whether <phrase template>
    | To decide which/what <kind of value> is <phrase template>
    | This is the <rule name>
    | [[A] Rule for] <circumstances> [(this is the <rule name>)]

<circumstances> ::=
    At <time>
    | When <event name>
    | [<placement>] <rulebook reference> [while/when <condition>] [during <scene name>]

<rulebook reference> ::=
    <rulebook name> [about/for/of/on/rule] [<action pattern>]
    | <object-based-rulebook name> [about/for/of/on/rule] [<description>]

<placement> ::=
    a/an
    | [the] first
    | [the] last

<phrases> ::=
    <phrase>
    | <phrases> ; <phrase>

The following examples show how Inform breaks down some typical rules using the system above:

<rule> = At 2:09 PM: increase the score by 2; say "Progress!"
    <preamble> = At 2:09 PM
        <circumstances> = At 2:09 PM
            At
            <time> = 2:09 PM
    :
    <phrases> = increase the score by 2; say "Progress!"
        <phrase> = increase the score by 2
        ;
        <phrase> = say "Progress"

<rule> = Instead of eating the ostrich during Formal Dinner (this is the cuisine rule), say "It's greasy!"
    <preamble> = Instead of eating the ostrich during Formal Dinner (this is the cuisine rule)
        <circumstances> = Instead of eating the ostrich during Formal Dinner
            <rulebook reference> = Instead of eating the ostrich
                <rulebook name> = Instead
                of
                <action pattern> = eating the ostrich
            during
            <scene name> = Formal Dinner
        (
        this
        is
        the
        <rule name> = cuisine rule
        )
    ,
    <phrases> = say "It's greasy!"
        <phrase> = say "It's greasy!"

<rule> = After printing the name of a container: say "!"
    <preamble> = After printing the name of a container
        <circumstances> = After printing the name of a container
            <rulebook reference> = After printing the name of a container
                <object-based-rulebook name> = After printing the name
                of
                <description> = a container
    :
    <phrases> = say "!"
        <phrase> = say "!"

(*) The colon dividing a rule preamble from its definition can be replaced by a comma only if the preamble begins with the words "Instead of", "Before", "After", "Every turn" or "When", and if the definition consists only of a single phrase.