1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 08:34:22 +03:00
inform7/docs/compiler.html

601 lines
20 KiB
HTML
Raw Normal View History

2020-03-19 02:11:25 +02:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
2020-03-23 23:42:00 +02:00
<title>The Inform 7 compiler</title>
2020-03-19 02:11:25 +02:00
<meta name="viewport" content="width=device-width initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-gb">
<link href="inweb.css" rel="stylesheet" rev="stylesheet" type="text/css"><style type="text/css">
/* This is a CSS file for pages woven by the literate programming tool inweb */
/* We'll start with syntax colouring, since everyone likes to toy with this: */
.cwebmacrotext { color: #000000; font-weight: bold; } /* The name of a web macro */
.functiontext { color: #C00000; } /* When a C function is being defined */
.string { color: #408040; } /* A double-quoted C literal string */
.character { color: #204020; } /* A single-quoted C literal character */
.constant { color: #204020; } /* A named constant */
.element { color: #40407f; } /* A C structure element */
.identifier { color: #4040ff; } /* An identifier */
.reserved { color: #600000; } /* A reserved word */
/* Comments at the end of lines are rendered like so: */
.comment {
font: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
color: #404040;
font-style:italic;
}
/* The name of a web macro when being used: */
.cwebmacro {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
text-decoration: none;
color: #000000; font-weight: bold;
}
.cwebmacronumber {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
font-size: 80%;
text-decoration: none;
color: #000000;
}
/* And when being defined: */
.cwebmacrodefn {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
text-decoration: none;
color: #000000; font-weight: bold;
font-weight:bold;
}
/* Now some generalities: */
body {
background-color: #ffffff;
margin: 8px;
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
font-size: 16px;
line-height: 24px;
background-color: transparent;
-webkit-font-smoothing: antialiased;
}
/* Forms of paragraph: */
p {
margin: 0;
padding-top: 5px;
padding-bottom: 5px;
clear: both;
}
/* Where an inweb paragraph begins: */
p.inwebparagraph {
width: 60em;
line-height: 150%;
padding-top: 15px;
padding-bottom: 5px;
}
/* If a web macro definition begins in its own paragraph, this is it: */
p.macrodefinition {
padding-top: 0px;
padding-bottom: 0px;
margin-left: 30px;
}
/* The endnotes at the foot of code: "The function foo_bar is used in ..." */
p.endnote {
font-size: 0.8em;
padding-top: 0px;
padding-bottom: 0px;
margin-left: 30px;
text-decoration:none;
color: #000000;
}
/* The Purpose slug: */
p.purpose {
width: 60em;
line-height: 150%;
font-size: 1em;
font-style:italic;
margin-left: 15px;
}
/* Blocks of code appear in these */
pre {
font-family: Monaco, monospace;
}
pre.display {
padding: 3px;
margin-top: 5px;
margin-bottom: 5px;
margin-left: 30px;
margin-right: 10px;
background: #f8f8f8;
border-width: 1px;
border-style: solid solid solid solid;
border-color: #ccc;
word-wrap: break-word;
white-space: pre-wrap;
}
pre.displaydefn {
padding: 3px;
margin-top: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 10px;
background: #f8f8f8;
border-width: 1px;
border-style: solid solid solid solid;
border-color: #ccc;
word-wrap: break-word;
white-space: pre-wrap;
}
pre.definitions {
padding-top: 0px;
margin-top: 0px;
margin-left: 0px;
margin-right: 10px;
word-wrap: break-word;
white-space: pre-wrap;
}
/* The following are for breadcrumbs of links: */
ul, li {
list-style-type:none;
padding:0;
margin:0;
}
.crumbs {
border:1px solid #dedede;
height:3.45em;
}
.crumbs li {
float:left;
line-height:2.3em;
padding-left:.75em;
color:#333;
font-size: 1.5em;
}
.crumbs li a {
display:block;
padding:0 15px 0 0;
background:url(crumbs.gif) no-repeat right center;
}
.crumbs li a:link, #crumbs li a:visited {
text-decoration:none;
color:#333;
}
.crumbs li a:hover, #crumbs li a:focus {
color:#dd2c0d;
}
/* This is for items in lists from inweb source: */
ul.items {
margin-top: 3px;
margin-bottom: 3px;
}
ul.items li {
margin-top: 1px;
margin-bottom: 1px;
margin-left: 15px;
}
/* And this is for each section's table of contents: */
ul.toc {
margin-top: 3px;
margin-bottom: 3px;
}
ul.toc li {
float:left;
margin-left: 15px;
color:#000;
}
ul.toc li a {
display:block;
}
ul.toc li a:link, ul.toc li a:visited {
text-decoration:none;
color:#000;
}
ul.toc li a:hover, ul.toc li a:focus {
color:#dd2c0d;
}
hr.tocbar {
clear: both;
margin-top:3px;
margin-bottom:3px;
color:#333;
border:0
background-color:#333;
}
/* This is for cross-reference links ("This code is used in ...") */
p.endnote:link, p.endnote:visited, p.endnote:hover, p.endnote:focus {
text-decoration:none;
color:#000;
}
p.endnote a:link, p.endnote a:visited {
text-decoration:none;
color:#000;
}
p.endnote a:hover, p.endnote a:focus {
text-decoration:none;
color:#dd2c0d;
}
/* Now for the index page */
p.heading {
margin-top: 2px;
margin-bottom: 2px;
font-size: 20
}
p.chapter {
font-size: 14
}
p.tight {
font-size: 12
}
p.tightin {
padding-left: 25px;
font-size: 12
}
.chapterlist li {
padding-top: 8px;
padding-left: 16px;
}
.chaptertitle {
font-weight: bold;
}
.chapterlist .sectionlist li {
padding-left: 48px;
}
span.definitionkeyword {
color:#801010;
font-weight:bold;
}
span.extract {
font-size: 15px;
border: 1px solid #e8e8e8;
border-radius: 3px;
background-color: #eef;
width: 100%;
padding: 3px;
}
nav[role="navigation"] {
width: 180px;
position: fixed;
overflow: scroll;
left: 0;
top: 0;
bottom: 0;
background: #FAFAFA;
border-right: 1px solid #e6e6e6;
padding: 20px 30px
}
nav[role="navigation"] ul {
border-top: 1px solid #e6e6e6;
font-weight: 400;
margin-bottom: 30px;
list-style: none
}
nav[role="navigation"] ul ul {
list-style: none
}
nav[role="navigation"] ul li {
border-bottom: 1px solid #e6e6e6
}
nav[role="navigation"] ul li.active {
border-bottom: 1px solid #333
}
nav[role="navigation"] ul li.active a {
font-weight: 700
}
nav[role="navigation"] h1 a:link {
color: #333;
text-decoration: none;
display: block;
}
nav[role="navigation"] h1 a:visited {
color: #333
}
nav[role="navigation"] h1 a:active {
font-weight: 700
}
nav[role="navigation"] h1 a:hover {
color: #dd2c0d
}
nav[role="navigation"] ul li a:link {
color: #333;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 1px;
font-size: 12px;
display: block;
padding: 10px 10px 2px 2px
}
nav[role="navigation"] ul li a:visited {
color: #333
}
nav[role="navigation"] ul li a:active {
font-weight: 700
}
nav[role="navigation"] ul li a:hover {
color: #dd2c0d
}
nav[role="navigation"] ul li ul {
margin-bottom: 10px;
border-top: none
}
nav[role="navigation"] ul li ul li {
border-bottom: none;
padding: 0.1em
}
nav[role="navigation"] ul li ul li.active {
border-bottom: none
}
nav[role="navigation"] ul li ul li.active a {
font-weight: 700
}
nav[role="navigation"] ul li ul a:link {
color: #dd2c0d;
text-decoration: none;
text-transform: none;
letter-spacing: 0;
font-size: 12px;
display: block;
margin-left: 15px;
padding: 0 0 3px;
border-bottom: none;
font-weight: 300
}
nav[role="navigation"] ul li ul a:hover {
text-decoration: underline
}
nav[role="navigation"] h2 {
font-size: 0.95em;
text-transform: lowercase;
font-variant: small-caps;
color: #999;
padding-bottom: 0.5em
}
nav[role="navigation"] h1 {
margin-top: 0em
}
main {
max-width: 1024px;
min-width: 320px;
margin-left: 250px;
min-height: 100%;
height: auto !important;
height: 100%
}
#logo {
text-indent: -9999px;
height: 48px;
width: 100%;
margin-top: 20px;
margin-bottom: 0.5em;
padding-bottom: 10px
}
#logo a {
display: block;
width: 190px;
height: 48px;
background-image: url("/assets/images/swift.svg");
background-repeat: no-repeat;
background-size: 190px 48px;
background-position-x: -8px
}
</style>
</head>
<body>
<nav role="navigation">
<h1><a href="webs.html">Sources</a></h1>
<ul>
<li><a href="compiler.html"><b>compiler tools</b></a></li>
2020-03-19 02:11:25 +02:00
<li><a href="other.html">other tools</a></li>
<li><a href="extensions.html">extensions and kits</a></li>
<li><a href="units.html">unit test tools</a></li>
</ul>
<h2>Compiler Webs</h2>
<ul>
<li><a href="inbuild/index.html">inbuild</a></li>
<li><a href="inform7/index.html">inform7</a></li>
<li><a href="inter/index.html">inter</a></li>
</ul>
<h2>Inbuild Modules</h2>
<ul>
<li><a href="inbuild-module/index.html">inbuild</a></li>
<li><a href="arch-module/index.html">arch</a></li>
<li><a href="words-module/index.html">words</a></li>
<li><a href="syntax-module/index.html">syntax</a></li>
<li><a href="html-module/index.html">html</a></li>
</ul>
<h2>Inform7 Modules</h2>
<ul>
<li><a href="core-module/index.html">core</a></li>
<li><a href="problems-module/index.html">problems</a></li>
<li><a href="inflections-module/index.html">inflections</a></li>
<li><a href="linguistics-module/index.html">linguistics</a></li>
<li><a href="kinds-module/index.html">kinds</a></li>
<li><a href="if-module/index.html">if</a></li>
<li><a href="multimedia-module/index.html">multimedia</a></li>
<li><a href="index-module/index.html">index</a></li>
</ul>
<h2>Inter Modules</h2>
<ul>
<li><a href="inter-module/index.html">inter</a></li>
<li><a href="building-module/index.html">building</a></li>
<li><a href="codegen-module/index.html">codegen</a></li>
</ul>
<h2>Foundation</h2>
<ul>
<li><a href="../../inweb/docs/foundation-module/index.html">foundation</a></li>
</ul>
</nav>
<main role="main">
<!--Weave of 'Complete Program' generated by 7-->
<ul class="crumbs"><li><b>The Inform 7 compiler</b></li></ul><p class="inwebparagraph"><a id="SP1"></a><b>&#167;1. </b>The task of the Inform 7 compiler is to take source text which may be as
2020-04-08 01:02:44 +03:00
minimal as "The Taj Mahal is a room.", and to turn it into a computer program.
It is properly speaking a "transpiler", in that it compiles down to code for
another compiler to take the rest of the way. Traditionally, that other
compiler is Inform 6 (1996-2003), a reliable generator of "story files"
(programs for virtual machines) from typeless but otherwise C-like code.
</p>
<p class="inwebparagraph">The Inform 7 compiler works in three phases:
2020-03-19 02:11:25 +02:00
</p>
<ul class="items"><li>(1) A build manager reads in the text, breaks it into sentences, finds the
necessary extensions, merges them in, and generally decides what to do.
</li><li>(2) The core of the compiler translates this assemblage of source text into
a low-level abstract language called "inter".
</li><li>(3) The code-generator further translates that intermediate code into our
2020-04-08 01:02:44 +03:00
final output, which will be code for some lower-level compiler.
2020-03-19 02:11:25 +02:00
</li></ul>
<p class="inwebparagraph"><a id="SP2"></a><b>&#167;2. </b>Three ccmmand-line tools are provided: <code class="display"><span class="extract">inbuild</span></code>, <code class="display"><span class="extract">inform7</span></code>, and <code class="display"><span class="extract">inter</span></code>.
2020-04-08 01:02:44 +03:00
They roughly correspond to the three phases, but <code class="display"><span class="extract">inbuild</span></code> can also
perform some useful archiving and resource management functions, and <code class="display"><span class="extract">inter</span></code>
can also perform assimilation on kits, or translate inter code not originated by
Inform. <code class="display"><span class="extract">inform7</span></code> on its own is capable of performing the complete compilation
process and is the only one of the three included in the GUI apps of Inform
for MacOS, Windows and so on.
2020-03-19 02:11:25 +02:00
</p>
2020-04-08 01:02:44 +03:00
<p class="inwebparagraph">Each tool has a tiny CLI (or "command-line interface") but is otherwise
divided up into large segments called "modules", many shared between two or
even all three tools. <code class="display"><span class="extract">inform7</span></code> contains every module. The following diagram
shows exactly how:
2020-03-19 02:11:25 +02:00
</p>
2020-04-08 01:02:44 +03:00
<pre class="display">
<span class="plain">+-------------+ +-------------+ +-------------+</span>
<span class="plain">| </span><span class="functiontext">INBUILD</span><span class="plain"> | | </span><span class="functiontext">INFORM7</span><span class="plain"> | | </span><span class="functiontext">INTER</span><span class="plain"> |</span>
<span class="plain">| | | | | |</span>
<span class="plain">+---+.............+---+ +---+.............+---+ +---+.............+---+</span>
<span class="plain">| </span><span class="element">inbuild</span><span class="plain"> (</span><span class="element">cli</span><span class="plain"> </span><span class="element">shell</span><span class="plain">) | | </span><span class="element">inform7</span><span class="plain"> (</span><span class="element">cli</span><span class="plain"> </span><span class="element">shell</span><span class="plain">) | | </span><span class="element">inter</span><span class="plain"> (</span><span class="element">cli</span><span class="plain"> </span><span class="element">shell</span><span class="plain">) |</span>
<span class="plain">+---+.............+---+ +---+.............+---+ +---+.............+---+</span>
<span class="plain">| | | | | |</span>
<span class="plain">+---+.............+----------+.............+---+ | |</span>
<span class="plain">| </span><span class="reserved">inbuild-module</span><span class="plain"> | | |</span>
<span class="plain">| </span><span class="reserved">syntax-module</span><span class="plain"> | | |</span>
<span class="plain">| </span><span class="reserved">html-module</span><span class="plain"> | | |</span>
<span class="plain">+---+.............+----------+.............+---+ | |</span>
<span class="plain">| | | | | |</span>
<span class="plain">| | +---+.............+---+ | |</span>
<span class="plain">| | | </span><span class="reserved">core-module</span><span class="plain"> | | |</span>
<span class="plain">| | | </span><span class="reserved">inflections-module</span><span class="plain"> | | |</span>
<span class="plain">| | | </span><span class="reserved">linguistics-module</span><span class="plain"> | | |</span>
<span class="plain">| | | </span><span class="reserved">problems-module</span><span class="plain"> | | |</span>
<span class="plain">| | | </span><span class="reserved">kinds-module</span><span class="plain"> | | |</span>
<span class="plain">| | | </span><span class="reserved">if-module</span><span class="plain"> | | |</span>
<span class="plain">| | | </span><span class="reserved">multimedia-module</span><span class="plain"> | | |</span>
<span class="plain">| | | </span><span class="reserved">index-module</span><span class="plain"> | | |</span>
<span class="plain">| | +---+.............+---+ | |</span>
<span class="plain">| | | | | |</span>
<span class="plain">| | +---+.............+----------+.............+---+</span>
<span class="plain">| | | </span><span class="reserved">inter-module</span><span class="plain"> |</span>
<span class="plain">| | | </span><span class="reserved">building-module</span><span class="plain"> |</span>
<span class="plain">| | | </span><span class="reserved">codegen-module</span><span class="plain"> |</span>
<span class="plain">| | +---+.............+----------+.............+---+</span>
<span class="plain">| | | | | |</span>
<span class="plain">+---+.............+----------+.............+----------+.............+---+</span>
<span class="plain">| </span><span class="reserved">words-module</span><span class="plain"> |</span>
<span class="plain">| </span><span class="reserved">arch-module</span><span class="plain"> |</span>
<span class="plain">+---+.............+----------+.............+----------+.............+---+</span>
<span class="plain">| | | | | |</span>
<span class="plain">+---+.............+----------+.............+----------+.............+---+</span>
<span class="plain">| (</span><span class="reserved">foundation-module</span><span class="plain"> </span><span class="element">from</span><span class="plain"> </span><span class="element">inweb</span><span class="plain">) |</span>
<span class="plain">| (</span><span class="element">Posix</span><span class="plain"> </span><span class="element">or</span><span class="plain"> </span><span class="element">Windows</span><span class="plain">-</span><span class="element">related</span><span class="plain"> </span><span class="element">functions</span><span class="plain">) |</span>
<span class="plain">| (</span><span class="element">standard</span><span class="plain"> </span><span class="element">C</span><span class="plain"> </span><span class="element">library</span><span class="plain">) |</span>
<span class="plain">+---+.............+----------+.............+----------+.............+---+</span>
<span class="plain">| | | | | |</span>
<span class="plain">+-------------+ +-------------+ +-------------+</span>
</pre>
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP3"></a><b>&#167;3. </b>The three CLIs are to be found in the webs called <code class="display"><span class="extract">inbuild</span></code>, <code class="display"><span class="extract">inform7</span></code>
and <code class="display"><span class="extract">inter</span></code> (and these are the webs which tangle to the three complete tools).
Each module is also a web, and the above chart shows where it is: a module
in the INBUILD column, say <code class="display"><span class="extract">syntax-module</span></code>, is at the path <code class="display"><span class="extract">inbuild/syntax-module</span></code>,
for example. But as the diagram shows, it's shared code and runs in both
<code class="display"><span class="extract">inbuild</span></code> and <code class="display"><span class="extract">inform7</span></code>.
2020-03-19 02:11:25 +02:00
</p>
2020-04-08 01:02:44 +03:00
<p class="inwebparagraph">All three tools also contain the <code class="display"><span class="extract">foundation</span></code> module, a library of utility
2020-03-19 02:11:25 +02:00
code which is present in every Inform tool.
</p>
<!--End of weave-->
</main>
</body>
</html>