I6 Template Layer

Inform 7 6M62ContentsIntroductionFunction IndexRules Index

Main.i6t

Main contents

Startup.

This segment of the template is not like any other. It contains almost the complete logical sequence of operations followed by NI – indeed, NI essentially works by parsing some command-line arguments to set switches and then asking the template interpreter to run through Main.i6t, the only template file which must always exist. (The other template files are only ever involved when called on by the {-segment:...} command from a template file already running.) Whereas most template segments contain I6 code to pass through into NI's output, this one runs both before and after NI's output file is being written, and contains only commands.

The Startup paragraph is not in fact modifiable in any easy way, because of course "Include..." sentences – used to tell the template interpreter to override the template files – will not be understood until long after this paragraph has been fully dealt with. But perhaps that's no bad thing.

26{-callv:Lexer::start} 27{-callv:Preform::read_definition} 28{-callv:Plugins::Manage::start} 29{-callv:InferenceSubjects::begin} 30 31{-callv:Extensions::Files::handle_census_mode} 32 33 34{-progress-stage:0} 35{-log-phase:Lexical analysis} 36{-callv:SourceFiles::read_primary_source_text} 37{-callv:Sentences::RuleSubtrees::create_standard_csps}

Semantic Analysis.

Similarly: Include... sentences are not read until this paragraph is long forgotten.

44{-progress-stage:1} 45{-log-phase:Semantic analysis Ia} 46{-callv:ParseTree::plant_parse_tree} ! Initialise the parse tree 47{-callv:Sentences::break_source} ! Build first tranche of sentences 48{-callv:Extensions::Inclusion::traverse} ! Expand extension inclusions and build sentences 49{-callv:Sentences::Headings::satisfy_dependencies} 50 51{-log-phase:Initialise language semantics} 52{-plugin:load} 53{-callv:BinaryPredicates::make_built_in} 54{-callv:Verbs::stock} 55{-callv:Quantifiers::make_built_in} 56 57{-log-phase:Semantic analysis Ib} 58{-callv:Sentences::VPs::traverse} ! Find verbs in the assertion sentences 59{-callv:Plurals::traverse_for_definitions} ! Build irregular plurals dictionary 60{-callv:Sentences::Rearrangement::tidy_up_ofs_and_froms} ! More "of" wrangling 61{-callv:Sentences::RuleSubtrees::register_recently_lexed_phrases} ! To make commands children of their routines 62{-callv:Sentences::declare_source_loaded} 63{-callv:Kinds::Interpreter::include_templates_for_kinds} 64 65{-log-phase:Semantic analysis II} 66{-callv:ParseTree::verify} ! Purely to check that NI is running correctly 67{-callv:Extensions::Files::check_versions} ! Do the extension version numbers meet needs? 68{-callv:Sentences::Headings::make_tree} ! Stratify headings and subheadings 69{-callv:Sentences::Headings::write_as_xml} ! Dump them to a file for the GUI to use 70 71{-log-phase:Semantic analysis III} 72{-callv:Phrases::Adjectives::traverse} 73{-callv:Equations::traverse_to_create} 74{-callv:Tables::traverse_to_create} 75{-callv:Phrases::Manager::traverse_for_names}

Assertion Reading.

Since Include... sentences are read during pass 2, they might just be able to meddle by adding instructions to take place after this paragraph, but would be too late to work before or instead of it.

83{-progress-stage:2} 84{-log-phase:First pass through assertions} 85{-read-assertions:1} 86{-callv:Tables::traverse_to_stock} 87{-log-phase:Second pass through assertions} 88{-read-assertions:2}

Model Construction.

93{-log-phase:Making the model world} 94{-callv:Properties::ObjectImplementation::allocate_attributes} 95{-callv:PL::Actions::name_all} 96{-callv:Nametags::name_all} 97{-callv:World::complete} 98{-callv:Properties::Measurement::validate_definitions} 99{-callv:BinaryPredicates::make_built_in_further}

Tables and Grammar.

104{-log-phase:Tables and grammar} 105{-callv:Tables::check_tables_for_kind_clashes} 106{-callv:PL::Parsing::traverse} 107{-callv:World::complete_additions}

Phrases and Rules.

112{-progress-stage:3} 113{-log-phase:Phrases and rules} 114{-callv:LiteralPatterns::define_named_phrases} 115{-callv:Phrases::Manager::traverse} 116{-callv:Phrases::Manager::register_meanings} 117{-callv:Phrases::Manager::parse_rule_parameters} 118{-callv:Phrases::Manager::add_rules_to_rulebooks} 119{-callv:Phrases::Manager::parse_rule_placements} 120{-callv:Equations::traverse_to_stock} 121{-callv:Tables::traverse_to_stock}

Code Generation.

This is where we hand over to regular template files – containing code passed through as I6 source, as well as a few further commands – starting with Output.i6t.

129{-progress-stage:4} 130{-log-phase:Code generation} 131{-open-file}{-segment:Output.i6t}{-close-file} 132{-log-phase:Compilation now complete}

Metadata.

137{-callv:PL::Bibliographic::Release::write_ifiction_and_blurb}

Indexing.

This paragraph can be skipped without harming any of the rest of NI's work: the only effect is to suppress the generation of the index. (Indeed, if NI is called with the -noindex command-line switch, then the template interpreter ignores all commands in between {-open-index} and {-close-index}, thus skipping exactly this paragraph.)

147{-open-index} 148 149{-index-page:cf0a38=Contents Index=Like the preliminary pages of a book} 150{-index-element:C Contents=Like the contents page of a book.|About headings<HEADINGS>; About extensions<EXTENSIONS>} 151{-index-element:Cd Card=How this project might be filed in a library catalogue.|About the Library Card<LCARDS>; About IFIDs<IFIDS>} 152{-index-element:Tb Tables=Tables of information in the source text.|About tables<TABLES>} 153{-index-element:Fi Figures=The figures, sound effects or external files used.|About figures<FIGURES>; About sounds<SOUNDS>; About files<EFILES>} 154{-index-element:In Innards=Technicalities about the story file being produced.|About the story file<STORYFILES>; About use options<OPTIONS>} 155 156{-index-page:ea5b1f=Actions Index=Things that people can try to do} 157{-index-element:A1 Grouped=With similar actions grouped together|About actions<ACTIONS>; New actions<NEWACTIONS>; Out of world actions (in red)<OUTOFWORLD>} 158{-index-element:A2 Alphabetic=Listed in alphabetical order|About actions<ACTIONS>; New actions<NEWACTIONS>; Out of world actions (in red)<OUTOFWORLD>} 159{-index-element:Bh Behaviour=Kinds of action, grouped under common names|About kinds of action<KACTIONS>} 160{-index-element:Cm Commands=Commands which the player can type|About commands<UNDERSTANDING>} 161{-index-element:To Tokens=Those square-bracketed pieces inside Understand grammar|About tokens<TOKENS>; New tokens<NEWTOKENS>} 162 163{-index-page:e9cf08=Kinds Index=All the different sorts of value} 164{-index-element:Ch Chart=A chart of all the kinds|About kinds<KINDS>; New kinds of object<NEWKINDS>; Other new kinds<KINDSVALUE>} 165{-index-element:Ar Arithmetic=Which values can be added up, multiplied and so on|About arithmetic<ARITHMETIC>} 166{-index-element:Vl Values=Values which vary during play, and equations.|About variables<VARIABLES>} 167 168{-index-page:52992f=Phrasebook Index=A short dictionary} 169{-index-element:Ph Phrases=A guide to the phrases allowed|About phrases<PHRASES>} 170{-index-element:Lx Lexicon=Words used in descriptions|About descriptions<DESCRIPTIONS>} 171{-index-element:Rl Relations=Relations give meaning to verbs|About relations<RELATIONS>} 172{-index-element:Vb Verbs=A table of verbs|About verbs<VERBS>} 173 174{-index-page:1d31b4=Rules Index=Inform's general workings} 175{-index-element:St Standards=From the Standard Rules|About rulebooks<RULEBOOKS>; About activities<ACTIVITIES>; Moving or abolishing rules<RLISTING>} 176{-index-element:Xt Extras=Further rulebooks, from the source or extensions|About rulebooks<RULEBOOKS>; About activities<ACTIVITIES>; Moving or abolishing rules<RLISTING>} 177 178{-index-page:001860=Scenes Index=Like scenes in a movie} 179{-index-element:Pl Plot=A map of how the scenes begin and end|About scenes<SCENESINTRO>; How they link together<LINKINGSCENES>} 180{-index-element:Ev Events=Timed events, if any|About timed events<TIMEDEVENTS>} 181{-index-element:RS Rules=General rules about scenes} 182 183{-index-page:8b58bf=World Index=Like locations, props and actors in a movie} 184{-index-element:Mp Map=A map of the world} 185{-index-element:Gz Gazetteer=An A-Z of places, things, people and so on} 186 187{-index-page:111111=Welcome Index=This text is not actually used} 188{-index-element:Bg Bogus=Does not in fact exist} 189 190{-index:Contents Index=How the source text is organised} 191{-index:Actions Index=Things that people can try to do} 192{-index:Kinds Index=All the different sorts of value} 193{-index:Phrasebook Index=A short dictionary} 194{-index:Rules Index=And the rulebooks they belong to} 195{-index:Scenes Index=Like scenes in a movie} 196{-index:World Index=Like locations, props and actors in a movie} 197{-index:Welcome Index=Navigation only} 198 199{-index-page:cf0a38=Action Details=This text is not actually used} 200{-index-element:Bg Bogus=Does not in fact exist} 201 202{-callv:Index::complete} 203{-close-index}

Shutdown.

Making any final reports to the debugging log, and that's then it.

209{-callv:TemplateFiles::report_unacted_upon_interventions} 210 211{ -callv:ParseTree::write_main_source_to_log} 212{ -callv:Memory::log_statistics} 213{ -callv:Preform::log_language} 214{ -callv:Index::DocReferences::log_statistics} 215{ -callv:Parser::SParser::debug_parser_statistics} 216{ -callv:Verbs::log_all}