1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-01 06:24:58 +03:00

Added interpipeline files

This commit is contained in:
Graham Nelson 2019-07-20 12:40:27 +01:00
parent 07973d0704
commit 0c0c148830
67 changed files with 1205 additions and 922 deletions

View file

@ -30,6 +30,7 @@ have no meaningful contents when the step is not running.
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">pathname</span><span class="plain"> **</span><span class="identifier">the_PP</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">the_N</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">to_debugging_log</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">repository_argument</span><span class="plain">;</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">text_out_file</span><span class="plain">;</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">repository</span><span class="plain">;</span>
<span class="identifier">MEMORY_MANAGEMENT</span>
@ -40,6 +41,7 @@ have no meaningful contents when the step is not running.
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;package_argument</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository_argument</span><span class="plain"> = -1;</span>
<span class="functiontext">CodeGen::Pipeline::clean_step</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">);</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">step</span><span class="plain">;</span>
<span class="plain">}</span>
@ -49,7 +51,7 @@ have no meaningful contents when the step is not running.
<p class="endnote">The function CodeGen::Pipeline::new_step is used in <a href="#SP3">&#167;3</a>.</p>
<p class="endnote">The structure pipeline_step is accessed in 2/lnk, 2/plm, 2/rcc, 2/alm, 2/res, 2/unq, 2/rv, 2/erm, 2/erl, 4/cg, 5/fti, 5/fbi, 5/fi and here.</p>
<p class="endnote">The structure pipeline_step is accessed in 1/stg, 2/lnk, 2/plm, 2/rcc, 2/alm, 2/res, 2/unq, 2/rv, 2/erm, 2/erl, 4/cg, 5/fti, 5/fbi, 5/fi and here.</p>
<p class="inwebparagraph"><a id="SP2"></a><b>&#167;2. </b>This wipes clean the temporary storage for a step.
</p>
@ -81,18 +83,22 @@ logging:
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> != </span><span class="constant">NO_STAGE_ARG</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;package_argument</span><span class="plain">) </span><span class="identifier">WRITE</span><span class="plain">(</span><span class="string">" %S"</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;package_argument</span><span class="plain">);</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">":"</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository_argument</span><span class="plain"> &gt;= 0) </span><span class="identifier">WRITE</span><span class="plain">(</span><span class="string">" %d &lt;-"</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository_argument</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;target_argument</span><span class="plain">) </span><span class="identifier">WRITE</span><span class="plain">(</span><span class="string">" %S -&gt;"</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;target_argument</span><span class="plain">-</span><span class="element">&gt;target_name</span><span class="plain">);</span>
<span class="identifier">WRITE</span><span class="plain">(</span><span class="string">" %S"</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="reserved">pipeline_step</span><span class="plain"> *</span><span class="functiontext">CodeGen::Pipeline::read_step</span><span class="plain">(</span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">leafname</span><span class="plain">) {</span>
<span class="reserved">pipeline_step</span><span class="plain"> *</span><span class="functiontext">CodeGen::Pipeline::read_step</span><span class="plain">(</span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">D</span><span class="plain">) {</span>
<span class="functiontext">CodeGen::Stage::make_stages</span><span class="plain">();</span>
<span class="functiontext">CodeGen::Targets::make_targets</span><span class="plain">();</span>
<span class="reserved">pipeline_step</span><span class="plain"> *</span><span class="identifier">ST</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::new_step</span><span class="plain">();</span>
<span class="identifier">match_results</span><span class="plain"> </span><span class="identifier">mr</span><span class="plain"> = </span><span class="identifier">Regexp::create_mr</span><span class="plain">();</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"(%c+?) *: *(%C*) *-&gt; *(%c*)"</span><span class="plain">)) {</span>
<span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain"> = </span><span class="identifier">Str::new</span><span class="plain">();</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"(%c+?) *: *(%d) *&lt;- *(%c*)"</span><span class="plain">)) {</span>
<span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;repository_argument</span><span class="plain"> = </span><span class="identifier">Str::atoi</span><span class="plain">(</span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[1], 0);</span>
<span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::read_parameter</span><span class="plain">(</span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[2], </span><span class="identifier">D</span><span class="plain">);</span>
<span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[0]);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"(%c+?) *: *(%C*) *-&gt; *(%c*)"</span><span class="plain">)) {</span>
<span class="reserved">code_generation_target</span><span class="plain"> *</span><span class="identifier">cgt</span><span class="plain">;</span>
<span class="identifier">LOOP_OVER</span><span class="plain">(</span><span class="identifier">cgt</span><span class="plain">, </span><span class="reserved">code_generation_target</span><span class="plain">)</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::eq</span><span class="plain">(</span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[1], </span><span class="identifier">cgt</span><span class="plain">-</span><span class="element">&gt;target_name</span><span class="plain">))</span>
@ -101,18 +107,14 @@ logging:
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">STDERR</span><span class="plain">, </span><span class="string">"No such code generation target as '%S'\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[1]);</span>
<span class="identifier">internal_error</span><span class="plain">(</span><span class="string">"no such target"</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[2]);</span>
<span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::read_parameter</span><span class="plain">(</span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[2], </span><span class="identifier">D</span><span class="plain">);</span>
<span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[0]);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::eq</span><span class="plain">(</span><span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"*"</span><span class="plain">)) </span><span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">leafname</span><span class="plain">);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"(%c+?) *: *(%c*)"</span><span class="plain">)) {</span>
<span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain"> = </span><span class="identifier">Str::new</span><span class="plain">();</span>
<span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[1]);</span>
<span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::read_parameter</span><span class="plain">(</span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[1], </span><span class="identifier">D</span><span class="plain">);</span>
<span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[0]);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::eq</span><span class="plain">(</span><span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"*"</span><span class="plain">)) </span><span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">leafname</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"(%C+?) (%c+)"</span><span class="plain">)) {</span>
<span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;package_argument</span><span class="plain"> = </span><span class="identifier">Str::new</span><span class="plain">();</span>
<span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;package_argument</span><span class="plain">, </span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[1]);</span>
<span class="identifier">ST</span><span class="plain">-</span><span class="element">&gt;package_argument</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::read_parameter</span><span class="plain">(</span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[1], </span><span class="identifier">D</span><span class="plain">);</span>
<span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[0]);</span>
<span class="plain">}</span>
@ -127,6 +129,16 @@ logging:
<span class="identifier">Regexp::dispose_of</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">);</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">ST</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="identifier">text_stream</span><span class="plain"> *</span><span class="functiontext">CodeGen::Pipeline::read_parameter</span><span class="plain">(</span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">from</span><span class="plain">, </span><span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">D</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::get_first_char</span><span class="plain">(</span><span class="identifier">from</span><span class="plain">) == </span><span class="character">'*'</span><span class="plain">) {</span>
<span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">find</span><span class="plain"> = </span><span class="identifier">Dictionaries::get_text</span><span class="plain">(</span><span class="identifier">D</span><span class="plain">, </span><span class="identifier">from</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">find</span><span class="plain">) </span><span class="reserved">return</span><span class="plain"> </span><span class="identifier">Str::duplicate</span><span class="plain">(</span><span class="identifier">find</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">STDERR</span><span class="plain">, </span><span class="string">"No such pipeline variable as '%S'\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">from</span><span class="plain">);</span>
<span class="identifier">internal_error</span><span class="plain">(</span><span class="string">"no such pipeline variable"</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">Str::duplicate</span><span class="plain">(</span><span class="identifier">from</span><span class="plain">);</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
@ -135,31 +147,58 @@ logging:
<p class="endnote">The function CodeGen::Pipeline::read_step is used in <a href="#SP4">&#167;4</a>.</p>
<p class="endnote">The function CodeGen::Pipeline::read_parameter appears nowhere else.</p>
<p class="inwebparagraph"><a id="SP4"></a><b>&#167;4. Pipelines. </b>And then a pipeline is just a linked list of steps.
</p>
<pre class="display">
<span class="reserved">typedef</span><span class="plain"> </span><span class="reserved">struct</span><span class="plain"> </span><span class="reserved">codegen_pipeline</span><span class="plain"> {</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">variables</span><span class="plain">;</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">repositories</span><span class="plain">[10];</span>
<span class="reserved">struct</span><span class="plain"> </span><span class="identifier">linked_list</span><span class="plain"> *</span><span class="identifier">steps</span><span class="plain">; </span> <span class="comment">of <code class="display"><span class="extract">pipeline_step</span></code></span>
<span class="identifier">MEMORY_MANAGEMENT</span>
<span class="plain">} </span><span class="reserved">codegen_pipeline</span><span class="plain">;</span>
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="functiontext">CodeGen::Pipeline::new</span><span class="plain">(</span><span class="reserved">void</span><span class="plain">) {</span>
<span class="identifier">dictionary</span><span class="plain"> *</span><span class="functiontext">CodeGen::Pipeline::basic_dictionary</span><span class="plain">(</span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">leafname</span><span class="plain">) {</span>
<span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">D</span><span class="plain"> = </span><span class="identifier">Dictionaries::new</span><span class="plain">(16, </span><span class="identifier">TRUE</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::len</span><span class="plain">(</span><span class="identifier">leafname</span><span class="plain">) &gt; 0) </span><span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">Dictionaries::create_text</span><span class="plain">(</span><span class="identifier">D</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"*out"</span><span class="plain">), </span><span class="identifier">leafname</span><span class="plain">);</span>
<span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">Dictionaries::create_text</span><span class="plain">(</span><span class="identifier">D</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"*log"</span><span class="plain">), </span><span class="identifier">I</span><span class="string">"*log"</span><span class="plain">);</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">D</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="functiontext">CodeGen::Pipeline::new</span><span class="plain">(</span><span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">D</span><span class="plain">) {</span>
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain"> = </span><span class="identifier">CREATE</span><span class="plain">(</span><span class="reserved">codegen_pipeline</span><span class="plain">);</span>
<span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;variables</span><span class="plain"> = </span><span class="identifier">D</span><span class="plain">;</span>
<span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;steps</span><span class="plain"> = </span><span class="identifier">NEW_LINKED_LIST</span><span class="plain">(</span><span class="reserved">pipeline_step</span><span class="plain">);</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">i</span><span class="plain">=0; </span><span class="identifier">i</span><span class="plain">&lt;10; </span><span class="identifier">i</span><span class="plain">++) </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;repositories</span><span class="plain">[</span><span class="identifier">i</span><span class="plain">] = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">S</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="functiontext">CodeGen::Pipeline::parse</span><span class="plain">(</span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">instructions</span><span class="plain">, </span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">leafname</span><span class="plain">) {</span>
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::new</span><span class="plain">();</span>
<span class="functiontext">CodeGen::Pipeline::parse_into</span><span class="plain">(</span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">instructions</span><span class="plain">, </span><span class="identifier">leafname</span><span class="plain">);</span>
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="functiontext">CodeGen::Pipeline::parse_from_file</span><span class="plain">(</span><span class="identifier">filename</span><span class="plain"> *</span><span class="identifier">F</span><span class="plain">, </span><span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">D</span><span class="plain">) {</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">A</span><span class="plain">);</span>
<span class="identifier">TextFiles::read</span><span class="plain">(</span><span class="identifier">F</span><span class="plain">, </span><span class="identifier">FALSE</span><span class="plain">, </span><span class="string">"can't open inter pipeline file"</span><span class="plain">,</span>
<span class="identifier">TRUE</span><span class="plain">, </span><span class="functiontext">CodeGen::Pipeline::scan_line</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, (</span><span class="reserved">void</span><span class="plain"> *) </span><span class="identifier">A</span><span class="plain">);</span>
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::new</span><span class="plain">(</span><span class="identifier">D</span><span class="plain">);</span>
<span class="functiontext">CodeGen::Pipeline::parse_into</span><span class="plain">(</span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">A</span><span class="plain">);</span>
<span class="identifier">DISCARD_TEXT</span><span class="plain">(</span><span class="identifier">A</span><span class="plain">);</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">S</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CodeGen::Pipeline::parse_into</span><span class="plain">(</span><span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">instructions</span><span class="plain">, </span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">leafname</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">instructions</span><span class="plain"> == </span><span class="identifier">NULL</span><span class="plain">)</span>
<span class="identifier">instructions</span><span class="plain"> = </span><span class="identifier">I</span><span class="string">"link:Output.i6t, parse-linked-matter, resolve-conditional-compilation, assimilate, reconcile-verbs, generate: inform6 -&gt; *"</span><span class="plain">;</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CodeGen::Pipeline::scan_line</span><span class="plain">(</span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">line</span><span class="plain">, </span><span class="identifier">text_file_position</span><span class="plain"> *</span><span class="identifier">tfp</span><span class="plain">, </span><span class="reserved">void</span><span class="plain"> *</span><span class="identifier">X</span><span class="plain">) {</span>
<span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">A</span><span class="plain"> = (</span><span class="identifier">text_stream</span><span class="plain"> *) </span><span class="identifier">X</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::len</span><span class="plain">(</span><span class="identifier">A</span><span class="plain">) &gt; 0) </span><span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">A</span><span class="plain">, </span><span class="string">", "</span><span class="plain">);</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">A</span><span class="plain">, </span><span class="string">"%S"</span><span class="plain">, </span><span class="identifier">line</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="functiontext">CodeGen::Pipeline::parse</span><span class="plain">(</span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">instructions</span><span class="plain">, </span><span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">D</span><span class="plain">) {</span>
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::new</span><span class="plain">(</span><span class="identifier">D</span><span class="plain">);</span>
<span class="functiontext">CodeGen::Pipeline::parse_into</span><span class="plain">(</span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">instructions</span><span class="plain">);</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">S</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CodeGen::Pipeline::parse_into</span><span class="plain">(</span><span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">instructions</span><span class="plain">) {</span>
<span class="identifier">TEMPORARY_TEXT</span><span class="plain">(</span><span class="identifier">T</span><span class="plain">);</span>
<span class="identifier">LOOP_THROUGH_TEXT</span><span class="plain">(</span><span class="identifier">P</span><span class="plain">, </span><span class="identifier">instructions</span><span class="plain">)</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Characters::is_babel_whitespace</span><span class="plain">(</span><span class="identifier">Str::get</span><span class="plain">(</span><span class="identifier">P</span><span class="plain">)))</span>
@ -167,30 +206,35 @@ logging:
<span class="reserved">else</span>
<span class="identifier">PUT_TO</span><span class="plain">(</span><span class="identifier">T</span><span class="plain">, </span><span class="identifier">Str::get</span><span class="plain">(</span><span class="identifier">P</span><span class="plain">));</span>
<span class="identifier">match_results</span><span class="plain"> </span><span class="identifier">mr</span><span class="plain"> = </span><span class="identifier">Regexp::create_mr</span><span class="plain">();</span>
<span class="reserved">while</span><span class="plain"> (</span><span class="identifier">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">T</span><span class="plain">, </span><span class="identifier">L</span><span class="string">" *(%c+?) *, *(%c*?) *"</span><span class="plain">)) {</span>
<span class="reserved">pipeline_step</span><span class="plain"> *</span><span class="identifier">ST</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::read_step</span><span class="plain">(</span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[0], </span><span class="identifier">leafname</span><span class="plain">);</span>
<span class="identifier">ADD_TO_LINKED_LIST</span><span class="plain">(</span><span class="identifier">ST</span><span class="plain">, </span><span class="reserved">pipeline_step</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;steps</span><span class="plain">);</span>
<span class="reserved">while</span><span class="plain"> (</span><span class="identifier">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">T</span><span class="plain">, </span><span class="identifier">L</span><span class="string">" *(%c+?) *,+ *(%c*?) *"</span><span class="plain">)) {</span>
<span class="reserved">pipeline_step</span><span class="plain"> *</span><span class="identifier">ST</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::read_step</span><span class="plain">(</span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[0], </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;variables</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">ST</span><span class="plain">) </span><span class="identifier">ADD_TO_LINKED_LIST</span><span class="plain">(</span><span class="identifier">ST</span><span class="plain">, </span><span class="reserved">pipeline_step</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;steps</span><span class="plain">);</span>
<span class="identifier">Str::copy</span><span class="plain">(</span><span class="identifier">T</span><span class="plain">, </span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[1]);</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">T</span><span class="plain">, </span><span class="identifier">L</span><span class="string">" *(%c+?) *"</span><span class="plain">)) {</span>
<span class="reserved">pipeline_step</span><span class="plain"> *</span><span class="identifier">ST</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::read_step</span><span class="plain">(</span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[0], </span><span class="identifier">leafname</span><span class="plain">);</span>
<span class="identifier">ADD_TO_LINKED_LIST</span><span class="plain">(</span><span class="identifier">ST</span><span class="plain">, </span><span class="reserved">pipeline_step</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;steps</span><span class="plain">);</span>
<span class="reserved">pipeline_step</span><span class="plain"> *</span><span class="identifier">ST</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::read_step</span><span class="plain">(</span><span class="identifier">mr</span><span class="plain">.</span><span class="identifier">exp</span><span class="plain">[0], </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;variables</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">ST</span><span class="plain">) </span><span class="identifier">ADD_TO_LINKED_LIST</span><span class="plain">(</span><span class="identifier">ST</span><span class="plain">, </span><span class="reserved">pipeline_step</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;steps</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CodeGen::Pipeline::run</span><span class="plain">(</span><span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">P</span><span class="plain">, </span><span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">I</span><span class="plain">, </span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">N</span><span class="plain">, </span><span class="identifier">pathname</span><span class="plain"> **</span><span class="identifier">PP</span><span class="plain">, </span><span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">PM</span><span class="plain">, </span><span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">FM</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">S</span><span class="plain"> == </span><span class="identifier">NULL</span><span class="plain">) </span><span class="reserved">return</span><span class="plain">;</span>
<span class="identifier">clock_t</span><span class="plain"> </span><span class="identifier">start</span><span class="plain"> = </span><span class="identifier">clock</span><span class="plain">();</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CodeGen::Pipeline::set_repository</span><span class="plain">(</span><span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">, </span><span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">I</span><span class="plain">) {</span>
<span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;repositories</span><span class="plain">[0] = </span><span class="identifier">I</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="functiontext">CodeGen::Pipeline::prepare_to_run</span><span class="plain">(</span><span class="identifier">I</span><span class="plain">);</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CodeGen::Pipeline::run</span><span class="plain">(</span><span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">P</span><span class="plain">, </span><span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">S</span><span class="plain">, </span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">N</span><span class="plain">, </span><span class="identifier">pathname</span><span class="plain"> **</span><span class="identifier">PP</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">S</span><span class="plain"> == </span><span class="identifier">NULL</span><span class="plain">) </span><span class="reserved">return</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;repositories</span><span class="plain">[0] == </span><span class="identifier">NULL</span><span class="plain">) </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;repositories</span><span class="plain">[0] = </span><span class="identifier">Inter::create</span><span class="plain">(1, 32);</span>
<span class="identifier">clock_t</span><span class="plain"> </span><span class="identifier">start</span><span class="plain"> = </span><span class="identifier">clock</span><span class="plain">();</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">step_count</span><span class="plain"> = 0, </span><span class="identifier">step_total</span><span class="plain"> = 0;</span>
<span class="reserved">pipeline_step</span><span class="plain"> *</span><span class="identifier">step</span><span class="plain">;</span>
<span class="identifier">LOOP_OVER_LINKED_LIST</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">, </span><span class="reserved">pipeline_step</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;steps</span><span class="plain">) </span><span class="identifier">step_total</span><span class="plain">++;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">active</span><span class="plain"> = </span><span class="identifier">TRUE</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">active</span><span class="plain"> = </span><span class="identifier">TRUE</span><span class="plain">, </span><span class="identifier">current_repo</span><span class="plain"> = 0;</span>
<span class="functiontext">CodeGen::Pipeline::prepare_to_run</span><span class="plain">(</span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;repositories</span><span class="plain">[</span><span class="identifier">current_repo</span><span class="plain">]);</span>
<span class="identifier">LOOP_OVER_LINKED_LIST</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">, </span><span class="reserved">pipeline_step</span><span class="plain">, </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;steps</span><span class="plain">)</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">active</span><span class="plain">) {</span>
<span class="identifier">inter_repository</span><span class="plain"> *</span><span class="identifier">I</span><span class="plain"> = </span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;repositories</span><span class="plain">[</span><span class="identifier">current_repo</span><span class="plain">];</span>
<span class="functiontext">CodeGen::Pipeline::lint</span><span class="plain">(</span><span class="identifier">I</span><span class="plain">);</span>
<span class="functiontext">CodeGen::Pipeline::clean_step</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">);</span>
@ -209,18 +253,17 @@ logging:
<span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> == </span><span class="constant">TEXT_OUT_STAGE_ARG</span><span class="plain">) ||</span>
<span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> == </span><span class="constant">EXT_FILE_STAGE_ARG</span><span class="plain">) ||</span>
<span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> == </span><span class="constant">EXT_TEXT_OUT_STAGE_ARG</span><span class="plain">)) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::eq</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"log"</span><span class="plain">)) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::eq</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"*log"</span><span class="plain">)) {</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;to_debugging_log</span><span class="plain"> = </span><span class="identifier">TRUE</span><span class="plain">;</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;parsed_filename</span><span class="plain"> = </span><span class="identifier">Filenames::from_text</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">);</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">slashes</span><span class="plain"> = </span><span class="identifier">FALSE</span><span class="plain">;</span>
<span class="identifier">LOOP_THROUGH_TEXT</span><span class="plain">(</span><span class="identifier">pos</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">)</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::get</span><span class="plain">(</span><span class="identifier">pos</span><span class="plain">) == </span><span class="character">'/'</span><span class="plain">)</span>
<span class="identifier">slashes</span><span class="plain"> = </span><span class="identifier">TRUE</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">slashes</span><span class="plain">) </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;parsed_filename</span><span class="plain"> = </span><span class="identifier">Filenames::from_text</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> ((</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> == </span><span class="constant">EXT_FILE_STAGE_ARG</span><span class="plain">) ||</span>
<span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_stage</span><span class="plain">-</span><span class="element">&gt;stage_arg</span><span class="plain"> == </span><span class="constant">EXT_TEXT_OUT_STAGE_ARG</span><span class="plain">))</span>
<span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;parsed_filename</span><span class="plain"> = </span><span class="identifier">Filenames::in_folder</span><span class="plain">(</span><span class="identifier">FM</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;parsed_filename</span><span class="plain"> = </span><span class="identifier">Filenames::in_folder</span><span class="plain">(</span><span class="identifier">P</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">);</span>
<span class="identifier">LOG</span><span class="plain">(</span><span class="string">"Parsed %S == %f\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;parsed_filename</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="plain">}</span>
@ -249,18 +292,31 @@ logging:
<span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;to_debugging_log</span><span class="plain"> == </span><span class="identifier">FALSE</span><span class="plain">)) {</span>
<span class="identifier">STREAM_CLOSE</span><span class="plain">(</span><span class="identifier">T</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository_argument</span><span class="plain"> &gt;= 0) {</span>
<span class="identifier">current_repo</span><span class="plain"> = </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository_argument</span><span class="plain">;</span>
<span class="functiontext">CodeGen::Pipeline::prepare_to_run</span><span class="plain">(</span><span class="identifier">S</span><span class="plain">-</span><span class="element">&gt;repositories</span><span class="plain">[</span><span class="identifier">current_repo</span><span class="plain">]);</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function CodeGen::Pipeline::basic_dictionary appears nowhere else.</p>
<p class="endnote">The function CodeGen::Pipeline::new appears nowhere else.</p>
<p class="endnote">The function CodeGen::Pipeline::parse_from_file appears nowhere else.</p>
<p class="endnote">The function CodeGen::Pipeline::scan_line appears nowhere else.</p>
<p class="endnote">The function CodeGen::Pipeline::parse appears nowhere else.</p>
<p class="endnote">The function CodeGen::Pipeline::parse_into appears nowhere else.</p>
<p class="endnote">The function CodeGen::Pipeline::set_repository appears nowhere else.</p>
<p class="endnote">The function CodeGen::Pipeline::run appears nowhere else.</p>
<p class="endnote">The structure codegen_pipeline is private to this section.</p>

View file

@ -63,6 +63,7 @@ to the routine below.
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">stages_made</span><span class="plain"> == </span><span class="identifier">FALSE</span><span class="plain">) {</span>
<span class="identifier">stages_made</span><span class="plain"> = </span><span class="identifier">TRUE</span><span class="plain">;</span>
<span class="functiontext">CodeGen::Stage::new</span><span class="plain">(</span><span class="identifier">I</span><span class="string">"stop"</span><span class="plain">, </span><span class="functiontext">CodeGen::Stage::run_stop_stage</span><span class="plain">, </span><span class="constant">NO_STAGE_ARG</span><span class="plain">);</span>
<span class="functiontext">CodeGen::Stage::new</span><span class="plain">(</span><span class="identifier">I</span><span class="string">"read"</span><span class="plain">, </span><span class="functiontext">CodeGen::Stage::run_read_stage</span><span class="plain">, </span><span class="constant">FILE_STAGE_ARG</span><span class="plain">);</span>
<span class="functiontext">CodeGen::create_pipeline_stage</span><span class="plain">();</span>
<span class="functiontext">CodeGen::Assimilate::create_pipeline_stage</span><span class="plain">();</span>
@ -91,12 +92,23 @@ the pipeline:
<span class="reserved">int</span><span class="plain"> </span><span class="functiontext">CodeGen::Stage::run_stop_stage</span><span class="plain">(</span><span class="reserved">pipeline_step</span><span class="plain"> *</span><span class="identifier">step</span><span class="plain">) {</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">FALSE</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">int</span><span class="plain"> </span><span class="functiontext">CodeGen::Stage::run_read_stage</span><span class="plain">(</span><span class="reserved">pipeline_step</span><span class="plain"> *</span><span class="identifier">step</span><span class="plain">) {</span>
<span class="identifier">filename</span><span class="plain"> *</span><span class="identifier">F</span><span class="plain"> = </span><span class="identifier">Filenames::from_text</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;step_argument</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Inter::Binary::test_file</span><span class="plain">(</span><span class="identifier">F</span><span class="plain">))</span>
<span class="identifier">Inter::Binary::read</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository</span><span class="plain">, </span><span class="identifier">F</span><span class="plain">);</span>
<span class="reserved">else</span>
<span class="identifier">Inter::Textual::read</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository</span><span class="plain">, </span><span class="identifier">F</span><span class="plain">);</span>
<span class="reserved">return</span><span class="plain"> </span><span class="identifier">TRUE</span><span class="plain">;</span>
<span class="plain">}</span>
</pre>
<p class="inwebparagraph"></p>
<p class="endnote">The function CodeGen::Stage::run_stop_stage is used in <a href="#SP2">&#167;2</a>.</p>
<p class="endnote">The function CodeGen::Stage::run_read_stage is used in <a href="#SP2">&#167;2</a>.</p>
<hr class="tocbar">
<ul class="toc"><li><a href="1-cm.html">Back to 'Codegen Module'</a></li><li><a href="1-ppl.html">Continue with 'Pipelines'</a></li></ul><hr class="tocbar">
<!--End of weave-->

View file

@ -201,9 +201,6 @@
<span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">suffix</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">inter_symbol</span><span class="plain"> *</span><span class="identifier">subpackage_type</span><span class="plain"> = </span><span class="identifier">plain_packagetype</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">plm</span><span class="plain"> == </span><span class="identifier">ATTRIBUTE_PLM</span><span class="plain">) </span><span class="identifier">trace_AME</span><span class="plain"> = </span><span class="identifier">TRUE</span><span class="plain">;</span>
<span class="reserved">else</span><span class="plain"> </span><span class="identifier">trace_AME</span><span class="plain"> = </span><span class="identifier">FALSE</span><span class="plain">;</span>
<span class="reserved">switch</span><span class="plain"> (</span><span class="identifier">plm</span><span class="plain">) {</span>
<span class="reserved">case</span><span class="plain"> </span><span class="identifier">VERB_PLM</span><span class="plain">:</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">command_ptype_symbol</span><span class="plain">) </span><span class="identifier">subpackage_type</span><span class="plain"> = </span><span class="identifier">command_ptype_symbol</span><span class="plain">;</span>

View file

@ -37,6 +37,7 @@
<span class="identifier">internal_error</span><span class="plain">(</span><span class="string">"that's not a package name"</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="reserved">code_generation</span><span class="plain"> *</span><span class="identifier">gen</span><span class="plain"> =</span>
<span class="functiontext">CodeGen::new_generation</span><span class="plain">(</span><span class="identifier">step</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;repository</span><span class="plain">, </span><span class="identifier">which</span><span class="plain">, </span><span class="identifier">step</span><span class="plain">-</span><span class="element">&gt;target_argument</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">CodeGen::Targets::begin_generation</span><span class="plain">(</span><span class="identifier">gen</span><span class="plain">) == </span><span class="identifier">FALSE</span><span class="plain">) {</span>

View file

@ -87,7 +87,8 @@ Inform 6 code is complete.
<pre class="display">
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">report_clock_time</span><span class="plain"> = </span><span class="identifier">FALSE</span><span class="plain">;</span>
<span class="identifier">time_t</span><span class="plain"> </span><span class="identifier">right_now</span><span class="plain">;</span>
<span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">inter_processing_chain</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">inter_processing_file</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">text_stream</span><span class="plain"> *</span><span class="identifier">inter_processing_pipeline</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">path_to_inform7</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="functiontext">CoreMain::main</span><span class="plain">(</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">argc</span><span class="plain">, </span><span class="reserved">char</span><span class="plain"> *</span><span class="identifier">argv</span><span class="plain">[]) {</span>
@ -138,7 +139,7 @@ Inform 6 code is complete.
<pre class="displaydefn">
<span class="identifier">Errors::set_internal_handler</span><span class="plain">(&amp;</span><span class="identifier">Problems::Issue::internal_error_fn</span><span class="plain">);</span>
<span class="identifier">story_filename_extension</span><span class="plain"> = </span><span class="identifier">I</span><span class="string">"ulx"</span><span class="plain">;</span>
<span class="identifier">inter_processing_chain</span><span class="plain"> = </span><span class="identifier">I</span><span class="string">"link: Output.i6t, parse-linked-matter, resolve-conditional-compilation, assimilate, make-identifiers-unique, resolve-external-symbols, reconcile-verbs, generate: inform6 -&gt; *"</span><span class="plain">;</span>
<span class="identifier">inter_processing_pipeline</span><span class="plain"> = </span><span class="identifier">Str::new</span><span class="plain">();</span>
<span class="identifier">PRINT</span><span class="plain">(</span><span class="string">"%B build %B has started.\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">FALSE</span><span class="plain">, </span><span class="identifier">TRUE</span><span class="plain">);</span>
<span class="identifier">STREAM_FLUSH</span><span class="plain">(</span><span class="identifier">STDOUT</span><span class="plain">);</span>
@ -171,7 +172,8 @@ list is not exhaustive.
<span class="definitionkeyword">enum</span> <span class="constant">RNG_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">SIGILS_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">TRANSIENT_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">INTER_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">PIPELINE_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">PIPELINE_FILE_CLSW</span>
</pre>
<p class="inwebparagraph"><a id="SP4_3"></a><b>&#167;4.3. </b><code class="display">
&lt;<span class="cwebmacrodefn">Register command-line arguments</span> <span class="cwebmacronumber">4.3</span>&gt; =
@ -207,8 +209,10 @@ list is not exhaustive.
<span class="identifier">L</span><span class="string">"make any source links refer to the source in extension example X"</span><span class="plain">);</span>
<span class="identifier">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">REQUIRE_PROBLEM_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"require-problem"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"return 0 unless exactly this Problem message is generated (for testing)"</span><span class="plain">);</span>
<span class="identifier">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">INTER_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"inter"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"specify code-generation chain for inter code"</span><span class="plain">);</span>
<span class="identifier">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">PIPELINE_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"pipeline"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"specify code-generation pipeline"</span><span class="plain">);</span>
<span class="identifier">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">PIPELINE_FILE_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"pipeline-file"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"specify code-generation pipeline from file X"</span><span class="plain">);</span>
<span class="identifier">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">PROJECT_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"project"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"work within the Inform project X"</span><span class="plain">);</span>
@ -568,13 +572,28 @@ list is not exhaustive.
<span class="identifier">LOG</span><span class="plain">(</span><span class="string">"Front end elapsed time: %dcs\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, ((</span><span class="reserved">int</span><span class="plain">) (</span><span class="identifier">front_end</span><span class="plain"> - </span><span class="identifier">start</span><span class="plain">)) / (</span><span class="identifier">CLOCKS_PER_SEC</span><span class="plain">/100));</span>
<span class="functiontext">CoreMain::go_to_log_phase</span><span class="plain">(</span><span class="identifier">I</span><span class="string">"Converting inter to Inform 6"</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">existing_story_file</span><span class="plain"> == </span><span class="identifier">FALSE</span><span class="plain">) {</span>
<span class="identifier">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">SS</span><span class="plain"> = </span><span class="identifier">CodeGen::Pipeline::new</span><span class="plain">();</span>
<span class="identifier">CodeGen::Pipeline::parse_into</span><span class="plain">(</span><span class="identifier">SS</span><span class="plain">, </span><span class="identifier">inter_processing_chain</span><span class="plain">,</span>
<span class="identifier">dictionary</span><span class="plain"> *</span><span class="identifier">D</span><span class="plain"> = </span><span class="identifier">CodeGen::Pipeline::basic_dictionary</span><span class="plain">(</span>
<span class="identifier">Filenames::get_leafname</span><span class="plain">(</span><span class="identifier">filename_of_compiled_i6_code</span><span class="plain">));</span>
<span class="identifier">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">SS</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">inter_processing_file</span><span class="plain">)</span>
<span class="identifier">SS</span><span class="plain"> = </span><span class="identifier">CodeGen::Pipeline::parse_from_file</span><span class="plain">(</span><span class="identifier">Filenames::from_text</span><span class="plain">(</span><span class="identifier">inter_processing_file</span><span class="plain">), </span><span class="identifier">D</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="identifier">Str::len</span><span class="plain">(</span><span class="identifier">inter_processing_pipeline</span><span class="plain">) &gt; 0)</span>
<span class="identifier">SS</span><span class="plain"> = </span><span class="identifier">CodeGen::Pipeline::parse</span><span class="plain">(</span><span class="identifier">inter_processing_pipeline</span><span class="plain">, </span><span class="identifier">D</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> {</span>
<span class="reserved">for</span><span class="plain"> (</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">area</span><span class="plain">=0; </span><span class="identifier">area</span><span class="plain">&lt;</span><span class="constant">NO_FS_AREAS</span><span class="plain">; </span><span class="identifier">area</span><span class="plain">++) {</span>
<span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">P</span><span class="plain"> = </span><span class="identifier">pathname_of_inter_resources</span><span class="plain">[</span><span class="identifier">area</span><span class="plain">];</span>
<span class="identifier">filename</span><span class="plain"> *</span><span class="identifier">F</span><span class="plain"> = </span><span class="identifier">Filenames::in_folder</span><span class="plain">(</span><span class="identifier">P</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"default.interpipeline"</span><span class="plain">);</span>
<span class="identifier">LOG</span><span class="plain">(</span><span class="string">"Trying %f\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">F</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">TextFiles::exists</span><span class="plain">(</span><span class="identifier">F</span><span class="plain">)) {</span>
<span class="identifier">SS</span><span class="plain"> = </span><span class="identifier">CodeGen::Pipeline::parse_from_file</span><span class="plain">(</span><span class="identifier">F</span><span class="plain">, </span><span class="identifier">D</span><span class="plain">);</span>
<span class="reserved">break</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">SS</span><span class="plain"> == </span><span class="identifier">NULL</span><span class="plain">) </span><span class="identifier">internal_error</span><span class="plain">(</span><span class="string">"no inter pipeline could be found"</span><span class="plain">);</span>
<span class="identifier">CodeGen::Pipeline::set_repository</span><span class="plain">(</span><span class="identifier">SS</span><span class="plain">, </span><span class="functiontext">Emit::repository</span><span class="plain">());</span>
<span class="identifier">CodeGen::Pipeline::run</span><span class="plain">(</span><span class="identifier">Filenames::get_path_to</span><span class="plain">(</span><span class="identifier">filename_of_compiled_i6_code</span><span class="plain">),</span>
<span class="identifier">SS</span><span class="plain">, </span><span class="functiontext">Emit::repository</span><span class="plain">(), </span><span class="constant">NO_FS_AREAS</span><span class="plain">, </span><span class="identifier">pathname_of_i6t_files</span><span class="plain">,</span>
<span class="identifier">pathname_of_i6t_files</span><span class="plain">[</span><span class="constant">INTERNAL_FS_AREA</span><span class="plain">],</span>
<span class="identifier">pathname_of_i6t_files</span><span class="plain">[</span><span class="constant">INTERNAL_FS_AREA</span><span class="plain">]);</span>
<span class="identifier">SS</span><span class="plain">, </span><span class="constant">NO_FS_AREAS</span><span class="plain">, </span><span class="identifier">pathname_of_i6t_files</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="identifier">LOG</span><span class="plain">(</span><span class="string">"Back end elapsed time: %dcs\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, ((</span><span class="reserved">int</span><span class="plain">) (</span><span class="identifier">clock</span><span class="plain">() - </span><span class="identifier">front_end</span><span class="plain">)) / (</span><span class="identifier">CLOCKS_PER_SEC</span><span class="plain">/100));</span>
<span class="plain">}</span>
@ -693,7 +712,8 @@ list is not exhaustive.
<span class="reserved">case</span><span class="plain"> </span><span class="constant">FORMAT_CLSW</span><span class="plain">: </span><span class="identifier">story_filename_extension</span><span class="plain"> = </span><span class="identifier">Str::duplicate</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">CASE_CLSW</span><span class="plain">: </span><span class="identifier">HTMLFiles::set_source_link_case</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">REQUIRE_PROBLEM_CLSW</span><span class="plain">: </span><span class="identifier">Problems::Fatal::require</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">INTER_CLSW</span><span class="plain">: </span><span class="identifier">inter_processing_chain</span><span class="plain"> = </span><span class="identifier">Str::duplicate</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">PIPELINE_CLSW</span><span class="plain">: </span><span class="identifier">inter_processing_pipeline</span><span class="plain"> = </span><span class="identifier">Str::duplicate</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">PIPELINE_FILE_CLSW</span><span class="plain">: </span><span class="identifier">inter_processing_file</span><span class="plain"> = </span><span class="identifier">Str::duplicate</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="comment">Useful pathnames</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">PROJECT_CLSW</span><span class="plain">: </span><span class="functiontext">Locations::set_project</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
@ -714,12 +734,12 @@ list is not exhaustive.
<span class="identifier">disable_import</span><span class="plain"> = </span><span class="identifier">TRUE</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CoreMain::set_inter_chain</span><span class="plain">(</span><span class="identifier">wording</span><span class="plain"> </span><span class="identifier">W</span><span class="plain">) {</span>
<span class="identifier">inter_processing_chain</span><span class="plain"> = </span><span class="identifier">Str::new</span><span class="plain">();</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">inter_processing_chain</span><span class="plain">, </span><span class="string">"%W"</span><span class="plain">, </span><span class="identifier">W</span><span class="plain">);</span>
<span class="identifier">Str::delete_first_character</span><span class="plain">(</span><span class="identifier">inter_processing_chain</span><span class="plain">);</span>
<span class="identifier">Str::delete_last_character</span><span class="plain">(</span><span class="identifier">inter_processing_chain</span><span class="plain">);</span>
<span class="identifier">LOG</span><span class="plain">(</span><span class="string">"Setting chain %S\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">inter_processing_chain</span><span class="plain">);</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">CoreMain::set_inter_pipeline</span><span class="plain">(</span><span class="identifier">wording</span><span class="plain"> </span><span class="identifier">W</span><span class="plain">) {</span>
<span class="identifier">inter_processing_pipeline</span><span class="plain"> = </span><span class="identifier">Str::new</span><span class="plain">();</span>
<span class="identifier">WRITE_TO</span><span class="plain">(</span><span class="identifier">inter_processing_pipeline</span><span class="plain">, </span><span class="string">"%W"</span><span class="plain">, </span><span class="identifier">W</span><span class="plain">);</span>
<span class="identifier">Str::delete_first_character</span><span class="plain">(</span><span class="identifier">inter_processing_pipeline</span><span class="plain">);</span>
<span class="identifier">Str::delete_last_character</span><span class="plain">(</span><span class="identifier">inter_processing_pipeline</span><span class="plain">);</span>
<span class="identifier">LOG</span><span class="plain">(</span><span class="string">"Setting pipeline %S\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">inter_processing_pipeline</span><span class="plain">);</span>
<span class="plain">}</span>
</pre>
@ -731,7 +751,7 @@ list is not exhaustive.
<p class="endnote">The function CoreMain::disable_importation is used in 7/hdn (<a href="7-hdn.html#SP10_2">&#167;10.2</a>).</p>
<p class="endnote">The function CoreMain::set_inter_chain is used in 26/uo (<a href="26-uo.html#SP11_2">&#167;11.2</a>).</p>
<p class="endnote">The function CoreMain::set_inter_pipeline is used in 26/uo (<a href="26-uo.html#SP11_2">&#167;11.2</a>).</p>
<hr class="tocbar">
<ul class="toc"><li><i>(This section begins Chapter 1: Configuration and Control.)</i></li><li><a href="1-cm.html">Continue with 'Core Module'</a></li></ul><hr class="tocbar">

View file

@ -44,6 +44,7 @@ not here. First, some "areas":
<span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">pathname_of_area</span><span class="plain">[</span><span class="constant">NO_FS_AREAS</span><span class="plain">] = { </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain"> };</span>
<span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">pathname_of_extensions</span><span class="plain">[</span><span class="constant">NO_FS_AREAS</span><span class="plain">] = { </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain"> };</span>
<span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">pathname_of_i6t_files</span><span class="plain">[</span><span class="constant">NO_FS_AREAS</span><span class="plain">] = { </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain"> };</span>
<span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">pathname_of_inter_resources</span><span class="plain">[</span><span class="constant">NO_FS_AREAS</span><span class="plain">] = { </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain"> };</span>
<span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">pathname_of_languages</span><span class="plain">[</span><span class="constant">NO_FS_AREAS</span><span class="plain">] = { </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain"> };</span>
<span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">pathname_of_website_templates</span><span class="plain">[</span><span class="constant">NO_FS_AREAS</span><span class="plain">] = { </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain"> };</span>
@ -75,6 +76,7 @@ not here. First, some "areas":
<span class="identifier">filename</span><span class="plain"> *</span><span class="identifier">filename_of_cblorb_report_model</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">filename</span><span class="plain"> *</span><span class="identifier">filename_of_compiled_i6_code</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">filename</span><span class="plain"> *</span><span class="identifier">filename_of_debugging_log</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">filename</span><span class="plain"> *</span><span class="identifier">filename_of_default_inter_pipeline</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">filename</span><span class="plain"> *</span><span class="identifier">filename_of_documentation_snippets</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">filename</span><span class="plain"> *</span><span class="identifier">filename_of_epsfile</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="identifier">filename</span><span class="plain"> *</span><span class="identifier">filename_of_existing_story_file</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
@ -219,6 +221,11 @@ example, live inside the Extensions part of this.
<span class="functiontext">Locations::EILT_at</span><span class="plain">(</span><span class="constant">INTERNAL_FS_AREA</span><span class="plain">, </span><span class="identifier">pathname_of_area</span><span class="plain">[</span><span class="constant">INTERNAL_FS_AREA</span><span class="plain">]);</span>
<span class="identifier">pathname</span><span class="plain"> *</span><span class="identifier">inter_resources</span><span class="plain"> =</span>
<span class="identifier">Pathnames::subfolder</span><span class="plain">(</span><span class="identifier">pathname_of_area</span><span class="plain">[</span><span class="constant">INTERNAL_FS_AREA</span><span class="plain">], </span><span class="identifier">I</span><span class="string">"Inter"</span><span class="plain">);</span>
<span class="identifier">filename_of_default_inter_pipeline</span><span class="plain"> =</span>
<span class="identifier">Filenames::in_folder</span><span class="plain">(</span><span class="identifier">inter_resources</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"default.interpipeline"</span><span class="plain">);</span>
&lt;<span class="cwebmacro">Miscellaneous other stuff</span> <span class="cwebmacronumber">6.1.1</span>&gt;<span class="plain">;</span>
</pre>
@ -710,6 +717,7 @@ template files, language definitions and website templates.
<span class="identifier">pathname_of_i6t_files</span><span class="plain">[</span><span class="identifier">area</span><span class="plain">] = </span><span class="identifier">Pathnames::subfolder</span><span class="plain">(</span><span class="identifier">P</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"I6T"</span><span class="plain">);</span>
<span class="identifier">pathname_of_languages</span><span class="plain">[</span><span class="identifier">area</span><span class="plain">] = </span><span class="identifier">Pathnames::subfolder</span><span class="plain">(</span><span class="identifier">P</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"Languages"</span><span class="plain">);</span>
<span class="identifier">pathname_of_website_templates</span><span class="plain">[</span><span class="identifier">area</span><span class="plain">] = </span><span class="identifier">Pathnames::subfolder</span><span class="plain">(</span><span class="identifier">P</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"Templates"</span><span class="plain">);</span>
<span class="identifier">pathname_of_inter_resources</span><span class="plain">[</span><span class="identifier">area</span><span class="plain">] = </span><span class="identifier">Pathnames::subfolder</span><span class="plain">(</span><span class="identifier">P</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"Inter"</span><span class="plain">);</span>
<span class="plain">}</span>
</pre>

View file

@ -214,8 +214,8 @@ option name is taken from the <code class="display"><span class="extract">...</s
<span class="plain">&lt;</span><span class="identifier">definite</span><span class="plain">-</span><span class="identifier">article</span><span class="plain">&gt; ... | ==&gt; 0</span>
<span class="plain">... ==&gt; 0</span>
<span class="plain">&lt;</span><span class="identifier">use</span><span class="plain">-</span><span class="identifier">inter</span><span class="plain">-</span><span class="identifier">chain</span><span class="plain">&gt; ::=</span>
<span class="identifier">inter</span><span class="plain"> </span><span class="identifier">chain</span><span class="plain"> {&lt;</span><span class="identifier">quoted</span><span class="plain">-</span><span class="identifier">text</span><span class="plain">&gt;} ==&gt; </span><span class="identifier">TRUE</span>
<span class="plain">&lt;</span><span class="identifier">use</span><span class="plain">-</span><span class="identifier">inter</span><span class="plain">-</span><span class="identifier">pipeline</span><span class="plain">&gt; ::=</span>
<span class="identifier">inter</span><span class="plain"> </span><span class="identifier">pipeline</span><span class="plain"> {&lt;</span><span class="identifier">quoted</span><span class="plain">-</span><span class="identifier">text</span><span class="plain">&gt;} ==&gt; </span><span class="identifier">TRUE</span>
</pre>
<p class="inwebparagraph"></p>
@ -292,7 +292,7 @@ there is no need to translate this to other languages.)
<span class="functiontext">UseOptions::set_use_options</span><span class="plain">(</span><span class="identifier">p</span><span class="plain">-</span><span class="element">&gt;down</span><span class="plain">-</span><span class="element">&gt;next</span><span class="plain">);</span>
<span class="reserved">return</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> (&lt;</span><span class="identifier">use</span><span class="plain">-</span><span class="identifier">inter</span><span class="plain">-</span><span class="identifier">chain</span><span class="plain">&gt;(</span><span class="identifier">ParseTree::get_text</span><span class="plain">(</span><span class="identifier">p</span><span class="plain">))) </span>&lt;<span class="cwebmacro">Set the chain given in this word range</span> <span class="cwebmacronumber">11.2</span>&gt;
<span class="reserved">if</span><span class="plain"> (&lt;</span><span class="identifier">use</span><span class="plain">-</span><span class="identifier">inter</span><span class="plain">-</span><span class="identifier">pipeline</span><span class="plain">&gt;(</span><span class="identifier">ParseTree::get_text</span><span class="plain">(</span><span class="identifier">p</span><span class="plain">))) </span>&lt;<span class="cwebmacro">Set the chain given in this word range</span> <span class="cwebmacronumber">11.2</span>&gt;
<span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (&lt;</span><span class="identifier">use</span><span class="plain">-</span><span class="identifier">sentence</span><span class="plain">-</span><span class="identifier">object</span><span class="plain">&gt;(</span><span class="identifier">ParseTree::get_text</span><span class="plain">(</span><span class="identifier">p</span><span class="plain">))) </span>&lt;<span class="cwebmacro">Set the option given in this word range</span> <span class="cwebmacronumber">11.1</span>&gt;<span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">traverse</span><span class="plain"> == 1) </span><span class="reserved">return</span><span class="plain">;</span>
<span class="identifier">LOG</span><span class="plain">(</span><span class="string">"Used: %W\</span><span class="plain">n</span><span class="string">"</span><span class="plain">, </span><span class="identifier">ParseTree::get_text</span><span class="plain">(</span><span class="identifier">p</span><span class="plain">));</span>
@ -349,8 +349,8 @@ there is no need to translate this to other languages.)
<pre class="displaydefn">
<span class="identifier">wording</span><span class="plain"> </span><span class="identifier">CW</span><span class="plain"> = </span><span class="identifier">GET_RW</span><span class="plain">(&lt;</span><span class="identifier">use</span><span class="plain">-</span><span class="identifier">inter</span><span class="plain">-</span><span class="identifier">chain</span><span class="plain">&gt;, 1);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">traverse</span><span class="plain"> == 1) </span><span class="functiontext">CoreMain::set_inter_chain</span><span class="plain">(</span><span class="identifier">CW</span><span class="plain">);</span>
<span class="identifier">wording</span><span class="plain"> </span><span class="identifier">CW</span><span class="plain"> = </span><span class="identifier">GET_RW</span><span class="plain">(&lt;</span><span class="identifier">use</span><span class="plain">-</span><span class="identifier">inter</span><span class="plain">-</span><span class="identifier">pipeline</span><span class="plain">&gt;, 1);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">traverse</span><span class="plain"> == 1) </span><span class="functiontext">CoreMain::set_inter_pipeline</span><span class="plain">(</span><span class="identifier">CW</span><span class="plain">);</span>
<span class="reserved">return</span><span class="plain">;</span>
</pre>

View file

@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>P/cas</title>
<title>P/pas</title>
<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">

View file

@ -19,13 +19,24 @@
<pre class="definitions">
<span class="definitionkeyword">enum</span> <span class="constant">TEXTUAL_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">BINARY_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">INTER_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">PIPELINE_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">PIPELINE_FILE_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">PIPELINE_VARIABLE_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">DOMAIN_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">TEMPLATE_CLSW</span>
<span class="definitionkeyword">enum</span> <span class="constant">TEST_CLSW</span>
</pre>
<pre class="display">
<span class="reserved">pathname</span><span class="plain"> *</span><span class="identifier">template_path</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">pathname</span><span class="plain"> *</span><span class="identifier">domain_path</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">filename</span><span class="plain"> *</span><span class="identifier">output_textually</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">filename</span><span class="plain"> *</span><span class="identifier">output_binarily</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">filename</span><span class="plain"> *</span><span class="identifier">unit_test_file</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">dictionary</span><span class="plain"> *</span><span class="identifier">pipeline_vars</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">filename</span><span class="plain"> *</span><span class="identifier">pipeline_as_file</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">pipeline_as_text</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">int</span><span class="plain"> </span><span class="functiontext">main</span><span class="plain">(</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">argc</span><span class="plain">, </span><span class="reserved">char</span><span class="plain"> **</span><span class="identifier">argv</span><span class="plain">) {</span>
<span class="functiontext">Foundation::start</span><span class="plain">();</span>
<span class="functiontext">InterModule::start</span><span class="plain">();</span>
@ -39,8 +50,12 @@
<span class="identifier">L</span><span class="string">"write to file X in textual format"</span><span class="plain">);</span>
<span class="functiontext">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">BINARY_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"binary"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"write to file X in binary format"</span><span class="plain">);</span>
<span class="functiontext">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">INTER_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"inter"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"specify code-generation chain for inter code"</span><span class="plain">);</span>
<span class="functiontext">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">PIPELINE_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"pipeline"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"specify pipeline textually"</span><span class="plain">);</span>
<span class="functiontext">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">PIPELINE_FILE_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"pipeline-file"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"specify pipeline from file X"</span><span class="plain">);</span>
<span class="functiontext">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">PIPELINE_VARIABLE_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"variable"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"set pipeline variable X (in form name=value)"</span><span class="plain">);</span>
<span class="functiontext">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">TEMPLATE_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"template"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"specify folder holding i6t template files"</span><span class="plain">);</span>
<span class="functiontext">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">TEST_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"test"</span><span class="plain">, 2,</span>
@ -48,6 +63,8 @@
<span class="functiontext">CommandLine::declare_switch</span><span class="plain">(</span><span class="constant">DOMAIN_CLSW</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"domain"</span><span class="plain">, 2,</span>
<span class="identifier">L</span><span class="string">"specify folder to read/write inter files from/to"</span><span class="plain">);</span>
<span class="identifier">pipeline_vars</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::basic_dictionary</span><span class="plain">(</span><span class="identifier">I</span><span class="string">"output.i6"</span><span class="plain">);</span>
<span class="functiontext">CommandLine::read</span><span class="plain">(</span><span class="identifier">argc</span><span class="plain">, </span><span class="identifier">argv</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">, &amp;</span><span class="functiontext">Main::respond</span><span class="plain">, &amp;</span><span class="functiontext">Main::add_file</span><span class="plain">);</span>
<span class="functiontext">Main::act</span><span class="plain">();</span>
@ -69,20 +86,28 @@
<pre class="display">
<span class="reserved">pathname</span><span class="plain"> *</span><span class="identifier">template_path</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">pathname</span><span class="plain"> *</span><span class="identifier">domain_path</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">filename</span><span class="plain"> *</span><span class="identifier">output_textually</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">filename</span><span class="plain"> *</span><span class="identifier">output_binarily</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">filename</span><span class="plain"> *</span><span class="identifier">unit_test_file</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">inter_processing_chain</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">;</span>
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">Main::respond</span><span class="plain">(</span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">id</span><span class="plain">, </span><span class="reserved">int</span><span class="plain"> </span><span class="identifier">val</span><span class="plain">, </span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">arg</span><span class="plain">, </span><span class="reserved">void</span><span class="plain"> *</span><span class="identifier">state</span><span class="plain">) {</span>
<span class="reserved">switch</span><span class="plain"> (</span><span class="identifier">id</span><span class="plain">) {</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">TEXTUAL_CLSW</span><span class="plain">: </span><span class="identifier">output_textually</span><span class="plain"> = </span><span class="functiontext">Filenames::from_text</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">BINARY_CLSW</span><span class="plain">: </span><span class="identifier">output_binarily</span><span class="plain"> = </span><span class="functiontext">Filenames::from_text</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="identifier">inter_processing_chain</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">; </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">INTER_CLSW</span><span class="plain">: </span><span class="identifier">inter_processing_chain</span><span class="plain"> = </span><span class="functiontext">Str::duplicate</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">DOMAIN_CLSW</span><span class="plain">: </span><span class="identifier">domain_path</span><span class="plain"> = </span><span class="functiontext">Pathnames::from_text</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="identifier">inter_processing_chain</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">; </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">TEMPLATE_CLSW</span><span class="plain">: </span><span class="identifier">template_path</span><span class="plain"> = </span><span class="functiontext">Pathnames::from_text</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="identifier">inter_processing_chain</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">; </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">BINARY_CLSW</span><span class="plain">: </span><span class="identifier">output_binarily</span><span class="plain"> = </span><span class="functiontext">Filenames::from_text</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="identifier">pipeline_as_text</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">; </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">PIPELINE_CLSW</span><span class="plain">: </span><span class="identifier">pipeline_as_text</span><span class="plain"> = </span><span class="functiontext">Str::duplicate</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">PIPELINE_FILE_CLSW</span><span class="plain">: </span><span class="identifier">pipeline_as_file</span><span class="plain"> = </span><span class="functiontext">Filenames::from_text</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">PIPELINE_VARIABLE_CLSW</span><span class="plain">: {</span>
<span class="reserved">match_results</span><span class="plain"> </span><span class="identifier">mr</span><span class="plain"> = </span><span class="functiontext">Regexp::create_mr</span><span class="plain">();</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Regexp::match</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">, </span><span class="identifier">arg</span><span class="plain">, </span><span class="identifier">L</span><span class="string">"(%c+)=(%c+)"</span><span class="plain">)) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Str::get_first_char</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">) != </span><span class="character">'*'</span><span class="plain">) {</span>
<span class="functiontext">Errors::fatal</span><span class="plain">(</span><span class="string">"-variable names must begin with '*'"</span><span class="plain">);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="functiontext">Str::copy</span><span class="plain">(</span><span class="functiontext">Dictionaries::create_text</span><span class="plain">(</span><span class="identifier">pipeline_vars</span><span class="plain">, </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[0]), </span><span class="identifier">mr</span><span class="element">.exp</span><span class="plain">[1]);</span>
<span class="plain">}</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="functiontext">Errors::fatal</span><span class="plain">(</span><span class="string">"-variable should take the form 'name=value'"</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="functiontext">Regexp::dispose_of</span><span class="plain">(&amp;</span><span class="identifier">mr</span><span class="plain">);</span>
<span class="reserved">break</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">DOMAIN_CLSW</span><span class="plain">: </span><span class="identifier">domain_path</span><span class="plain"> = </span><span class="functiontext">Pathnames::from_text</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="identifier">pipeline_as_text</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">; </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">TEMPLATE_CLSW</span><span class="plain">: </span><span class="identifier">template_path</span><span class="plain"> = </span><span class="functiontext">Pathnames::from_text</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="identifier">pipeline_as_text</span><span class="plain"> = </span><span class="identifier">NULL</span><span class="plain">; </span><span class="reserved">break</span><span class="plain">;</span>
<span class="reserved">case</span><span class="plain"> </span><span class="constant">TEST_CLSW</span><span class="plain">: </span><span class="identifier">unit_test_file</span><span class="plain"> = </span><span class="functiontext">Filenames::from_text</span><span class="plain">(</span><span class="identifier">arg</span><span class="plain">); </span><span class="reserved">break</span><span class="plain">;</span>
<span class="plain">}</span>
<span class="plain">}</span>
@ -118,22 +143,27 @@
<pre class="display">
<span class="reserved">void</span><span class="plain"> </span><span class="functiontext">Main::act</span><span class="plain">(</span><span class="reserved">void</span><span class="plain">) {</span>
<span class="reserved">inter_repository</span><span class="plain"> *</span><span class="identifier">I</span><span class="plain"> = </span><span class="functiontext">Inter::create</span><span class="plain">(1, 32);</span>
<span class="reserved">inter_file</span><span class="plain"> *</span><span class="identifier">IF</span><span class="plain">;</span>
<span class="identifier">LOOP_OVER</span><span class="plain">(</span><span class="identifier">IF</span><span class="plain">, </span><span class="reserved">inter_file</span><span class="plain">)</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Inter::Binary::test_file</span><span class="plain">(</span><span class="identifier">IF</span><span class="plain">-</span><span class="element">&gt;inter_filename</span><span class="plain">))</span>
<span class="functiontext">Inter::Binary::read</span><span class="plain">(</span><span class="identifier">I</span><span class="plain">, </span><span class="identifier">IF</span><span class="plain">-</span><span class="element">&gt;inter_filename</span><span class="plain">);</span>
<span class="reserved">else</span>
<span class="functiontext">Inter::Textual::read</span><span class="plain">(</span><span class="identifier">I</span><span class="plain">, </span><span class="identifier">IF</span><span class="plain">-</span><span class="element">&gt;inter_filename</span><span class="plain">);</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">inter_processing_chain</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> ((</span><span class="identifier">pipeline_as_file</span><span class="plain">) || (</span><span class="identifier">pipeline_as_text</span><span class="plain">)) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">NUMBER_CREATED</span><span class="plain">(</span><span class="reserved">inter_file</span><span class="plain">) &gt; 0)</span>
<span class="functiontext">Errors::fatal</span><span class="plain">(</span><span class="string">"-pipeline and -pipeline-file cannot be combined with inter file parameters"</span><span class="plain">);</span>
<span class="reserved">int</span><span class="plain"> </span><span class="identifier">NO_FS_AREAS</span><span class="plain"> = 0;</span>
<span class="reserved">pathname</span><span class="plain"> *</span><span class="identifier">pathname_of_i6t_files</span><span class="plain">[1];</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">template_path</span><span class="plain">) { </span><span class="identifier">NO_FS_AREAS</span><span class="plain"> = 1; </span><span class="identifier">pathname_of_i6t_files</span><span class="plain">[0] = </span><span class="identifier">template_path</span><span class="plain">; }</span>
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">SS</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::parse</span><span class="plain">(</span><span class="identifier">inter_processing_chain</span><span class="plain">, </span><span class="identifier">I</span><span class="string">"output.i6"</span><span class="plain">);</span>
<span class="functiontext">CodeGen::Pipeline::run</span><span class="plain">(</span><span class="identifier">domain_path</span><span class="plain">, </span><span class="identifier">SS</span><span class="plain">, </span><span class="identifier">I</span><span class="plain">, </span><span class="identifier">NO_FS_AREAS</span><span class="plain">, </span><span class="identifier">pathname_of_i6t_files</span><span class="plain">, </span><span class="identifier">template_path</span><span class="plain">, </span><span class="identifier">NULL</span><span class="plain">);</span>
<span class="reserved">codegen_pipeline</span><span class="plain"> *</span><span class="identifier">SS</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">pipeline_as_file</span><span class="plain">) </span><span class="identifier">SS</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::parse_from_file</span><span class="plain">(</span><span class="identifier">pipeline_as_file</span><span class="plain">, </span><span class="identifier">pipeline_vars</span><span class="plain">);</span>
<span class="reserved">else</span><span class="plain"> </span><span class="identifier">SS</span><span class="plain"> = </span><span class="functiontext">CodeGen::Pipeline::parse</span><span class="plain">(</span><span class="identifier">pipeline_as_text</span><span class="plain">, </span><span class="identifier">pipeline_vars</span><span class="plain">);</span>
<span class="functiontext">CodeGen::Pipeline::run</span><span class="plain">(</span><span class="identifier">domain_path</span><span class="plain">, </span><span class="identifier">SS</span><span class="plain">, </span><span class="identifier">NO_FS_AREAS</span><span class="plain">, </span><span class="identifier">pathname_of_i6t_files</span><span class="plain">);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> </span><span class="reserved">if</span><span class="plain"> (</span><span class="identifier">unit_test_file</span><span class="plain">) {</span>
<span class="functiontext">UnitTests::run</span><span class="plain">(</span><span class="identifier">unit_test_file</span><span class="plain">);</span>
<span class="plain">} </span><span class="reserved">else</span><span class="plain"> {</span>
<span class="reserved">inter_repository</span><span class="plain"> *</span><span class="identifier">I</span><span class="plain"> = </span><span class="functiontext">Inter::create</span><span class="plain">(1, 32);</span>
<span class="reserved">inter_file</span><span class="plain"> *</span><span class="identifier">IF</span><span class="plain">;</span>
<span class="identifier">LOOP_OVER</span><span class="plain">(</span><span class="identifier">IF</span><span class="plain">, </span><span class="reserved">inter_file</span><span class="plain">) {</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="functiontext">Inter::Binary::test_file</span><span class="plain">(</span><span class="identifier">IF</span><span class="plain">-</span><span class="element">&gt;inter_filename</span><span class="plain">))</span>
<span class="functiontext">Inter::Binary::read</span><span class="plain">(</span><span class="identifier">I</span><span class="plain">, </span><span class="identifier">IF</span><span class="plain">-</span><span class="element">&gt;inter_filename</span><span class="plain">);</span>
<span class="reserved">else</span>
<span class="functiontext">Inter::Textual::read</span><span class="plain">(</span><span class="identifier">I</span><span class="plain">, </span><span class="identifier">IF</span><span class="plain">-</span><span class="element">&gt;inter_filename</span><span class="plain">);</span>
<span class="plain">}</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">output_textually</span><span class="plain">) {</span>
<span class="reserved">text_stream</span><span class="plain"> </span><span class="identifier">C_struct</span><span class="plain">; </span><span class="reserved">text_stream</span><span class="plain"> *</span><span class="identifier">OUT</span><span class="plain"> = &amp;</span><span class="identifier">C_struct</span><span class="plain">;</span>
<span class="reserved">if</span><span class="plain"> (</span><span class="identifier">STREAM_OPEN_TO_FILE</span><span class="plain">(</span><span class="identifier">OUT</span><span class="plain">, </span><span class="identifier">output_textually</span><span class="plain">, </span><span class="constant">UTF8_ENC</span><span class="plain">) == </span><span class="constant">FALSE</span><span class="plain">)</span>

View file

@ -1,281 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>P/io</title>
<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">
</head>
<body>
<!--Weave of 'P/cas' generated by 7-->
<ul class="crumbs"><li><a href="../webs.html">&#9733;</a></li><li><a href="index.html">inter 1</a></li><li><a href="index.html#P">Preliminaries</a></li><li><b>Chains and Stages</b></li></ul><p class="purpose">Sequences of named code-generation stages are called chains.</p>
<ul class="toc"><li><a href="#SP1">&#167;1. Stages and descriptions</a></li><li><a href="#SP3">&#167;3. The code-generation stages</a></li><li><a href="#SP14">&#167;14. Diagnostic or non-working stages</a></li></ul><hr class="tocbar">
<p class="inwebparagraph"><a id="SP1"></a><b>&#167;1. Stages and descriptions. </b>A processing stage is a step in code generation which acts on a repository
of inter in memory. Some stages change, add to or edit down that code, while
others leave it untouched but output a file based on it.
</p>
<p class="inwebparagraph">Each stage can see an entire repository of inter code at a time, and is
not restricted to working through it in sequence. Those which read in or write
out a file also have a filename supplied to them as a parameter, but there
are otherwise no configuration options. It's not possible to tell a stage
to work on one specific function alone, for example.
</p>
<p class="inwebparagraph">Stages are named, which are written without spaces, and conventionally use
hyphens: for example, <code class="display"><span class="extract">resolve-conditional-compilation</span></code>. Where a filename has
to be supplied, it appears after a colon. Thus <code class="display"><span class="extract">generate-inter:my.intert</span></code>
is a valid stage description.
</p>
<p class="inwebparagraph">A "chain" is a comma-separated list of stage descriptions, and represents a
sort of program to follow: memory inter is passed through each stage in turn.
The special stage <code class="display"><span class="extract">stop</span></code> halts processing of the chain midway. At present
this is only useful for making experimental edits to chain descriptions
to see what just the first half does, without deleting the second half of
the description.
</p>
<p class="inwebparagraph"><a id="SP2"></a><b>&#167;2. </b>There are three ways to use chains. One is from the command line of Inter:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">$ inter/Tangled/inter FILE -inter 'CHAIN'</span>
</pre>
<p class="inwebparagraph">The other is to use two experimental features of Inform. This sentence:
</p>
<blockquote>
<p>Use inter chain "STAGES".</p>
</blockquote>
<p class="inwebparagraph">replaces the chain normally used for code generation with the one supplied.
(This may very well cause the compiler not to produce viable code, of course.)
Equivalently, a replacement chain can be specified at the Inform 7 command line:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">$ inform7/Tangled/inform7 ... -inter 'CHAIN'</span>
</pre>
<p class="inwebparagraph">When using a chain within Inform, one further description syntax is allowed:
the filename <code class="display"><span class="extract">*</span></code> means "the filename Inform wants to use for the final
Inform 6 file".
</p>
<p class="inwebparagraph"><a id="SP3"></a><b>&#167;3. The code-generation stages. </b>The following are all experimental, and have probably not yet reached their
final form or names. But this briefly describes the stages which currently
exist in the code generator. In the description below, the "repository" is
the reservoir of memory inter code being worked on.
</p>
<p class="inwebparagraph">Although one thinks of code generation as a process of turning inter into
Inform 6, in fact it goes both ways, because we also have to read in
the "template" of standing Inform 6 code. The early code generation stages
convert the template from Inform 6 into inter, merging it with the inter
already produced by the front end of the compiler. The later stages then
turn this merged repository into Inform 6 code. (Routines in the template,
therefore, are converted out of Inform 6 and then back into it again. This
sounds inefficient but is surprisingly fast, and enables many optimisations.)
</p>
<p class="inwebparagraph"><a id="SP4"></a><b>&#167;4. </b><code class="display"><span class="extract">link:T</span></code> reads in the I6T template file T, converts it to inter in a very
basic way (creating many splats), and merges it with the repository. Splats
are the unhappiest of inter statements, simply including verbatim snippets
of Inform 6 code.
</p>
<p class="inwebparagraph"><a id="SP5"></a><b>&#167;5. </b><code class="display"><span class="extract">parse-linked-matter</span></code> examines the splats produced by linking and annotates
them by what they seem to want to do. For example,
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">splat &amp;"Global nitwit = 2;\n"</span>
</pre>
<p class="inwebparagraph">is recognised as an Inform 6 variable declaration, and annotated thus:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">splat GLOBAL &amp;"Global nitwit = 2;\n"</span>
</pre>
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP6"></a><b>&#167;6. </b><code class="display"><span class="extract">resolve-conditional-compilation</span></code> looks for splats arising from Inform 6
conditional compilation directives such as <code class="display"><span class="extract">#ifdef</span></code>, <code class="display"><span class="extract">#ifndef</span></code>, <code class="display"><span class="extract">#endif</span></code>;
it then detects whether the relevant symbols are defined, or looks at their
values, and deletes sections of code not to be compiled. At the end of this
stage, there are no conditional compilation splats left in the repository.
For example:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">constant MAGIC K_number = 16339</span>
<span class="plain">splat IFTRUE &amp;"#iftrue MAGIC == 16339;\n"</span>
<span class="plain">constant WIZARD K_number = 5</span>
<span class="plain">splat IFNOT &amp;"#ifnot;\n"</span>
<span class="plain">constant MUGGLE K_number = 0</span>
<span class="plain">splat ENDIF &amp;"#endif;\n"</span>
</pre>
<p class="inwebparagraph">is resolved to:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">constant MAGIC K_number = 16339</span>
<span class="plain">constant WIZARD K_number = 5</span>
</pre>
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP7"></a><b>&#167;7. </b><code class="display"><span class="extract">assimilate</span></code> aims to convert all remaining splats in the repository into
higher-level inter statements. For example,
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">splat STUB &amp;"#Stub Peach 0;\n"</span>
<span class="plain">splat ATTRIBUTE &amp;"Attribute marmorial;\n"</span>
</pre>
<p class="inwebparagraph">becomes:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">constant Peach K_unchecked_function = Peach_B __assimilated=1</span>
<span class="plain">property marmorial K_truth_state __assimilated=1 __attribute=1 __either_or=1</span>
</pre>
<p class="inwebparagraph">At the end of this stage, there should be no splats left in the repository,
and the linking process is complete.
</p>
<p class="inwebparagraph"><a id="SP8"></a><b>&#167;8. </b><code class="display"><span class="extract">make-identifiers-unique</span></code> looks for symbols marked with the <code class="display"><span class="extract">MAKE_NAME_UNIQUE</span></code>
flag (represented in textual form by an asterisk after its name), This flag
means that Inform wants the symbol name to be globally unique in the repository.
For example, if Inform generates the symbol name <code class="display"><span class="extract">fruit*</span></code>, it's really telling
the code generator that it eventually wants this to have a name which won't
collide with anything else.
</p>
<p class="inwebparagraph">What <code class="display"><span class="extract">make-identifiers-unique</span></code> does is to append <code class="display"><span class="extract">_U1</span></code>, <code class="display"><span class="extract">_U2</span></code>, ... to such
names across the repository. Thus <code class="display"><span class="extract">fruit*</span></code> might become <code class="display"><span class="extract">fruit_U176</span></code>, and it
is guaranteed that no other symbol has the same name.
</p>
<p class="inwebparagraph">This stage is needed because whereas the inter language has namespces, so
that the same name can mean different things in different parts of the
program, Inform 6 (mostly) does not. There cannot be two functions with the
same name in any I6 program, for example.
</p>
<p class="inwebparagraph">At the end of this stage, no symbol still has the <code class="display"><span class="extract">MAKE_NAME_UNIQUE</span></code> flag.
</p>
<p class="inwebparagraph"><a id="SP9"></a><b>&#167;9. </b><code class="display"><span class="extract">reconcile-verbs</span></code> is a short stage looking for clashes between any verbs (in
the parser interactive fiction sense) which have been assimilated from the
template, and verbs which have been defined in the main source text. For
example, suppose the source creates the command verb "abstract": this would
collide with the command meta-verb "abstract", intended for debugging, which
appears in the template. What this stage does is to detect such problems,
and if it finds one, to prefix the template verb with <code class="display"><span class="extract">!</span></code>. Thus we would end
up with two command verbs: <code class="display"><span class="extract">abstract</span></code>, with its source text meaning, and
<code class="display"><span class="extract">!abstract</span></code>, with its template meaning.
</p>
<p class="inwebparagraph">At the end of this stage, all parser verbs have distinct textual forms.
</p>
<p class="inwebparagraph"><a id="SP10"></a><b>&#167;10. </b><code class="display"><span class="extract">eliminate-redundant-labels</span></code> performs peephole optimisation on all of
the functions in the repository to remove all labels which are declared
but can never be jumped to.
</p>
<p class="inwebparagraph">At the end of this stage, all labels inside functions are targets of some
branch, either by <code class="display"><span class="extract">inv !jump</span></code> or in assembly language.
</p>
<p class="inwebparagraph"><a id="SP11"></a><b>&#167;11. </b><code class="display"><span class="extract">generate-inter:F</span></code> writes out the repository as a textual inter file <code class="display"><span class="extract">F</span></code>.
(By default, Inform doesn't do this: the inter ordinarily stays in memory
throughout.)
</p>
<p class="inwebparagraph">This stage leaves the repository unchanged.
</p>
<p class="inwebparagraph"><a id="SP12"></a><b>&#167;12. </b><code class="display"><span class="extract">generate-inter-binary:F</span></code> writes out the repository as a binary inter
file <code class="display"><span class="extract">F</span></code>. (By default, Inform doesn't do this: the inter ordinarily stays in
memory throughout.)
</p>
<p class="inwebparagraph">This stage leaves the repository unchanged.
</p>
<p class="inwebparagraph"><a id="SP13"></a><b>&#167;13. </b><code class="display"><span class="extract">generate-i6:F</span></code> translates the repository to an Inform 6 program. This is
normally the final stage in the Inform code generation chain.
</p>
<p class="inwebparagraph">This stage leaves the repository unchanged.
</p>
<p class="inwebparagraph"><a id="SP14"></a><b>&#167;14. Diagnostic or non-working stages. </b></p>
<p class="inwebparagraph"><a id="SP15"></a><b>&#167;15. </b><code class="display"><span class="extract">show-dependencies:F</span></code> and <code class="display"><span class="extract">log-dependencies</span></code> output a dependency graph of
the symbols in the current repository, one to a file, the other to the
debugging log. A dependency means that one can't be compiled without the
other: for example, if a function has a local variable of a given kind, then
the function depends on that kind.
</p>
<p class="inwebparagraph"><code class="display"><span class="extract">eliminate-redundant-code</span></code> is a stage which removes all material from
the repository which the main routine is not dependent on. This can result
in many template routines being kicked out, and substantially reduces
story file sizes. The stage mostly works, but needs more refinement before
we could safely enable it by default with Inform.
</p>
<p class="inwebparagraph"><a id="SP16"></a><b>&#167;16. </b><code class="display"><span class="extract">summarise:F</span></code> is a very slow diagnostic stage showing the breakdown of the
current repository into packages, writing the output to file <code class="display"><span class="extract">F</span></code>. (Slow in
this sense means that it roughly triples compilation time.)
</p>
<p class="inwebparagraph"><a id="SP17"></a><b>&#167;17. </b><code class="display"><span class="extract">export:F</span></code> and <code class="display"><span class="extract">import:F</span></code> were part of an experiment to do with caching the
inter generated by the Standard Rules. This eventually worked, but was put on
ice while a better and more systematic solution was found.
</p>
<hr class="tocbar">
<ul class="toc"><li><a href="P-io.html">Back to 'Inform Organisation'</a></li><li><i>(This section ends Preliminaries.)</i></li></ul><hr class="tocbar">
<!--End of weave-->
</body>
</html>

View file

@ -204,7 +204,7 @@ possible, function packages are self-contained.
<p class="inwebparagraph"></p>
<hr class="tocbar">
<ul class="toc"><li><a href="P-ia.html">Back to 'Inform Annotations'</a></li><li><a href="P-cas.html">Continue with 'Chains and Stages'</a></li></ul><hr class="tocbar">
<ul class="toc"><li><a href="P-ia.html">Back to 'Inform Annotations'</a></li><li><a href="P-pas.html">Continue with 'Pipelines and Stages'</a></li></ul><hr class="tocbar">
<!--End of weave-->
</body>
</html>

400
docs/inter/P-pas.html Normal file
View file

@ -0,0 +1,400 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>P/io</title>
<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">
</head>
<body>
<!--Weave of 'P/pas' generated by 7-->
<ul class="crumbs"><li><a href="../webs.html">&#9733;</a></li><li><a href="index.html">inter 1</a></li><li><a href="index.html#P">Preliminaries</a></li><li><b>Pipelines and Stages</b></li></ul><p class="purpose">Sequences of named code-generation stages are called pipelines.</p>
<ul class="toc"><li><a href="#SP1">&#167;1. Stages and descriptions</a></li><li><a href="#SP3">&#167;3. Pipelines run by Inform</a></li><li><a href="#SP4">&#167;4. Reading and generating</a></li><li><a href="#SP5">&#167;5. The code-generation stages</a></li></ul><hr class="tocbar">
<p class="inwebparagraph"><a id="SP1"></a><b>&#167;1. Stages and descriptions. </b>A processing stage is a step in code generation which acts on a repository
of inter in memory. Some stages change, add to or edit down that code, while
others leave it untouched but output a file based on it.
</p>
<p class="inwebparagraph">Each stage can see an entire repository of inter code at a time, and is
not restricted to working through it in sequence.
</p>
<p class="inwebparagraph">Stages are named, which are written without spaces, and conventionally use
hyphens: for example, <code class="display"><span class="extract">resolve-conditional-compilation</span></code>. Where a filename has
to be supplied, it appears after a colon. Thus <code class="display"><span class="extract">generate-inter:my.intert</span></code>
is a valid stage description.
</p>
<p class="inwebparagraph">A "pipeline" is a list of stage descriptions. If the pipeline is spelled
out textually on the command line, then commas are used to divide the stages:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">$ inter/Tangled/inter -pipeline 'plugh, xyzzy, plover'</span>
</pre>
<p class="inwebparagraph">If the pipeline is in an external file, then one stage should appear on
each line, and the comma is not needed:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">plugh</span>
<span class="plain">xyzzy</span>
<span class="plain">plover</span>
</pre>
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP2"></a><b>&#167;2. </b>A pipeline can work on up to 10 different repositories, called <code class="display"><span class="extract">0</span></code> to <code class="display"><span class="extract">9</span></code>,
which are initially empty (but see below).
</p>
<p class="inwebparagraph">A pipeline description can make use of "variables". These hold only text,
and generally represent filenames. Variable names begin with a star <code class="display"><span class="extract">*</span></code>.
The pipeline cannot create variables: instead, the user of the pipeline has
to make them before use. For example,
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">$ inter/Tangled/inter -variable '*X=ex/why' -pipeline-file mypl.interpipeline</span>
</pre>
<p class="inwebparagraph">creates the variable <code class="display"><span class="extract">*X</span></code> with the textual contents <code class="display"><span class="extract">ex/why</span></code> before running
the given pipeline. Inside the pipeline, a line such as:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">generate: inform6 -&gt; *X</span>
</pre>
<p class="inwebparagraph">would then be read as:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">generate: inform6 -&gt; ex/why</span>
</pre>
<p class="inwebparagraph">After variable substitution like this, filenames inside the pipeline
description are interpreted as follows:
</p>
<p class="inwebparagraph"></p>
<ul class="items"><li>(a) If a filename contains a slash character, it is considered a literal
filename.
</li><li>(b) If not, it is considered to be a leafname inside the "domain" directory.
By default this is the current working directory, but using <code class="display"><span class="extract">-domain</span></code> at
the Inter command line changes that.
</li></ul>
<p class="inwebparagraph">The special variable <code class="display"><span class="extract">*log</span></code>, which always exists, means the debugging log.
A command to write a text file to <code class="display"><span class="extract">*log</span></code> is interpreted instead to mean
"spool the output you would otherwise write to the debugging log instead".
For example,
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">generate: inventory -&gt; *log</span>
</pre>
<p class="inwebparagraph">Template filenames are a little different: those are searched for inside
a path of possible directories. By default there's no such path, but using
<code class="display"><span class="extract">-template T</span></code> at the Inter command line gives a path of just one directory.
</p>
<p class="inwebparagraph"><a id="SP3"></a><b>&#167;3. Pipelines run by Inform. </b>As the above implies, Inter pipelines normally begin with a clean slate:
no repositories, no variables.
</p>
<p class="inwebparagraph">When a pipeline is being run by the main Inform 7 compiler, however,
repository <code class="display"><span class="extract">0</span></code> will be preloaded with the inter code Inform has generated
in memory. The variable <code class="display"><span class="extract">*out</span></code> is set to the filename to which final I6 code
needs to be written, and the "domain" is the directory containing that.
The template search path is set to the one used in Inform, that is, the
template file <code class="display"><span class="extract">Whatever.i6t</span></code> would be looked for first in the project's
<code class="display"><span class="extract">X.materials/I6T</span></code> directory, then in the user's <code class="display"><span class="extract">I6T</span></code> directory, and failing
that in Inform's built-in one.
</p>
<p class="inwebparagraph">The pipeline is itself looked for in the same way. If you have a project
called <code class="display"><span class="extract">Strange.inform</span></code>, then Inform first looks for
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">Strange.materials/Inter/default.interpipeline</span>
</pre>
<p class="inwebparagraph">If it can't find this file, it next looks for <code class="display"><span class="extract">default.interpipeline</span></code> in
the user's folder, and then in Inform's built-in one. If you're curious to
read the pipeline normally used by a shipping version of Inform, the file
can be found here in the Github repository for Inform:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">inform7/Internal/Inter/default.interpipeline</span>
</pre>
<p class="inwebparagraph">The best way to change the pipeline, then, is to put a new file in the
project's Materials folder. But there are also two other ways.
</p>
<p class="inwebparagraph">1. This sentence:
</p>
<blockquote>
<p>Use inter pipeline "PIPELINE".</p>
</blockquote>
<p class="inwebparagraph">replaces the pipeline normally used for code generation with the one supplied.
(That may very well cause the compiler not to produce viable code, of course.)
</p>
<p class="inwebparagraph">2. A replacement pipeline can be specified at the Inform 7 command line:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">$ inform7/Tangled/inform7 ... -pipeline 'PIPELINE'</span>
</pre>
<p class="inwebparagraph">Exactly as with Inter, Inform 7 also responds to <code class="display"><span class="extract">-pipeline-file</span></code>:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">$ inform7/Tangled/inform7 ... -pipeline-file FILE</span>
</pre>
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP4"></a><b>&#167;4. Reading and generating. </b>The <code class="display"><span class="extract">read</span></code> stage reads Inter from a file into a repository in memory.
(Its previous contents, if any, are discarded.) This then becomes the
repository to which subsequent stages apply. The format is:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">read REPOSITORY &lt;- FILE</span>
</pre>
<p class="inwebparagraph">where <code class="display"><span class="extract">REPOSITORY</span></code> is <code class="display"><span class="extract">0</span></code> to <code class="display"><span class="extract">9</span></code>. Conventionally, we use <code class="display"><span class="extract">0</span></code> most of the time.
The <code class="display"><span class="extract">FILE</span></code> can contain either binary or textual Inter, and this is
automatically detected.
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">generate: FORMAT -&gt; FILE</span>
</pre>
<p class="inwebparagraph">writes the contents of the current repository out into the given <code class="display"><span class="extract">FILE</span></code>.
There are several possible formats: <code class="display"><span class="extract">binary</span></code> and <code class="display"><span class="extract">text</span></code> mean a binary or
textual Inter file, <code class="display"><span class="extract">inventory</span></code> means a textual summary of the contents,
and <code class="display"><span class="extract">inform6</span></code> means an Inform 6 program.
</p>
<p class="inwebparagraph">The <code class="display"><span class="extract">generate</span></code> stage leaves the repository unchanged, so it's possible
to generate multiple representations of the same repository into different
files.
</p>
<p class="inwebparagraph"><a id="SP5"></a><b>&#167;5. The code-generation stages. </b>The following are all experimental, and have probably not yet reached their
final form or names.
</p>
<p class="inwebparagraph">Although one thinks of code generation as a process of turning inter into
Inform 6, in fact it goes both ways, because we also have to read in
the "template" of standing Inform 6 code. The early code generation stages
convert the template from Inform 6 into inter, merging it with the inter
already produced by the front end of the compiler. The later stages then
turn this merged repository into Inform 6 code. (Routines in the template,
therefore, are converted out of Inform 6 and then back into it again. This
sounds inefficient but is surprisingly fast, and enables many optimisations.)
</p>
<p class="inwebparagraph"><a id="SP6"></a><b>&#167;6. </b><code class="display"><span class="extract">link:T</span></code> reads in the I6T template file T, converts it to inter in a very
basic way (creating many splats), and merges it with the repository. Splats
are the unhappiest of inter statements, simply including verbatim snippets
of Inform 6 code.
</p>
<p class="inwebparagraph"><a id="SP7"></a><b>&#167;7. </b><code class="display"><span class="extract">parse-linked-matter</span></code> examines the splats produced by linking and annotates
them by what they seem to want to do. For example,
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">splat &amp;"Global nitwit = 2;\n"</span>
</pre>
<p class="inwebparagraph">is recognised as an Inform 6 variable declaration, and annotated thus:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">splat GLOBAL &amp;"Global nitwit = 2;\n"</span>
</pre>
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP8"></a><b>&#167;8. </b><code class="display"><span class="extract">resolve-conditional-compilation</span></code> looks for splats arising from Inform 6
conditional compilation directives such as <code class="display"><span class="extract">#ifdef</span></code>, <code class="display"><span class="extract">#ifndef</span></code>, <code class="display"><span class="extract">#endif</span></code>;
it then detects whether the relevant symbols are defined, or looks at their
values, and deletes sections of code not to be compiled. At the end of this
stage, there are no conditional compilation splats left in the repository.
For example:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">constant MAGIC K_number = 16339</span>
<span class="plain">splat IFTRUE &amp;"#iftrue MAGIC == 16339;\n"</span>
<span class="plain">constant WIZARD K_number = 5</span>
<span class="plain">splat IFNOT &amp;"#ifnot;\n"</span>
<span class="plain">constant MUGGLE K_number = 0</span>
<span class="plain">splat ENDIF &amp;"#endif;\n"</span>
</pre>
<p class="inwebparagraph">is resolved to:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">constant MAGIC K_number = 16339</span>
<span class="plain">constant WIZARD K_number = 5</span>
</pre>
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP9"></a><b>&#167;9. </b><code class="display"><span class="extract">assimilate</span></code> aims to convert all remaining splats in the repository into
higher-level inter statements. For example,
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">splat STUB &amp;"#Stub Peach 0;\n"</span>
<span class="plain">splat ATTRIBUTE &amp;"Attribute marmorial;\n"</span>
</pre>
<p class="inwebparagraph">becomes:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">constant Peach K_unchecked_function = Peach_B __assimilated=1</span>
<span class="plain">property marmorial K_truth_state __assimilated=1 __attribute=1 __either_or=1</span>
</pre>
<p class="inwebparagraph">At the end of this stage, there should be no splats left in the repository,
and the linking process is complete.
</p>
<p class="inwebparagraph"><a id="SP10"></a><b>&#167;10. </b><code class="display"><span class="extract">make-identifiers-unique</span></code> looks for symbols marked with the <code class="display"><span class="extract">MAKE_NAME_UNIQUE</span></code>
flag (represented in textual form by an asterisk after its name), This flag
means that Inform wants the symbol name to be globally unique in the repository.
For example, if Inform generates the symbol name <code class="display"><span class="extract">fruit*</span></code>, it's really telling
the code generator that it eventually wants this to have a name which won't
collide with anything else.
</p>
<p class="inwebparagraph">What <code class="display"><span class="extract">make-identifiers-unique</span></code> does is to append <code class="display"><span class="extract">_U1</span></code>, <code class="display"><span class="extract">_U2</span></code>, ... to such
names across the repository. Thus <code class="display"><span class="extract">fruit*</span></code> might become <code class="display"><span class="extract">fruit_U176</span></code>, and it
is guaranteed that no other symbol has the same name.
</p>
<p class="inwebparagraph">This stage is needed because whereas the inter language has namespces, so
that the same name can mean different things in different parts of the
program, Inform 6 (mostly) does not. There cannot be two functions with the
same name in any I6 program, for example.
</p>
<p class="inwebparagraph">At the end of this stage, no symbol still has the <code class="display"><span class="extract">MAKE_NAME_UNIQUE</span></code> flag.
</p>
<p class="inwebparagraph"><a id="SP11"></a><b>&#167;11. </b><code class="display"><span class="extract">reconcile-verbs</span></code> is a short stage looking for clashes between any verbs (in
the parser interactive fiction sense) which have been assimilated from the
template, and verbs which have been defined in the main source text. For
example, suppose the source creates the command verb "abstract": this would
collide with the command meta-verb "abstract", intended for debugging, which
appears in the template. What this stage does is to detect such problems,
and if it finds one, to prefix the template verb with <code class="display"><span class="extract">!</span></code>. Thus we would end
up with two command verbs: <code class="display"><span class="extract">abstract</span></code>, with its source text meaning, and
<code class="display"><span class="extract">!abstract</span></code>, with its template meaning.
</p>
<p class="inwebparagraph">At the end of this stage, all parser verbs have distinct textual forms.
</p>
<p class="inwebparagraph"><a id="SP12"></a><b>&#167;12. </b><code class="display"><span class="extract">eliminate-redundant-code</span></code> deletes all packages which Inter can prove
will not be used in the final code generated from the repository. For
example, functions never called, or arrays never referred to, are deleted.
</p>
<p class="inwebparagraph"><a id="SP13"></a><b>&#167;13. </b><code class="display"><span class="extract">eliminate-redundant-labels</span></code> performs peephole optimisation on all of
the functions in the repository to remove all labels which are declared
but can never be jumped to.
</p>
<p class="inwebparagraph">At the end of this stage, all labels inside functions are targets of some
branch, either by <code class="display"><span class="extract">inv !jump</span></code> or in assembly language.
</p>
<p class="inwebparagraph"><a id="SP14"></a><b>&#167;14. </b>The special stage <code class="display"><span class="extract">stop</span></code> halts processing of the pipeline midway. At present
this is only useful for making experimental edits to pipeline descriptions
to see what just the first half does, without deleting the second half of
the description.
</p>
<hr class="tocbar">
<ul class="toc"><li><a href="P-io.html">Back to 'Inform Organisation'</a></li><li><i>(This section ends Preliminaries.)</i></li></ul><hr class="tocbar">
<!--End of weave-->
</body>
</html>

View file

@ -30,17 +30,22 @@ or for future applications of inter code.
<p class="inwebparagraph"><a id="SP2"></a><b>&#167;2. Command-line usage. </b>If you have compiled the standard distribution of the command-line tools
for Inform then the Inter executable will be at <code class="display"><span class="extract">inter/Tangled/inter</span></code>.
The usage is:
</p>
<p class="inwebparagraph">Inter has three basic modes. In the first, the command line specifies only
a single file:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">$ inter/Tangled/inter FILE1 FILE2 ... [OPTIONS]</span>
<span class="plain">$ inter/Tangled/inter INTERFILE</span>
</pre>
<p class="inwebparagraph">Though multiple files can be supplied, it's usual to supply just one.
<p class="inwebparagraph">Inter simply verifies this file for correctness: that is, to see if the inter
code supplied conforms to the inter specification. It returns the exit code 0
if all is well, and issues error messages and returns 1 if not.
</p>
<p class="inwebparagraph">Such files can be in either textual or binary form, and Inter automatically
@ -49,13 +54,7 @@ have the filename extension <code class="display"><span class="extract">.intert<
not how Inter decides.)
</p>
<p class="inwebparagraph"><a id="SP3"></a><b>&#167;3. </b>Inter has three basic modes. In the first, when no options are supplied,
Inter simply verifies its input for correctness: that is, to see if the inter
code supplied conforms to the inter specification. It returns the exit code 0
if all is well, and issues error messages and returns 1 if not.
</p>
<p class="inwebparagraph"><a id="SP4"></a><b>&#167;4. </b>In the second mode, Inter converts from textual to binary form or vice
<p class="inwebparagraph"><a id="SP3"></a><b>&#167;3. </b>In the second mode, Inter converts from textual to binary form or vice
versa. The option <code class="display"><span class="extract">-binary X</span></code> writes a binary form of the inter to file <code class="display"><span class="extract">X</span></code>,
and <code class="display"><span class="extract">-textual X</span></code> writes a text form. So, for example,
</p>
@ -80,49 +79,73 @@ and <code class="display"><span class="extract">-textual X</span></code> writes
<p class="inwebparagraph"></p>
<p class="inwebparagraph"><a id="SP5"></a><b>&#167;5. </b>In the third and most flexible mode, Inter runs the supplied code through
a "chain" of processing stages. The chain, which must contain at least
one stage, is a textual list of comma-separated stage names. For example,
<p class="inwebparagraph"><a id="SP4"></a><b>&#167;4. </b>In the third and most flexible mode, Inter runs the supplied code through
a pipeline of processing stages. The pipeline, which must contain at least
one stage, can be quite elaborate (see later), but for example:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">resolve-conditional-compilation,assimilate,make-identifiers-unique</span>
<span class="plain">read: 0 &lt;- myfile.inter, resolve-conditional-compilation, generate: inform6 -&gt; myfile.i6</span>
</pre>
<p class="inwebparagraph">is a valid three-stage chain. The command to do this is then:
<p class="inwebparagraph">is a valid three-stage pipeline. The command to do this is then:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">$ inter/Tangled/inter my.intert -inter 'CHAIN'</span>
<span class="plain">$ inter/Tangled/inter -pipeline 'PIPELINE'</span>
</pre>
<p class="inwebparagraph">where <code class="display"><span class="extract">CHAIN</span></code> is the chain description.
</p>
<p class="inwebparagraph">In practice, this will only be useful if you can access the result, so it's
normal for the final stage to output something: perhaps Inform 6 code, perhaps
textual inter. For example:
<p class="inwebparagraph">where <code class="display"><span class="extract">PIPELINE</span></code> is a textual description like the one above. In practice,
it may not be convenient to spell the pipeline out on the command line, so
one can also put it into a text file:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">$ inter/Tangled/inter in.intert -inter 'parse-linked-matter, generate-inter:out.intert'</span>
<span class="plain">$ inter/Tangled/inter -pipeline-file mypl.interpipeline</span>
</pre>
<p class="inwebparagraph">Two more options may be helpful to supplement this: <code class="display"><span class="extract">-domain D</span></code> sets the
directory <code class="display"><span class="extract">D</span></code> to be the default location for reading and writing inter files;
and <code class="display"><span class="extract">-template T</span></code> tells Inter that it can find the I6T template files at
the file system location <code class="display"><span class="extract">T</span></code>. (Some code-generation stages import these.)
<p class="inwebparagraph">Pipelines can contain variables, and their values can be set at the command
line with e.g.:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">-variable '*out=myfile.i6'</span>
</pre>
<p class="inwebparagraph">It is also possible to set the default directory for reading and writing files:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">-domain D</span>
</pre>
<p class="inwebparagraph">Finally, we can tell Inter where to find I6T template files:
</p>
<p class="inwebparagraph"></p>
<pre class="display">
<span class="plain">-template T</span>
</pre>
<p class="inwebparagraph"></p>
<hr class="tocbar">
<ul class="toc"><li><i>(This section begins Preliminaries.)</i></li><li><a href="P-ti.html">Continue with 'Textual Inter'</a></li></ul><hr class="tocbar">
<!--End of weave-->

View file

@ -44,8 +44,8 @@
<span class="purpose">The standard hierarchy of inter code generated by Inform.</span></p>
</li>
<li>
<p><a href="P-cas.html"><spon class="sectiontitle">Chains and Stages</span></a> -
<span class="purpose">Sequences of named code-generation stages are called chains.</span></p>
<p><a href="P-pas.html"><spon class="sectiontitle">Pipelines and Stages</span></a> -
<span class="purpose">Sequences of named code-generation stages are called pipelines.</span></p>
</li>
</ul>
</li>

View file

@ -0,0 +1,8 @@
link: Output.i6t
parse-linked-matter
resolve-conditional-compilation
assimilate
make-identifiers-unique
resolve-external-symbols
reconcile-verbs
generate: inform6 -> *out

View file

@ -1,42 +0,0 @@
Moon is a room. A rock is a thing.
To present (decider - a phrase nothing -> truth state):
showme the decider.
An astronaut is a kind of person.
Jet is an astronaut in the Moon.
Doc is an astronaut in the Moon.
Doc can be calm, agitated or solemn.
The Decontamination Station is a room. A control panel is here. "Three
buttons -- red, blue, and green -- adorn the control panel in front of you.
A sign above the buttons reads: CAUTION: RADIATION PURGE."
A red button is part of the control panel. A green button is part of the
control panel. A blue button is part of the control panel.
The lower levels is a region. The access tunnels is a region. The
residential bays is a region.
 
Purging something is an activity.
 
Before purging a region (called the purged area), say "Initiating purge
protocols in [the purged area]..."
 
Rule for purging the lower levels: say "The lower levels have been purged."
Rule for purging the access tunnels: say "The access tunnels have been purged."
Rule for purging the residential bays: say "The residential bays have been purged."
 
After purging a region: say "Purge complete."
 
Instead of pushing the red button, carry out the purging activity with the lower levels.
Instead of pushing the green button, carry out the purging activity with the access tunnels.
Instead of pushing the blue button, carry out the purging activity with the residential bays. 
 
Test me with "push red / push blue / push green".
Eightball is a scene.
Eightball has a number called countervalue.

View file

@ -5,7 +5,6 @@
-set hash_cache 'inform7/Tests/hashes.intest'
-cases [Main] 'inform7/Tests/Test Cases'
! -cases [Inter] 'inform7/Tests/Test Inter'
-if osx -cases [Index] 'inform7/Tests/Test Index'
-if osx -cases [Map] 'inform7/Tests/Test Maps'
-if osx -cases [Release] 'inform7/Tests/Test Releases'
@ -80,7 +79,7 @@
set: $SRINTERB = inform7/Internal/I6T/sr-Z.interb
endif
set: $INTERCHAIN = link:Output.i6t,parse-linked-matter,resolve-conditional-compilation,assimilate,make-identifiers-unique,resolve-external-symbols,reconcile-verbs,generate:inform6->*
set: $PIPELINE = inform7/Tests/test-pl.interpipeline
! First, problem message cases, where we require ni to fail and with the
! correct output.
@ -88,7 +87,7 @@
if: $TYPE problem
set: $A = $PATH/_Results_Actual/$CASE.txt
set: $I = $PATH/_Results_Ideal/$CASE.txt
fail step: $I7 `$I7OPTIONS -require-problem $CASE -project $WORK/Example.inform -inter $INTERCHAIN >$A 2>&1
fail step: $I7 `$I7OPTIONS -require-problem $CASE -project $WORK/Example.inform -pipeline-file $PIPELINE >$A 2>&1
or: 'failed to produce its namesake Problem message' $A
show: $A
exists: $I
@ -101,7 +100,7 @@
! And then the general case.
set: $I7CONSOLE = $WORK/Example.inform/Build/i7_output.txt
step: $I7 `$I7OPTIONS -format=$FORMAT -project $WORK/Example.inform -inter $INTERCHAIN >$I7CONSOLE 2>&1
step: $I7 `$I7OPTIONS -format=$FORMAT -project $WORK/Example.inform -pipeline-file $PIPELINE >$I7CONSOLE 2>&1
or: 'failed with Problem message(s)' $I7CONSOLE
show: $I7CONSOLE
@ -266,69 +265,6 @@
-end
-recipe [Inter]
set: $I7 = inform7/Tangled/inform7
set: $INTER = inter/Tangled/inter
set: $INTERNAL = inform7/Internal
set: $WORKSPACE = intest/Workspace
! First we decide whether to compile it for the Z-machine or Glulx.
set: $VM = Z
if: $CASE %c*-G
set: $VM = G
endif
if: $CASE %c*Metric%c*Units%c*
set: $VM = G
endif
! On the basis of which:
if: $VM G
set: $FORMAT = ulx
else
set: $FORMAT = z8
endif
mkdir: $PATH/_Inter_Binary
mkdir: $PATH/_Inter_Textual
mkdir: $PATH/_Inter_Actual
mkdir: $PATH/_Inter_Ideal
! Now we extract the source text from whatever file originated the test
! case: this is a non-trivial operation when the file is an Extension or
! an example, but is a simple copy operation otherwise.
extract: $WORK/Example.inform/Source/story.ni $VM
set: $I7OPTIONS = -format=$FORMAT -noprogress -fixtime -rng -sigils -clock -log nothing -external inform7/Tests -transient $WORK/Transient -noindex -internal $INTERNAL
set: $INTERB = $PATH/_Inter_Binary/$CASE.interb
set: $INTERT = $PATH/_Inter_Textual/$CASE.intert
set: $INTERCHAIN = generate-inter:$INTERT,generate-inter-binary:$INTERB
set: $I7CONSOLE = $WORK/Example.inform/Build/i7_output.txt
step: $I7 `$I7OPTIONS -format=$FORMAT -project $WORK/Example.inform -inter $INTERCHAIN >$I7CONSOLE 2>&1
or: 'failed with Problem message(s)' $I7CONSOLE
set: $INTERA = $PATH/_Inter_Actual/$CASE.intert
set: $INTERI = $PATH/_Inter_Ideal/$CASE.intert
set: $INTERCONSOLE = $WORK/Example.inform/Build/inter_output.txt
step: $INTER $INTERB -textual $INTERA >$INTERCONSOLE 2>&1
or: 'failed to read inter' $INTERCONSOLE
show: $INTERCONSOLE
match text: $INTERA $INTERI
or: 'produced the wrong inter code'
show: $INTERA
pass: 'passed'
-end
-recipe [Release]
set: $I7 = inform7/Tangled/inform7

View file

@ -0,0 +1,8 @@
link: Output.i6t
parse-linked-matter
resolve-conditional-compilation
assimilate
make-identifiers-unique
resolve-external-symbols
reconcile-verbs
generate: inform6 -> *out

View file

@ -58,7 +58,8 @@ int indexing_stage = FALSE; /* Everything is done except indexing */
@ =
int report_clock_time = FALSE;
time_t right_now;
text_stream *inter_processing_chain = NULL;
text_stream *inter_processing_file = NULL;
text_stream *inter_processing_pipeline = NULL;
pathname *path_to_inform7 = NULL;
int CoreMain::main(int argc, char *argv[]) {
@ -97,7 +98,7 @@ int CoreMain::main(int argc, char *argv[]) {
@<Banner and startup@> =
Errors::set_internal_handler(&Problems::Issue::internal_error_fn);
story_filename_extension = I"ulx";
inter_processing_chain = I"link: Output.i6t, parse-linked-matter, resolve-conditional-compilation, assimilate, make-identifiers-unique, resolve-external-symbols, reconcile-verbs, generate: inform6 -> *";
inter_processing_pipeline = Str::new();
PRINT("%B build %B has started.\n", FALSE, TRUE);
STREAM_FLUSH(STDOUT);
@ -122,7 +123,8 @@ list is not exhaustive.
@e RNG_CLSW
@e SIGILS_CLSW
@e TRANSIENT_CLSW
@e INTER_CLSW
@e PIPELINE_CLSW
@e PIPELINE_FILE_CLSW
@<Register command-line arguments@> =
CommandLine::declare_heading(
@ -153,8 +155,10 @@ list is not exhaustive.
L"make any source links refer to the source in extension example X");
CommandLine::declare_switch(REQUIRE_PROBLEM_CLSW, L"require-problem", 2,
L"return 0 unless exactly this Problem message is generated (for testing)");
CommandLine::declare_switch(INTER_CLSW, L"inter", 2,
L"specify code-generation chain for inter code");
CommandLine::declare_switch(PIPELINE_CLSW, L"pipeline", 2,
L"specify code-generation pipeline");
CommandLine::declare_switch(PIPELINE_FILE_CLSW, L"pipeline-file", 2,
L"specify code-generation pipeline from file X");
CommandLine::declare_switch(PROJECT_CLSW, L"project", 2,
L"work within the Inform project X");
@ -390,13 +394,28 @@ with "Output.i6t".
LOG("Front end elapsed time: %dcs\n", ((int) (front_end - start)) / (CLOCKS_PER_SEC/100));
CoreMain::go_to_log_phase(I"Converting inter to Inform 6");
if (existing_story_file == FALSE) {
codegen_pipeline *SS = CodeGen::Pipeline::new();
CodeGen::Pipeline::parse_into(SS, inter_processing_chain,
dictionary *D = CodeGen::Pipeline::basic_dictionary(
Filenames::get_leafname(filename_of_compiled_i6_code));
codegen_pipeline *SS = NULL;
if (inter_processing_file)
SS = CodeGen::Pipeline::parse_from_file(Filenames::from_text(inter_processing_file), D);
else if (Str::len(inter_processing_pipeline) > 0)
SS = CodeGen::Pipeline::parse(inter_processing_pipeline, D);
else {
for (int area=0; area<NO_FS_AREAS; area++) {
pathname *P = pathname_of_inter_resources[area];
filename *F = Filenames::in_folder(P, I"default.interpipeline");
LOG("Trying %f\n", F);
if (TextFiles::exists(F)) {
SS = CodeGen::Pipeline::parse_from_file(F, D);
break;
}
}
}
if (SS == NULL) internal_error("no inter pipeline could be found");
CodeGen::Pipeline::set_repository(SS, Emit::repository());
CodeGen::Pipeline::run(Filenames::get_path_to(filename_of_compiled_i6_code),
SS, Emit::repository(), NO_FS_AREAS, pathname_of_i6t_files,
pathname_of_i6t_files[INTERNAL_FS_AREA],
pathname_of_i6t_files[INTERNAL_FS_AREA]);
SS, NO_FS_AREAS, pathname_of_i6t_files);
}
LOG("Back end elapsed time: %dcs\n", ((int) (clock() - front_end)) / (CLOCKS_PER_SEC/100));
}
@ -467,7 +486,8 @@ void CoreMain::switch(int id, int val, text_stream *arg, void *state) {
case FORMAT_CLSW: story_filename_extension = Str::duplicate(arg); break;
case CASE_CLSW: HTMLFiles::set_source_link_case(arg); break;
case REQUIRE_PROBLEM_CLSW: Problems::Fatal::require(arg); break;
case INTER_CLSW: inter_processing_chain = Str::duplicate(arg); break;
case PIPELINE_CLSW: inter_processing_pipeline = Str::duplicate(arg); break;
case PIPELINE_FILE_CLSW: inter_processing_file = Str::duplicate(arg); break;
/* Useful pathnames */
case PROJECT_CLSW: Locations::set_project(arg); break;
@ -488,10 +508,10 @@ void CoreMain::disable_importation(void) {
disable_import = TRUE;
}
void CoreMain::set_inter_chain(wording W) {
inter_processing_chain = Str::new();
WRITE_TO(inter_processing_chain, "%W", W);
Str::delete_first_character(inter_processing_chain);
Str::delete_last_character(inter_processing_chain);
LOG("Setting chain %S\n", inter_processing_chain);
void CoreMain::set_inter_pipeline(wording W) {
inter_processing_pipeline = Str::new();
WRITE_TO(inter_processing_pipeline, "%W", W);
Str::delete_first_character(inter_processing_pipeline);
Str::delete_last_character(inter_processing_pipeline);
LOG("Setting pipeline %S\n", inter_processing_pipeline);
}

View file

@ -24,6 +24,7 @@ char *AREA_NAME[3] = { "from .materials", "installed", "built in" };
pathname *pathname_of_area[NO_FS_AREAS] = { NULL, NULL, NULL };
pathname *pathname_of_extensions[NO_FS_AREAS] = { NULL, NULL, NULL };
pathname *pathname_of_i6t_files[NO_FS_AREAS] = { NULL, NULL, NULL };
pathname *pathname_of_inter_resources[NO_FS_AREAS] = { NULL, NULL, NULL };
pathname *pathname_of_languages[NO_FS_AREAS] = { NULL, NULL, NULL };
pathname *pathname_of_website_templates[NO_FS_AREAS] = { NULL, NULL, NULL };
@ -50,6 +51,7 @@ filename *filename_of_cblorb_report = NULL;
filename *filename_of_cblorb_report_model = NULL;
filename *filename_of_compiled_i6_code = NULL;
filename *filename_of_debugging_log = NULL;
filename *filename_of_default_inter_pipeline = NULL;
filename *filename_of_documentation_snippets = NULL;
filename *filename_of_epsfile = NULL;
filename *filename_of_existing_story_file = NULL;
@ -158,6 +160,11 @@ example, live inside the Extensions part of this.
Locations::EILT_at(INTERNAL_FS_AREA, pathname_of_area[INTERNAL_FS_AREA]);
pathname *inter_resources =
Pathnames::subfolder(pathname_of_area[INTERNAL_FS_AREA], I"Inter");
filename_of_default_inter_pipeline =
Filenames::in_folder(inter_resources, I"default.interpipeline");
@<Miscellaneous other stuff@>;
@ Most of these files are to help Inblorb to perform a release. The
@ -463,6 +470,7 @@ void Locations::EILT_at(int area, pathname *P) {
pathname_of_i6t_files[area] = Pathnames::subfolder(P, I"I6T");
pathname_of_languages[area] = Pathnames::subfolder(P, I"Languages");
pathname_of_website_templates[area] = Pathnames::subfolder(P, I"Templates");
pathname_of_inter_resources[area] = Pathnames::subfolder(P, I"Inter");
}
@h Location of extensions.

View file

@ -142,8 +142,8 @@ option name is taken from the |...| or |###| as appropriate:
<definite-article> ... | ==> 0
... ==> 0
<use-inter-chain> ::=
inter chain {<quoted-text>} ==> TRUE
<use-inter-pipeline> ::=
inter pipeline {<quoted-text>} ==> TRUE
@ These are use option names which Inform provides special support for; it
recognises the English names when they are defined by the Standard Rules. (So
@ -206,7 +206,7 @@ void UseOptions::set_use_options(parse_node *p) {
UseOptions::set_use_options(p->down->next);
return;
}
if (<use-inter-chain>(ParseTree::get_text(p))) @<Set the chain given in this word range@>
if (<use-inter-pipeline>(ParseTree::get_text(p))) @<Set the chain given in this word range@>
else if (<use-sentence-object>(ParseTree::get_text(p))) @<Set the option given in this word range@>;
if (traverse == 1) return;
LOG("Used: %W\n", ParseTree::get_text(p));
@ -239,8 +239,8 @@ void UseOptions::set_use_options(parse_node *p) {
}
@<Set the chain given in this word range@> =
wording CW = GET_RW(<use-inter-chain>, 1);
if (traverse == 1) CoreMain::set_inter_chain(CW);
wording CW = GET_RW(<use-inter-pipeline>, 1);
if (traverse == 1) CoreMain::set_inter_pipeline(CW);
return;
@<Adjust the minimum setting@> =

14
inter/.gitignore vendored
View file

@ -15,19 +15,9 @@ inter-module/Woven/
inter.mk
Tests/Assimilate/_Results_Actual/
Tests/Assimilate/_Console/
Tests/Generations/_Results_Actual/
Tests/Generations/_Console/
Tests/Graph/_Results_Actual/
Tests/Graph/_Console/
Tests/Invalid/_Results_Actual/
Tests/PLM/_Results_Actual/
Tests/PLM/_Console/
Tests/RCC/_Results_Actual/
Tests/RCC/_Console/
Tests/ERL/_Results_Actual/
Tests/ERL/_Console/
Tests/General/_Results_Actual/
Tests/General/_Console/
Tests/Valid/_Binary/
Tests/Valid/_Console/
Tests/Valid/_Textual/

View file

@ -7,12 +7,23 @@ this plan out.
@e TEXTUAL_CLSW
@e BINARY_CLSW
@e INTER_CLSW
@e PIPELINE_CLSW
@e PIPELINE_FILE_CLSW
@e PIPELINE_VARIABLE_CLSW
@e DOMAIN_CLSW
@e TEMPLATE_CLSW
@e TEST_CLSW
=
pathname *template_path = NULL;
pathname *domain_path = NULL;
filename *output_textually = NULL;
filename *output_binarily = NULL;
filename *unit_test_file = NULL;
dictionary *pipeline_vars = NULL;
filename *pipeline_as_file = NULL;
text_stream *pipeline_as_text = NULL;
int main(int argc, char **argv) {
Foundation::start();
InterModule::start();
@ -26,8 +37,12 @@ int main(int argc, char **argv) {
L"write to file X in textual format");
CommandLine::declare_switch(BINARY_CLSW, L"binary", 2,
L"write to file X in binary format");
CommandLine::declare_switch(INTER_CLSW, L"inter", 2,
L"specify code-generation chain for inter code");
CommandLine::declare_switch(PIPELINE_CLSW, L"pipeline", 2,
L"specify pipeline textually");
CommandLine::declare_switch(PIPELINE_FILE_CLSW, L"pipeline-file", 2,
L"specify pipeline from file X");
CommandLine::declare_switch(PIPELINE_VARIABLE_CLSW, L"variable", 2,
L"set pipeline variable X (in form name=value)");
CommandLine::declare_switch(TEMPLATE_CLSW, L"template", 2,
L"specify folder holding i6t template files");
CommandLine::declare_switch(TEST_CLSW, L"test", 2,
@ -35,6 +50,8 @@ int main(int argc, char **argv) {
CommandLine::declare_switch(DOMAIN_CLSW, L"domain", 2,
L"specify folder to read/write inter files from/to");
pipeline_vars = CodeGen::Pipeline::basic_dictionary(I"output.i6");
CommandLine::read(argc, argv, NULL, &Main::respond, &Main::add_file);
Main::act();
@ -48,20 +65,28 @@ int main(int argc, char **argv) {
}
@ =
pathname *template_path = NULL;
pathname *domain_path = NULL;
filename *output_textually = NULL;
filename *output_binarily = NULL;
filename *unit_test_file = NULL;
text_stream *inter_processing_chain = NULL;
void Main::respond(int id, int val, text_stream *arg, void *state) {
switch (id) {
case TEXTUAL_CLSW: output_textually = Filenames::from_text(arg); break;
case BINARY_CLSW: output_binarily = Filenames::from_text(arg); inter_processing_chain = NULL; break;
case INTER_CLSW: inter_processing_chain = Str::duplicate(arg); break;
case DOMAIN_CLSW: domain_path = Pathnames::from_text(arg); inter_processing_chain = NULL; break;
case TEMPLATE_CLSW: template_path = Pathnames::from_text(arg); inter_processing_chain = NULL; break;
case BINARY_CLSW: output_binarily = Filenames::from_text(arg); pipeline_as_text = NULL; break;
case PIPELINE_CLSW: pipeline_as_text = Str::duplicate(arg); break;
case PIPELINE_FILE_CLSW: pipeline_as_file = Filenames::from_text(arg); break;
case PIPELINE_VARIABLE_CLSW: {
match_results mr = Regexp::create_mr();
if (Regexp::match(&mr, arg, L"(%c+)=(%c+)")) {
if (Str::get_first_char(arg) != '*') {
Errors::fatal("-variable names must begin with '*'");
} else {
Str::copy(Dictionaries::create_text(pipeline_vars, mr.exp[0]), mr.exp[1]);
}
} else {
Errors::fatal("-variable should take the form 'name=value'");
}
Regexp::dispose_of(&mr);
break;
}
case DOMAIN_CLSW: domain_path = Pathnames::from_text(arg); pipeline_as_text = NULL; break;
case TEMPLATE_CLSW: template_path = Pathnames::from_text(arg); pipeline_as_text = NULL; break;
case TEST_CLSW: unit_test_file = Filenames::from_text(arg); break;
}
}
@ -79,22 +104,27 @@ void Main::add_file(int id, text_stream *arg, void *state) {
@ =
void Main::act(void) {
inter_repository *I = Inter::create(1, 32);
inter_file *IF;
LOOP_OVER(IF, inter_file)
if (Inter::Binary::test_file(IF->inter_filename))
Inter::Binary::read(I, IF->inter_filename);
else
Inter::Textual::read(I, IF->inter_filename);
if (inter_processing_chain) {
if ((pipeline_as_file) || (pipeline_as_text)) {
if (NUMBER_CREATED(inter_file) > 0)
Errors::fatal("-pipeline and -pipeline-file cannot be combined with inter file parameters");
int NO_FS_AREAS = 0;
pathname *pathname_of_i6t_files[1];
if (template_path) { NO_FS_AREAS = 1; pathname_of_i6t_files[0] = template_path; }
codegen_pipeline *SS = CodeGen::Pipeline::parse(inter_processing_chain, I"output.i6");
CodeGen::Pipeline::run(domain_path, SS, I, NO_FS_AREAS, pathname_of_i6t_files, template_path, NULL);
codegen_pipeline *SS;
if (pipeline_as_file) SS = CodeGen::Pipeline::parse_from_file(pipeline_as_file, pipeline_vars);
else SS = CodeGen::Pipeline::parse(pipeline_as_text, pipeline_vars);
CodeGen::Pipeline::run(domain_path, SS, NO_FS_AREAS, pathname_of_i6t_files);
} else if (unit_test_file) {
UnitTests::run(unit_test_file);
} else {
inter_repository *I = Inter::create(1, 32);
inter_file *IF;
LOOP_OVER(IF, inter_file) {
if (Inter::Binary::test_file(IF->inter_filename))
Inter::Binary::read(I, IF->inter_filename);
else
Inter::Textual::read(I, IF->inter_filename);
}
if (output_textually) {
text_stream C_struct; text_stream *OUT = &C_struct;
if (STREAM_OPEN_TO_FILE(OUT, output_textually, UTF8_ENC) == FALSE)

View file

@ -18,7 +18,7 @@ Preliminaries
Inform Primitives
Inform Annotations
Inform Organisation
Chains and Stages
Pipelines and Stages
Chapter 1: Everything
Basics

View file

@ -1,182 +0,0 @@
Chains and Stages.
Sequences of named code-generation stages are called chains.
@h Stages and descriptions.
A processing stage is a step in code generation which acts on a repository
of inter in memory. Some stages change, add to or edit down that code, while
others leave it untouched but output a file based on it.
Each stage can see an entire repository of inter code at a time, and is
not restricted to working through it in sequence. Those which read in or write
out a file also have a filename supplied to them as a parameter, but there
are otherwise no configuration options. It's not possible to tell a stage
to work on one specific function alone, for example.
Stages are named, which are written without spaces, and conventionally use
hyphens: for example, |resolve-conditional-compilation|. Where a filename has
to be supplied, it appears after a colon. Thus |generate-inter:my.intert|
is a valid stage description.
A "chain" is a comma-separated list of stage descriptions, and represents a
sort of program to follow: memory inter is passed through each stage in turn.
The special stage |stop| halts processing of the chain midway. At present
this is only useful for making experimental edits to chain descriptions
to see what just the first half does, without deleting the second half of
the description.
@ There are three ways to use chains. One is from the command line of Inter:
|$ inter/Tangled/inter FILE -inter 'CHAIN'|
The other is to use two experimental features of Inform. This sentence:
>> Use inter chain "STAGES".
replaces the chain normally used for code generation with the one supplied.
(This may very well cause the compiler not to produce viable code, of course.)
Equivalently, a replacement chain can be specified at the Inform 7 command line:
|$ inform7/Tangled/inform7 ... -inter 'CHAIN'|
When using a chain within Inform, one further description syntax is allowed:
the filename |*| means "the filename Inform wants to use for the final
Inform 6 file".
@h The code-generation stages.
The following are all experimental, and have probably not yet reached their
final form or names. But this briefly describes the stages which currently
exist in the code generator. In the description below, the "repository" is
the reservoir of memory inter code being worked on.
Although one thinks of code generation as a process of turning inter into
Inform 6, in fact it goes both ways, because we also have to read in
the "template" of standing Inform 6 code. The early code generation stages
convert the template from Inform 6 into inter, merging it with the inter
already produced by the front end of the compiler. The later stages then
turn this merged repository into Inform 6 code. (Routines in the template,
therefore, are converted out of Inform 6 and then back into it again. This
sounds inefficient but is surprisingly fast, and enables many optimisations.)
@ |link:T| reads in the I6T template file T, converts it to inter in a very
basic way (creating many splats), and merges it with the repository. Splats
are the unhappiest of inter statements, simply including verbatim snippets
of Inform 6 code.
@ |parse-linked-matter| examines the splats produced by linking and annotates
them by what they seem to want to do. For example,
|splat &"Global nitwit = 2;\n"|
is recognised as an Inform 6 variable declaration, and annotated thus:
|splat GLOBAL &"Global nitwit = 2;\n"|
@ |resolve-conditional-compilation| looks for splats arising from Inform 6
conditional compilation directives such as |#ifdef|, |#ifndef|, |#endif|;
it then detects whether the relevant symbols are defined, or looks at their
values, and deletes sections of code not to be compiled. At the end of this
stage, there are no conditional compilation splats left in the repository.
For example:
|constant MAGIC K_number = 16339|
|splat IFTRUE &"#iftrue MAGIC == 16339;\n"|
|constant WIZARD K_number = 5|
|splat IFNOT &"#ifnot;\n"|
|constant MUGGLE K_number = 0|
|splat ENDIF &"#endif;\n"|
is resolved to:
|constant MAGIC K_number = 16339|
|constant WIZARD K_number = 5|
@ |assimilate| aims to convert all remaining splats in the repository into
higher-level inter statements. For example,
|splat STUB &"#Stub Peach 0;\n"|
|splat ATTRIBUTE &"Attribute marmorial;\n"|
becomes:
|constant Peach K_unchecked_function = Peach_B __assimilated=1|
|property marmorial K_truth_state __assimilated=1 __attribute=1 __either_or=1|
At the end of this stage, there should be no splats left in the repository,
and the linking process is complete.
@ |make-identifiers-unique| looks for symbols marked with the |MAKE_NAME_UNIQUE|
flag (represented in textual form by an asterisk after its name), This flag
means that Inform wants the symbol name to be globally unique in the repository.
For example, if Inform generates the symbol name |fruit*|, it's really telling
the code generator that it eventually wants this to have a name which won't
collide with anything else.
What |make-identifiers-unique| does is to append |_U1|, |_U2|, ... to such
names across the repository. Thus |fruit*| might become |fruit_U176|, and it
is guaranteed that no other symbol has the same name.
This stage is needed because whereas the inter language has namespces, so
that the same name can mean different things in different parts of the
program, Inform 6 (mostly) does not. There cannot be two functions with the
same name in any I6 program, for example.
At the end of this stage, no symbol still has the |MAKE_NAME_UNIQUE| flag.
@ |reconcile-verbs| is a short stage looking for clashes between any verbs (in
the parser interactive fiction sense) which have been assimilated from the
template, and verbs which have been defined in the main source text. For
example, suppose the source creates the command verb "abstract": this would
collide with the command meta-verb "abstract", intended for debugging, which
appears in the template. What this stage does is to detect such problems,
and if it finds one, to prefix the template verb with |!|. Thus we would end
up with two command verbs: |abstract|, with its source text meaning, and
|!abstract|, with its template meaning.
At the end of this stage, all parser verbs have distinct textual forms.
@ |eliminate-redundant-labels| performs peephole optimisation on all of
the functions in the repository to remove all labels which are declared
but can never be jumped to.
At the end of this stage, all labels inside functions are targets of some
branch, either by |inv !jump| or in assembly language.
@ |generate-inter:F| writes out the repository as a textual inter file |F|.
(By default, Inform doesn't do this: the inter ordinarily stays in memory
throughout.)
This stage leaves the repository unchanged.
@ |generate-inter-binary:F| writes out the repository as a binary inter
file |F|. (By default, Inform doesn't do this: the inter ordinarily stays in
memory throughout.)
This stage leaves the repository unchanged.
@ |generate-i6:F| translates the repository to an Inform 6 program. This is
normally the final stage in the Inform code generation chain.
This stage leaves the repository unchanged.
@h Diagnostic or non-working stages.
@ |show-dependencies:F| and |log-dependencies| output a dependency graph of
the symbols in the current repository, one to a file, the other to the
debugging log. A dependency means that one can't be compiled without the
other: for example, if a function has a local variable of a given kind, then
the function depends on that kind.
|eliminate-redundant-code| is a stage which removes all material from
the repository which the main routine is not dependent on. This can result
in many template routines being kicked out, and substantially reduces
story file sizes. The stage mostly works, but needs more refinement before
we could safely enable it by default with Inform.
@ |summarise:F| is a very slow diagnostic stage showing the breakdown of the
current repository into packages, writing the output to file |F|. (Slow in
this sense means that it roughly triples compilation time.)
@ |export:F| and |import:F| were part of an experiment to do with caching the
inter generated by the Standard Rules. This eventually worked, but was put on
ice while a better and more systematic solution was found.

View file

@ -0,0 +1,238 @@
Pipelines and Stages.
Sequences of named code-generation stages are called pipelines.
@h Stages and descriptions.
A processing stage is a step in code generation which acts on a repository
of inter in memory. Some stages change, add to or edit down that code, while
others leave it untouched but output a file based on it.
Each stage can see an entire repository of inter code at a time, and is
not restricted to working through it in sequence.
Stages are named, which are written without spaces, and conventionally use
hyphens: for example, |resolve-conditional-compilation|. Where a filename has
to be supplied, it appears after a colon. Thus |generate-inter:my.intert|
is a valid stage description.
A "pipeline" is a list of stage descriptions. If the pipeline is spelled
out textually on the command line, then commas are used to divide the stages:
|$ inter/Tangled/inter -pipeline 'plugh, xyzzy, plover'|
If the pipeline is in an external file, then one stage should appear on
each line, and the comma is not needed:
|plugh|
|xyzzy|
|plover|
@ A pipeline can work on up to 10 different repositories, called |0| to |9|,
which are initially empty (but see below).
A pipeline description can make use of "variables". These hold only text,
and generally represent filenames. Variable names begin with a star |*|.
The pipeline cannot create variables: instead, the user of the pipeline has
to make them before use. For example,
|$ inter/Tangled/inter -variable '*X=ex/why' -pipeline-file mypl.interpipeline|
creates the variable |*X| with the textual contents |ex/why| before running
the given pipeline. Inside the pipeline, a line such as:
|generate: inform6 -> *X|
would then be read as:
|generate: inform6 -> ex/why|
After variable substitution like this, filenames inside the pipeline
description are interpreted as follows:
(a) If a filename contains a slash character, it is considered a literal
filename.
(b) If not, it is considered to be a leafname inside the "domain" directory.
By default this is the current working directory, but using |-domain| at
the Inter command line changes that.
The special variable |*log|, which always exists, means the debugging log.
A command to write a text file to |*log| is interpreted instead to mean
"spool the output you would otherwise write to the debugging log instead".
For example,
|generate: inventory -> *log|
Template filenames are a little different: those are searched for inside
a path of possible directories. By default there's no such path, but using
|-template T| at the Inter command line gives a path of just one directory.
@h Pipelines run by Inform.
As the above implies, Inter pipelines normally begin with a clean slate:
no repositories, no variables.
When a pipeline is being run by the main Inform 7 compiler, however,
repository |0| will be preloaded with the inter code Inform has generated
in memory. The variable |*out| is set to the filename to which final I6 code
needs to be written, and the "domain" is the directory containing that.
The template search path is set to the one used in Inform, that is, the
template file |Whatever.i6t| would be looked for first in the project's
|X.materials/I6T| directory, then in the user's |I6T| directory, and failing
that in Inform's built-in one.
The pipeline is itself looked for in the same way. If you have a project
called |Strange.inform|, then Inform first looks for
|Strange.materials/Inter/default.interpipeline|
If it can't find this file, it next looks for |default.interpipeline| in
the user's folder, and then in Inform's built-in one. If you're curious to
read the pipeline normally used by a shipping version of Inform, the file
can be found here in the Github repository for Inform:
|inform7/Internal/Inter/default.interpipeline|
The best way to change the pipeline, then, is to put a new file in the
project's Materials folder. But there are also two other ways.
1. This sentence:
>> Use inter pipeline "PIPELINE".
replaces the pipeline normally used for code generation with the one supplied.
(That may very well cause the compiler not to produce viable code, of course.)
2. A replacement pipeline can be specified at the Inform 7 command line:
|$ inform7/Tangled/inform7 ... -pipeline 'PIPELINE'|
Exactly as with Inter, Inform 7 also responds to |-pipeline-file|:
|$ inform7/Tangled/inform7 ... -pipeline-file FILE|
@h Reading and generating.
The |read| stage reads Inter from a file into a repository in memory.
(Its previous contents, if any, are discarded.) This then becomes the
repository to which subsequent stages apply. The format is:
|read REPOSITORY <- FILE|
where |REPOSITORY| is |0| to |9|. Conventionally, we use |0| most of the time.
The |FILE| can contain either binary or textual Inter, and this is
automatically detected.
|generate: FORMAT -> FILE|
writes the contents of the current repository out into the given |FILE|.
There are several possible formats: |binary| and |text| mean a binary or
textual Inter file, |inventory| means a textual summary of the contents,
and |inform6| means an Inform 6 program.
The |generate| stage leaves the repository unchanged, so it's possible
to generate multiple representations of the same repository into different
files.
@h The code-generation stages.
The following are all experimental, and have probably not yet reached their
final form or names.
Although one thinks of code generation as a process of turning inter into
Inform 6, in fact it goes both ways, because we also have to read in
the "template" of standing Inform 6 code. The early code generation stages
convert the template from Inform 6 into inter, merging it with the inter
already produced by the front end of the compiler. The later stages then
turn this merged repository into Inform 6 code. (Routines in the template,
therefore, are converted out of Inform 6 and then back into it again. This
sounds inefficient but is surprisingly fast, and enables many optimisations.)
@ |link:T| reads in the I6T template file T, converts it to inter in a very
basic way (creating many splats), and merges it with the repository. Splats
are the unhappiest of inter statements, simply including verbatim snippets
of Inform 6 code.
@ |parse-linked-matter| examines the splats produced by linking and annotates
them by what they seem to want to do. For example,
|splat &"Global nitwit = 2;\n"|
is recognised as an Inform 6 variable declaration, and annotated thus:
|splat GLOBAL &"Global nitwit = 2;\n"|
@ |resolve-conditional-compilation| looks for splats arising from Inform 6
conditional compilation directives such as |#ifdef|, |#ifndef|, |#endif|;
it then detects whether the relevant symbols are defined, or looks at their
values, and deletes sections of code not to be compiled. At the end of this
stage, there are no conditional compilation splats left in the repository.
For example:
|constant MAGIC K_number = 16339|
|splat IFTRUE &"#iftrue MAGIC == 16339;\n"|
|constant WIZARD K_number = 5|
|splat IFNOT &"#ifnot;\n"|
|constant MUGGLE K_number = 0|
|splat ENDIF &"#endif;\n"|
is resolved to:
|constant MAGIC K_number = 16339|
|constant WIZARD K_number = 5|
@ |assimilate| aims to convert all remaining splats in the repository into
higher-level inter statements. For example,
|splat STUB &"#Stub Peach 0;\n"|
|splat ATTRIBUTE &"Attribute marmorial;\n"|
becomes:
|constant Peach K_unchecked_function = Peach_B __assimilated=1|
|property marmorial K_truth_state __assimilated=1 __attribute=1 __either_or=1|
At the end of this stage, there should be no splats left in the repository,
and the linking process is complete.
@ |make-identifiers-unique| looks for symbols marked with the |MAKE_NAME_UNIQUE|
flag (represented in textual form by an asterisk after its name), This flag
means that Inform wants the symbol name to be globally unique in the repository.
For example, if Inform generates the symbol name |fruit*|, it's really telling
the code generator that it eventually wants this to have a name which won't
collide with anything else.
What |make-identifiers-unique| does is to append |_U1|, |_U2|, ... to such
names across the repository. Thus |fruit*| might become |fruit_U176|, and it
is guaranteed that no other symbol has the same name.
This stage is needed because whereas the inter language has namespces, so
that the same name can mean different things in different parts of the
program, Inform 6 (mostly) does not. There cannot be two functions with the
same name in any I6 program, for example.
At the end of this stage, no symbol still has the |MAKE_NAME_UNIQUE| flag.
@ |reconcile-verbs| is a short stage looking for clashes between any verbs (in
the parser interactive fiction sense) which have been assimilated from the
template, and verbs which have been defined in the main source text. For
example, suppose the source creates the command verb "abstract": this would
collide with the command meta-verb "abstract", intended for debugging, which
appears in the template. What this stage does is to detect such problems,
and if it finds one, to prefix the template verb with |!|. Thus we would end
up with two command verbs: |abstract|, with its source text meaning, and
|!abstract|, with its template meaning.
At the end of this stage, all parser verbs have distinct textual forms.
@ |eliminate-redundant-code| deletes all packages which Inter can prove
will not be used in the final code generated from the repository. For
example, functions never called, or arrays never referred to, are deleted.
@ |eliminate-redundant-labels| performs peephole optimisation on all of
the functions in the repository to remove all labels which are declared
but can never be jumped to.
At the end of this stage, all labels inside functions are targets of some
branch, either by |inv !jump| or in assembly language.
@ The special stage |stop| halts processing of the pipeline midway. At present
this is only useful for making experimental edits to pipeline descriptions
to see what just the first half does, without deleting the second half of
the description.

View file

@ -19,22 +19,21 @@ or for future applications of inter code.
@h Command-line usage.
If you have compiled the standard distribution of the command-line tools
for Inform then the Inter executable will be at |inter/Tangled/inter|.
The usage is:
|$ inter/Tangled/inter FILE1 FILE2 ... [OPTIONS]|
Inter has three basic modes. In the first, the command line specifies only
a single file:
Though multiple files can be supplied, it's usual to supply just one.
|$ inter/Tangled/inter INTERFILE|
Inter simply verifies this file for correctness: that is, to see if the inter
code supplied conforms to the inter specification. It returns the exit code 0
if all is well, and issues error messages and returns 1 if not.
Such files can be in either textual or binary form, and Inter automatically
detects which by looking at their contents. (Conventionally, such files
have the filename extension |.intert| or |.interb| respectively, but that's
not how Inter decides.)
@ Inter has three basic modes. In the first, when no options are supplied,
Inter simply verifies its input for correctness: that is, to see if the inter
code supplied conforms to the inter specification. It returns the exit code 0
if all is well, and issues error messages and returns 1 if not.
@ In the second mode, Inter converts from textual to binary form or vice
versa. The option |-binary X| writes a binary form of the inter to file |X|,
and |-textual X| writes a text form. So, for example,
@ -47,24 +46,30 @@ converts |my.intert| (a textual inter file) to its binary equivalent
|$ inter/Tangled/inter my.interb -textual my.intert|
@ In the third and most flexible mode, Inter runs the supplied code through
a "chain" of processing stages. The chain, which must contain at least
one stage, is a textual list of comma-separated stage names. For example,
a pipeline of processing stages. The pipeline, which must contain at least
one stage, can be quite elaborate (see later), but for example:
|resolve-conditional-compilation,assimilate,make-identifiers-unique|
|read: 0 <- myfile.inter, resolve-conditional-compilation, generate: inform6 -> myfile.i6|
is a valid three-stage chain. The command to do this is then:
is a valid three-stage pipeline. The command to do this is then:
|$ inter/Tangled/inter my.intert -inter 'CHAIN'|
|$ inter/Tangled/inter -pipeline 'PIPELINE'|
where |CHAIN| is the chain description.
where |PIPELINE| is a textual description like the one above. In practice,
it may not be convenient to spell the pipeline out on the command line, so
one can also put it into a text file:
In practice, this will only be useful if you can access the result, so it's
normal for the final stage to output something: perhaps Inform 6 code, perhaps
textual inter. For example:
|$ inter/Tangled/inter -pipeline-file mypl.interpipeline|
|$ inter/Tangled/inter in.intert -inter 'parse-linked-matter, generate-inter:out.intert'|
Pipelines can contain variables, and their values can be set at the command
line with e.g.:
Two more options may be helpful to supplement this: |-domain D| sets the
directory |D| to be the default location for reading and writing inter files;
and |-template T| tells Inter that it can find the I6T template files at
the file system location |T|. (Some code-generation stages import these.)
|-variable '*out=myfile.i6'|
It is also possible to set the default directory for reading and writing files:
|-domain D|
Finally, we can tell Inter where to find I6T template files:
|-template T|

View file

@ -0,0 +1,5 @@
read: 0 <- *in
parse-linked-matter
assimilate
resolve-external-symbols
generate: text -> *out

View file

@ -0,0 +1,5 @@
read: 0 <- *in
parse-linked-matter
resolve-conditional-compilation
assimilate
generate: inform6 -> *out

View file

@ -0,0 +1,4 @@
read: 0 <- *in
parse-linked-matter
resolve-conditional-compilation
generate: text -> *out

View file

@ -0,0 +1,4 @@
read: 0 <- *in
parse-linked-matter
resolve-conditional-compilation
generate: text -> *out

View file

@ -0,0 +1,5 @@
read: 0 <- *in
parse-linked-matter
resolve-conditional-compilation
assimilate
generate: inform6 -> *out

View file

@ -0,0 +1,3 @@
read: 0 <- *in
parse-linked-matter
generate: text -> *out

View file

@ -0,0 +1,5 @@
read: 0 <- *in
parse-linked-matter
resolve-conditional-compilation
assimilate
generate: inform6 -> *out

View file

@ -0,0 +1,5 @@
read: 0 <- *in
parse-linked-matter
resolve-conditional-compilation
assimilate
generate: inform6 -> *out

View file

@ -0,0 +1,3 @@
read: 0 <- *in
eliminate-redundant-labels
generate: text -> *out

View file

@ -0,0 +1,5 @@
read: 0 <- *in
parse-linked-matter
resolve-conditional-compilation
assimilate
generate: inform6 -> *out

View file

@ -0,0 +1,5 @@
read: 0 <- *in
parse-linked-matter
resolve-conditional-compilation
assimilate
generate: inform6 -> *out

View file

@ -1,11 +1,7 @@
-cases [Valid] 'inter/Tests/Valid'
-cases [Invalid] 'inter/Tests/Invalid'
-cases [Generations] 'inter/Tests/Generations'
-cases [RCC] 'inter/Tests/RCC'
-cases [PLM] 'inter/Tests/PLM'
-cases [Assimilate] 'inter/Tests/Assimilate'
-cases [General] 'inter/Tests/General'
-cases [Units] 'inter/Tests/Units'
-cases [ERL] 'inter/Tests/ERL'
-recipe [Valid]
@ -50,9 +46,10 @@
-end
-recipe [Generations]
-recipe [General]
set: $O = $PATH/$CASE.intert
set: $P = $PATH/_Pipelines/$CASE.interpipeline
set: $A = $PATH/_Results_Actual/$CASE.txt
set: $I = $PATH/_Results_Ideal/$CASE.txt
set: $T = $PATH/_Console/$CASE.txt
@ -61,91 +58,7 @@
mkdir: $PATH/_Results_Ideal
mkdir: $PATH/_Console
step: inter/Tangled/inter $O -inter 'parse-linked-matter, resolve-conditional-compilation, assimilate, generate: inform6 -> $A' >$T 2>&1
or: 'failed to produce output' $T
show: $A
match text: $A $I
or: 'produced incorrect output'
-end
-recipe [RCC]
set: $O = $PATH/$CASE.intert
set: $A = $PATH/_Results_Actual/$CASE.txt
set: $I = $PATH/_Results_Ideal/$CASE.txt
set: $T = $PATH/_Console/$CASE.txt
mkdir: $PATH/_Results_Actual
mkdir: $PATH/_Results_Ideal
mkdir: $PATH/_Console
step: inter/Tangled/inter $O -inter 'parse-linked-matter, resolve-conditional-compilation, generate: text ->$A' >$T 2>&1
or: 'failed to produce output' $T
show: $A
match text: $A $I
or: 'produced incorrect output'
-end
-recipe [PLM]
set: $O = $PATH/$CASE.intert
set: $A = $PATH/_Results_Actual/$CASE.txt
set: $I = $PATH/_Results_Ideal/$CASE.txt
set: $T = $PATH/_Console/$CASE.txt
mkdir: $PATH/_Results_Actual
mkdir: $PATH/_Results_Ideal
mkdir: $PATH/_Console
step: inter/Tangled/inter $O -inter 'parse-linked-matter, generate: text ->$A' >$T 2>&1
or: 'failed to produce output' $T
show: $A
match text: $A $I
or: 'produced incorrect output'
-end
-recipe [ERL]
set: $O = $PATH/$CASE.intert
set: $A = $PATH/_Results_Actual/$CASE.txt
set: $I = $PATH/_Results_Ideal/$CASE.txt
set: $T = $PATH/_Console/$CASE.txt
mkdir: $PATH/_Results_Actual
mkdir: $PATH/_Results_Ideal
mkdir: $PATH/_Console
step: inter/Tangled/inter $O -inter 'eliminate-redundant-labels, generate: text ->$A' >$T 2>&1
or: 'failed to produce output' $T
show: $A
match text: $A $I
or: 'produced incorrect output'
-end
-recipe [Assimilate]
set: $O = $PATH/$CASE.intert
set: $A = $PATH/_Results_Actual/$CASE.txt
set: $I = $PATH/_Results_Ideal/$CASE.txt
set: $T = $PATH/_Console/$CASE.txt
mkdir: $PATH/_Results_Actual
mkdir: $PATH/_Results_Ideal
mkdir: $PATH/_Console
step: inter/Tangled/inter $O -inter 'parse-linked-matter, assimilate, resolve-external-symbols, generate: text ->$A' >$T 2>&1
step: inter/Tangled/inter -variable '*in=$O' -variable '*out=$A' -pipeline-file $P >$T 2>&1
or: 'failed to produce output' $T
show: $A

View file

@ -18,6 +18,7 @@ typedef struct pipeline_step {
struct pathname **the_PP;
int the_N;
int to_debugging_log;
int repository_argument;
struct text_stream *text_out_file;
struct inter_repository *repository;
MEMORY_MANAGEMENT
@ -28,6 +29,7 @@ pipeline_step *CodeGen::Pipeline::new_step(void) {
step->step_stage = NULL;
step->step_argument = NULL;
step->package_argument = NULL;
step->repository_argument = -1;
CodeGen::Pipeline::clean_step(step);
return step;
}
@ -53,18 +55,22 @@ void CodeGen::Pipeline::write_step(OUTPUT_STREAM, pipeline_step *step) {
if (step->step_stage->stage_arg != NO_STAGE_ARG) {
if (step->package_argument) WRITE(" %S", step->package_argument);
WRITE(":");
if (step->repository_argument >= 0) WRITE(" %d <-", step->repository_argument);
if (step->target_argument) WRITE(" %S ->", step->target_argument->target_name);
WRITE(" %S", step->step_argument);
}
}
pipeline_step *CodeGen::Pipeline::read_step(text_stream *step, text_stream *leafname) {
pipeline_step *CodeGen::Pipeline::read_step(text_stream *step, dictionary *D) {
CodeGen::Stage::make_stages();
CodeGen::Targets::make_targets();
pipeline_step *ST = CodeGen::Pipeline::new_step();
match_results mr = Regexp::create_mr();
if (Regexp::match(&mr, step, L"(%c+?) *: *(%C*) *-> *(%c*)")) {
ST->step_argument = Str::new();
if (Regexp::match(&mr, step, L"(%c+?) *: *(%d) *<- *(%c*)")) {
ST->repository_argument = Str::atoi(mr.exp[1], 0);
ST->step_argument = CodeGen::Pipeline::read_parameter(mr.exp[2], D);
Str::copy(step, mr.exp[0]);
} else if (Regexp::match(&mr, step, L"(%c+?) *: *(%C*) *-> *(%c*)")) {
code_generation_target *cgt;
LOOP_OVER(cgt, code_generation_target)
if (Str::eq(mr.exp[1], cgt->target_name))
@ -73,18 +79,14 @@ pipeline_step *CodeGen::Pipeline::read_step(text_stream *step, text_stream *leaf
WRITE_TO(STDERR, "No such code generation target as '%S'\n", mr.exp[1]);
internal_error("no such target");
}
Str::copy(ST->step_argument, mr.exp[2]);
ST->step_argument = CodeGen::Pipeline::read_parameter(mr.exp[2], D);
Str::copy(step, mr.exp[0]);
if (Str::eq(ST->step_argument, I"*")) Str::copy(ST->step_argument, leafname);
} else if (Regexp::match(&mr, step, L"(%c+?) *: *(%c*)")) {
ST->step_argument = Str::new();
Str::copy(ST->step_argument, mr.exp[1]);
ST->step_argument = CodeGen::Pipeline::read_parameter(mr.exp[1], D);
Str::copy(step, mr.exp[0]);
if (Str::eq(ST->step_argument, I"*")) Str::copy(ST->step_argument, leafname);
}
if (Regexp::match(&mr, step, L"(%C+?) (%c+)")) {
ST->package_argument = Str::new();
Str::copy(ST->package_argument, mr.exp[1]);
ST->package_argument = CodeGen::Pipeline::read_parameter(mr.exp[1], D);
Str::copy(step, mr.exp[0]);
}
@ -100,30 +102,65 @@ pipeline_step *CodeGen::Pipeline::read_step(text_stream *step, text_stream *leaf
return ST;
}
text_stream *CodeGen::Pipeline::read_parameter(text_stream *from, dictionary *D) {
if (Str::get_first_char(from) == '*') {
text_stream *find = Dictionaries::get_text(D, from);
if (find) return Str::duplicate(find);
WRITE_TO(STDERR, "No such pipeline variable as '%S'\n", from);
internal_error("no such pipeline variable");
}
return Str::duplicate(from);
}
@h Pipelines.
And then a pipeline is just a linked list of steps.
=
typedef struct codegen_pipeline {
struct dictionary *variables;
struct inter_repository *repositories[10];
struct linked_list *steps; /* of |pipeline_step| */
MEMORY_MANAGEMENT
} codegen_pipeline;
codegen_pipeline *CodeGen::Pipeline::new(void) {
dictionary *CodeGen::Pipeline::basic_dictionary(text_stream *leafname) {
dictionary *D = Dictionaries::new(16, TRUE);
if (Str::len(leafname) > 0) Str::copy(Dictionaries::create_text(D, I"*out"), leafname);
Str::copy(Dictionaries::create_text(D, I"*log"), I"*log");
return D;
}
codegen_pipeline *CodeGen::Pipeline::new(dictionary *D) {
codegen_pipeline *S = CREATE(codegen_pipeline);
S->variables = D;
S->steps = NEW_LINKED_LIST(pipeline_step);
for (int i=0; i<10; i++) S->repositories[i] = NULL;
return S;
}
codegen_pipeline *CodeGen::Pipeline::parse(text_stream *instructions, text_stream *leafname) {
codegen_pipeline *S = CodeGen::Pipeline::new();
CodeGen::Pipeline::parse_into(S, instructions, leafname);
codegen_pipeline *CodeGen::Pipeline::parse_from_file(filename *F, dictionary *D) {
TEMPORARY_TEXT(A);
TextFiles::read(F, FALSE, "can't open inter pipeline file",
TRUE, CodeGen::Pipeline::scan_line, NULL, (void *) A);
codegen_pipeline *S = CodeGen::Pipeline::new(D);
CodeGen::Pipeline::parse_into(S, A);
DISCARD_TEXT(A);
return S;
}
void CodeGen::Pipeline::parse_into(codegen_pipeline *S, text_stream *instructions, text_stream *leafname) {
if (instructions == NULL)
instructions = I"link:Output.i6t, parse-linked-matter, resolve-conditional-compilation, assimilate, reconcile-verbs, generate: inform6 -> *";
void CodeGen::Pipeline::scan_line(text_stream *line, text_file_position *tfp, void *X) {
text_stream *A = (text_stream *) X;
if (Str::len(A) > 0) WRITE_TO(A, ", ");
WRITE_TO(A, "%S", line);
}
codegen_pipeline *CodeGen::Pipeline::parse(text_stream *instructions, dictionary *D) {
codegen_pipeline *S = CodeGen::Pipeline::new(D);
CodeGen::Pipeline::parse_into(S, instructions);
return S;
}
void CodeGen::Pipeline::parse_into(codegen_pipeline *S, text_stream *instructions) {
TEMPORARY_TEXT(T);
LOOP_THROUGH_TEXT(P, instructions)
if (Characters::is_babel_whitespace(Str::get(P)))
@ -131,30 +168,35 @@ void CodeGen::Pipeline::parse_into(codegen_pipeline *S, text_stream *instruction
else
PUT_TO(T, Str::get(P));
match_results mr = Regexp::create_mr();
while (Regexp::match(&mr, T, L" *(%c+?) *, *(%c*?) *")) {
pipeline_step *ST = CodeGen::Pipeline::read_step(mr.exp[0], leafname);
ADD_TO_LINKED_LIST(ST, pipeline_step, S->steps);
while (Regexp::match(&mr, T, L" *(%c+?) *,+ *(%c*?) *")) {
pipeline_step *ST = CodeGen::Pipeline::read_step(mr.exp[0], S->variables);
if (ST) ADD_TO_LINKED_LIST(ST, pipeline_step, S->steps);
Str::copy(T, mr.exp[1]);
}
if (Regexp::match(&mr, T, L" *(%c+?) *")) {
pipeline_step *ST = CodeGen::Pipeline::read_step(mr.exp[0], leafname);
ADD_TO_LINKED_LIST(ST, pipeline_step, S->steps);
pipeline_step *ST = CodeGen::Pipeline::read_step(mr.exp[0], S->variables);
if (ST) ADD_TO_LINKED_LIST(ST, pipeline_step, S->steps);
}
}
void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, inter_repository *I, int N, pathname **PP, pathname *PM, pathname *FM) {
if (S == NULL) return;
clock_t start = clock();
void CodeGen::Pipeline::set_repository(codegen_pipeline *S, inter_repository *I) {
S->repositories[0] = I;
}
CodeGen::Pipeline::prepare_to_run(I);
void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, int N, pathname **PP) {
if (S == NULL) return;
if (S->repositories[0] == NULL) S->repositories[0] = Inter::create(1, 32);
clock_t start = clock();
int step_count = 0, step_total = 0;
pipeline_step *step;
LOOP_OVER_LINKED_LIST(step, pipeline_step, S->steps) step_total++;
int active = TRUE;
int active = TRUE, current_repo = 0;
CodeGen::Pipeline::prepare_to_run(S->repositories[current_repo]);
LOOP_OVER_LINKED_LIST(step, pipeline_step, S->steps)
if (active) {
inter_repository *I = S->repositories[current_repo];
CodeGen::Pipeline::lint(I);
CodeGen::Pipeline::clean_step(step);
@ -173,18 +215,17 @@ void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, inter_repository *
(step->step_stage->stage_arg == TEXT_OUT_STAGE_ARG) ||
(step->step_stage->stage_arg == EXT_FILE_STAGE_ARG) ||
(step->step_stage->stage_arg == EXT_TEXT_OUT_STAGE_ARG)) {
if (Str::eq(step->step_argument, I"log")) {
if (Str::eq(step->step_argument, I"*log")) {
step->to_debugging_log = TRUE;
} else {
step->parsed_filename = Filenames::from_text(step->step_argument);
int slashes = FALSE;
LOOP_THROUGH_TEXT(pos, step->step_argument)
if (Str::get(pos) == '/')
slashes = TRUE;
if (slashes) step->parsed_filename = Filenames::from_text(step->step_argument);
else if ((step->step_stage->stage_arg == EXT_FILE_STAGE_ARG) ||
(step->step_stage->stage_arg == EXT_TEXT_OUT_STAGE_ARG))
step->parsed_filename = Filenames::in_folder(FM, step->step_argument);
else step->parsed_filename = Filenames::in_folder(P, step->step_argument);
LOG("Parsed %S == %f\n", step->step_argument, step->parsed_filename);
}
}
@ -213,6 +254,11 @@ void CodeGen::Pipeline::run(pathname *P, codegen_pipeline *S, inter_repository *
(step->to_debugging_log == FALSE)) {
STREAM_CLOSE(T);
}
if (step->repository_argument >= 0) {
current_repo = step->repository_argument;
CodeGen::Pipeline::prepare_to_run(S->repositories[current_repo]);
}
}
}

View file

@ -41,6 +41,7 @@ void CodeGen::Stage::make_stages(void) {
if (stages_made == FALSE) {
stages_made = TRUE;
CodeGen::Stage::new(I"stop", CodeGen::Stage::run_stop_stage, NO_STAGE_ARG);
CodeGen::Stage::new(I"read", CodeGen::Stage::run_read_stage, FILE_STAGE_ARG);
CodeGen::create_pipeline_stage();
CodeGen::Assimilate::create_pipeline_stage();
@ -62,3 +63,12 @@ the pipeline:
int CodeGen::Stage::run_stop_stage(pipeline_step *step) {
return FALSE;
}
int CodeGen::Stage::run_read_stage(pipeline_step *step) {
filename *F = Filenames::from_text(step->step_argument);
if (Inter::Binary::test_file(F))
Inter::Binary::read(step->repository, F);
else
Inter::Textual::read(step->repository, F);
return TRUE;
}

View file

@ -143,9 +143,6 @@ void CodeGen::Assimilate::visitor3(inter_repository *I, inter_frame P, void *sta
text_stream *suffix = NULL;
inter_symbol *subpackage_type = plain_packagetype;
if (plm == ATTRIBUTE_PLM) trace_AME = TRUE;
else trace_AME = FALSE;
switch (plm) {
case VERB_PLM:
if (command_ptype_symbol) subpackage_type = command_ptype_symbol;

View file

@ -25,6 +25,7 @@ int CodeGen::run_pipeline_stage(pipeline_step *step) {
internal_error("that's not a package name");
}
}
code_generation *gen =
CodeGen::new_generation(step, step->repository, which, step->target_argument);
if (CodeGen::Targets::begin_generation(gen) == FALSE) {

View file

@ -5,19 +5,9 @@ inter-module/Woven/
inter.mk
Tests/Assimilate/_Results_Actual/
Tests/Assimilate/_Console/
Tests/Generations/_Results_Actual/
Tests/Generations/_Console/
Tests/Graph/_Results_Actual/
Tests/Graph/_Console/
Tests/Invalid/_Results_Actual/
Tests/PLM/_Results_Actual/
Tests/PLM/_Console/
Tests/RCC/_Results_Actual/
Tests/RCC/_Console/
Tests/ERL/_Results_Actual/
Tests/ERL/_Console/
Tests/General/_Results_Actual/
Tests/General/_Console/
Tests/Valid/_Binary/
Tests/Valid/_Console/
Tests/Valid/_Textual/

View file

@ -436,25 +436,6 @@ define clean-ebooks
rm -f resources/Changes/Output/*.*
endef
# -----------------------------------------------------------------------------
# Target "csr"
# -----------------------------------------------------------------------------
# "make csr" is for use while experimenting with Inter - it caches the Standard
# Rules as inter files, one for Z, one for Glulx.
# -----------------------------------------------------------------------------
.PHONY: csr
csr:
cp -f $(INFORM7WEB)/Home.txt $(INTESTWEB)/Workspace/T0/Example.inform/Source/story.ni
'inform7/Tangled/inform7' '-format=z8' '-noprogress' '-fixtime' '-rng' '-sigils' '-clock' '-log' 'nothing' '-external' 'inform7/Tests' '-transient' 'intest/Workspace/T0/Transient' '-noindex' '-internal' 'inform7/Internal' '-project' 'intest/Workspace/T0/Example.inform' '-export' 'inform7/Internal/I6T/sr-Z.intert' '-inter' 'stop'
$(INTERTOOLWEB)/Tangled/inter inform7/Internal/I6T/sr-Z.intert -binary inform7/Internal/I6T/sr-Z.interb
cp -f inform7/Internal/I6T/sr-Z.intert $(INTERNAL)/I6T/sr-Z.intert
cp -f inform7/Internal/I6T/sr-Z.interb $(INTERNAL)/I6T/sr-Z.interb
'inform7/Tangled/inform7' '-format=ulx' '-noprogress' '-fixtime' '-rng' '-sigils' '-clock' '-log' 'nothing' '-external' 'inform7/Tests' '-transient' 'intest/Workspace/T0/Transient' '-noindex' '-internal' 'inform7/Internal' '-project' 'intest/Workspace/T0/Example.inform' '-export' 'inform7/Internal/I6T/sr-G.intert' '-inter' 'stop'
$(INTERTOOLWEB)/Tangled/inter inform7/Internal/I6T/sr-G.intert -binary inform7/Internal/I6T/sr-G.interb
cp -f inform7/Internal/I6T/sr-G.intert $(INTERNAL)/I6T/sr-G.intert
cp -f inform7/Internal/I6T/sr-G.interb $(INTERNAL)/I6T/sr-G.interb
# -----------------------------------------------------------------------------
# Targets "integration" and "forceintegration"
# -----------------------------------------------------------------------------
@ -482,6 +463,7 @@ integration: \
$(INTERNAL)/Languages/English/Syntax.preform \
$(SRULESINPLACE) \
$(INTERNAL)/I6T/Main.i6t \
$(INTERNAL)/Inter/default.interpipeline \
$(INTERNALEXEMPLUM) \
$(IMAGESEXEMPLUM) \
$(DOCEXEMPLUM) \
@ -493,6 +475,7 @@ forceintegration:
$(call transfer-preform)
$(call transfer-standard-rules)
$(call transfer-i6-template)
$(call transfer-inter-resources)
$(call transfer-internal-tree)
$(call transfer-images)
$(call make-inapp-documentation)
@ -568,6 +551,15 @@ define transfer-i6-template
cp -R -f inform7/Internal/I6T/*.i6t $(INTERNAL)/I6T
endef
$(INTERNAL)/Inter/default.interpipeline: inform7/Internal/Inter/*.interpipeline
$(call transfer-inter-resources)
define transfer-inter-resources
mkdir -p "$(INTERNAL)/Inter"
rm -f $(INTERNAL)/Inter/*.interpipeline
cp -R -f inform7/Internal/Inter/*.interpipeline $(INTERNAL)/Inter
endef
# (e) Copying internal resources into the app
# The Internal tree also holds built-in extensions, web interpreters and so on.