§1. The core Inform compiler combines natural-language source text, including natural-language extensions, and precompiled "kits" in order to make the instructions for making a playable story. Inform is internally divided into Stages, numbered 1 to 7. (These slightly overlap in chronological order, but they do mostly happen in sequence.)
(1) Build management: gathering up what must be compiled and reading it in as an annotated syntax tree, or "AST". (AST normally stands for "abstract syntax tree" but we prefer "annotated", skirting the issue of exactly how abstract vs concrete it is.)
(2) Queueing and organising work which will be done by stages 3 to 5.
(3) Turning assertion sentences -- "Peter is a man", "The tally is a number that varies" -- into a world model of variables, kinds, instances and properties. Values and typechecking are also managed here. Phrases and rules are identified, but their bodies are ignored for the moment.
(4) The world model, phrases and rules identified by stage (3) are now compiled to an Intermediate Representation, or "IR", another sort of tree known as Inter. This is done by calling down to the API provided by...
(5) ... which is more a layer than a stage: it's a comprehensive system for building Inter code, and could conceivably be used by other compilers too.
(6) A "pipeline" of transformations on the Inter code improves it. A weak form of linker joins on precompiled Inter code from "kits" such as BasicInformKit or WorldModelKit.
(7) The finished Inter tree is then code-generated to form our output, which
can be in several different formats, and an Index mini-website about it is made.
For most users of the Inform app, the format will be Inform 6, and further
command-line tools inform6 and inblorb then turn that into a "story
file" and then a Javascript-running web page; but for some command-line users,
the format is C and a compiler like clang is then used to make an executable.
§2. These seven stages form a single code base but are packaged up into three command-line tools, not one:
inbuildis Stage 1 as a stand-alone tool: see this description.inform7is Stages 1 to 7 as an all-in-one: see this description of the part unique to it, Stages 2 to 4.interis Stages 5 to 7 as a stand-alone tool: see this description.
All three tools also use a large library of services: everything from inflecting words to simplifying logical propositions.
kit sources (in Inform 6 code) | | INTER \|/ precompiled Inter trees . main source text extension source texts . \ / . \ / INFORM7 Stage 1 or INBUILD . \ / . \|/ \|/ . syntax tree . | . | INFORM7 Stages 2 to 4/5 . | . . . . . . . precompiled \|/ Inter trees Inter tree \ / \ / INFORM7 Stage 6 or INTER \|/ \|/ single linked Inter tree / | \ / | \ INFORM7 Stage 7 or INTER \|/ \|/ \|/ Inform 6 code C code index mini-website : : INFORM6 : : CLANG or GCC \:/ \:/ story file executable : INBLORB : \:/ playable website
§4. The code base is subdivided into "modules". There are around 30, from five sources:
- A set of services, which are libraries of code providing features useful to programs dealing with natural language.
- Those owned by Inbuild.
- Those owned by Inform7.
- Those owned by Inter.
- The foundation library for memory-management, string handling and so on, which is a module held in the inweb repository rather than here.
§5. The full breakdown of the three compiler tools into modules is as follows.
An o means that the tool is the owner of the module in question; a x means
that it imports the module from somewhere else.
WEB ACTIVE STAGES INWEB SERVICES INBUILD INFORM7 INTER
The executables otherwise contain only a few POSIX or Windows-related functions for file and directory handling, and functions from the standard C library. There are, therefore, no external dependencies.