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

Fix for Jira bug I7-2334

This commit is contained in:
Graham Nelson 2023-04-22 22:47:10 +01:00
parent 3cf062f766
commit 5d4586387c
10 changed files with 111 additions and 34 deletions

View file

@ -750,12 +750,17 @@ which, of course, it usually isn't.
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">InterSchemas::internal_error_on_schema_errors</span><button class="popup" onclick="togglePopup('usagePopup20')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup20">Usage of <span class="code-font"><span class="function-syntax">InterSchemas::internal_error_on_schema_errors</span></span>:<br/>Parsing Inter Schemas - <a href="2-pis.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">inter_schema</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sch</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LinkedLists::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">sch</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_errors</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">CORE_MODULE</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">SourceProblems::inter_schema_errors</span><span class="plain-syntax">(</span><span class="identifier-syntax">sch</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax"> #</span><span class="identifier-syntax">ifndef</span><span class="plain-syntax"> </span><span class="identifier-syntax">CORE_MODULE</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">STDERR</span><span class="plain-syntax">, </span><span class="string-syntax">"Parsing error(s) in the internal schema '%S':\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">sch</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">converted_from</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">schema_parsing_error</span><span class="plain-syntax"> *</span><span class="identifier-syntax">err</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">, </span><span class="reserved-syntax">schema_parsing_error</span><span class="plain-syntax">, </span><span class="identifier-syntax">sch</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">parsing_errors</span><span class="plain-syntax">)</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">WRITE_TO</span><span class="plain-syntax">(</span><span class="identifier-syntax">STDERR</span><span class="plain-syntax">, </span><span class="string-syntax">"- %S\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">err</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">message</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"malformed schema"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> #</span><span class="identifier-syntax">endif</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax">}</span>
</pre>

View file

@ -301,7 +301,7 @@ hierarchy: these functions are always called in matching ways.
</p>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>The <a href="../pipeline-module/index.html" class="internal">pipeline</a> module makes heavy use of the Produce API. Surprising,
<a href="../inform7/index.html" class="internal">inform7</a> calls it in only a few places &mdash; but in fact that it is because
<a href="../inform7/index.html" class="internal">inform7</a> calls it in only a few places &mdash; but in fact that is because
it provides still another middleware layer on top. See <a href="../runtime-module/2-emt.html" class="internal">Emit (in runtime)</a>.
But it's really only a very thin layer, allowing the caller not to have to
pass the <span class="extract"><span class="extract-syntax">I</span></span> argument to every call (because it will always be the Inter tree

View file

@ -246,7 +246,7 @@ rough stages. Twenty is plenty.
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">inform7_task</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">project</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">as_copy</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">edition</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="identifier-syntax">parse_node_tree</span><span class="plain-syntax"> *</span><span class="function-syntax">Task::syntax_tree</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Task::syntax_tree</span></span>:<br/><a href="1-wtc.html#SP14">&#167;14</a><br/>Core Preform - <a href="1-cp2.html#SP2">&#167;2</a>, <a href="1-cp2.html#SP3">&#167;3</a><br/>Using Problems - <a href="2-up.html#SP3">&#167;3</a>, <a href="2-up.html#SP3_3">&#167;3.3</a><br/>Supplementary Issues - <a href="2-si.html#SP1">&#167;1</a>, <a href="2-si.html#SP2">&#167;2</a>, <a href="2-si.html#SP3">&#167;3</a>, <a href="2-si.html#SP4">&#167;4</a>, <a href="2-si.html#SP5">&#167;5</a>, <a href="2-si.html#SP6">&#167;6</a>, <a href="2-si.html#SP7">&#167;7</a>, <a href="2-si.html#SP8">&#167;8</a>, <a href="2-si.html#SP9">&#167;9</a>, <a href="2-si.html#SP10">&#167;10</a>, <a href="2-si.html#SP11">&#167;11</a>, <a href="2-si.html#SP12">&#167;12</a>, <a href="2-si.html#SP13">&#167;13</a><br/>Problems With Source Text - <a href="2-pwst.html#SP1">&#167;1</a><br/>Calculus Problems - <a href="2-cp.html#SP1">&#167;1</a><br/>Kinds Problems - <a href="2-kp.html#SP1">&#167;1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="identifier-syntax">parse_node_tree</span><span class="plain-syntax"> *</span><span class="function-syntax">Task::syntax_tree</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Task::syntax_tree</span></span>:<br/><a href="1-wtc.html#SP14">&#167;14</a><br/>Core Preform - <a href="1-cp2.html#SP2">&#167;2</a>, <a href="1-cp2.html#SP3">&#167;3</a><br/>Using Problems - <a href="2-up.html#SP3">&#167;3</a>, <a href="2-up.html#SP3_3">&#167;3.3</a><br/>Supplementary Issues - <a href="2-si.html#SP1">&#167;1</a>, <a href="2-si.html#SP2">&#167;2</a>, <a href="2-si.html#SP3">&#167;3</a>, <a href="2-si.html#SP4">&#167;4</a>, <a href="2-si.html#SP5">&#167;5</a>, <a href="2-si.html#SP6">&#167;6</a>, <a href="2-si.html#SP7">&#167;7</a>, <a href="2-si.html#SP8">&#167;8</a>, <a href="2-si.html#SP9">&#167;9</a>, <a href="2-si.html#SP10">&#167;10</a>, <a href="2-si.html#SP11">&#167;11</a>, <a href="2-si.html#SP12">&#167;12</a>, <a href="2-si.html#SP13">&#167;13</a><br/>Problems With Source Text - <a href="2-pwst.html#SP1">&#167;1</a>, <a href="2-pwst.html#SP2">&#167;2</a><br/>Calculus Problems - <a href="2-cp.html#SP1">&#167;1</a><br/>Kinds Problems - <a href="2-kp.html#SP1">&#167;1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">latest_syntax_tree</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

View file

@ -650,6 +650,31 @@ group.
<span class="plain-syntax"> </span><span class="identifier-syntax">Problems::quote_stream</span><span class="plain-syntax">(</span><span class="identifier-syntax">N</span><span class="plain-syntax">, </span><span class="identifier-syntax">name</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>These are errors generated by the <a href="../building-module/index.html" class="internal">building</a> module, but which we want to
tidy up and present in the usual Inform 7 way.
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">SourceProblems::inter_schema_errors</span><span class="plain-syntax">(</span><span class="identifier-syntax">inter_schema</span><span class="plain-syntax"> *</span><span class="identifier-syntax">sch</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">current_sentence</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Problems::quote_stream</span><span class="plain-syntax">(2, </span><span class="identifier-syntax">sch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">converted_from</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">StandardProblems::handmade_problem</span><span class="plain-syntax">(</span><a href="1-wtc.html#SP6" class="function-link"><span class="function-syntax">Task::syntax_tree</span></a><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_InterSchemaErrors</span><span class="plain-syntax">));</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span>
<span class="plain-syntax"> </span><span class="string-syntax">"In the sentence %1, you use a fragment of code written in Inform 6 "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"syntax which seems to be malformed in some way. I delegate all that "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"work to a lesser compiler: I gave it '%2' to compile, and it came "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"back with this: "</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">schema_parsing_error</span><span class="plain-syntax"> *</span><span class="identifier-syntax">err</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">LOOP_OVER_LINKED_LIST</span><span class="plain-syntax">(</span><span class="identifier-syntax">err</span><span class="plain-syntax">, </span><span class="identifier-syntax">schema_parsing_error</span><span class="plain-syntax">, </span><span class="identifier-syntax">sch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">parsing_errors</span><span class="plain-syntax">) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Problems::quote_stream</span><span class="plain-syntax">(1, </span><span class="identifier-syntax">err</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">message</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(2, &amp;</span><span class="identifier-syntax">c</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Problems::issue_problem_segment</span><span class="plain-syntax">(</span><span class="string-syntax">"%P%2. %1 "</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">c</span><span class="plain-syntax">++;</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Problems::issue_problem_end</span><span class="plain-syntax">();</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
<ul class="progressbar"><li class="progressprev"><a href="2-si.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-cm.html">1</a></li><li class="progresscurrentchapter">2</li><li class="progresssection"><a href="2-up.html">up</a></li><li class="progresssection"><a href="2-sq.html">sq</a></li><li class="progresssection"><a href="2-si.html">si</a></li><li class="progresscurrent">pwst</li><li class="progresssection"><a href="2-cp.html">cp</a></li><li class="progresssection"><a href="2-kp.html">kp</a></li><li class="progresschapter"><a href="3-pc.html">3</a></li><li class="progressnext"><a href="2-cp.html">&#10095;</a></li></ul></div>
</nav><!--End of weave-->

View file

@ -1,32 +1,33 @@
100.0% in inform7 run
70.7% in compilation to Inter
49.8% in //Sequence::undertake_queued_tasks//
4.9% in //MajorNodes::pre_pass//
3.5% in //MajorNodes::pass_1//
1.8% in //ImperativeDefinitions::assess_all//
1.6% in //RTPhrasebook::compile_entries//
1.4% in //RTKindConstructors::compile//
1.0% in //Sequence::lint_inter//
0.6% in //MajorNodes::pass_2//
0.6% in //Sequence::undertake_queued_tasks//
0.6% in //World::stage_V//
0.4% in //ImperativeDefinitions::compile_first_block//
0.4% in //Sequence::undertake_queued_tasks//
0.2% in //CompletionModule::compile//
0.2% in //InferenceSubjects::emit_all//
0.2% in //RTKindConstructors::compile_permissions//
0.2% in //Task::make_built_in_kind_constructors//
2.9% not specifically accounted for
25.9% in running Inter pipeline
10.1% in step 14/15: generate inform6 -> auto.inf
5.7% in step 5/15: load-binary-kits
5.3% in step 6/15: make-synoptic-module
1.8% in step 9/15: make-identifiers-unique
0.4% in step 12/15: eliminate-redundant-operations
0.4% in step 4/15: compile-splats
0.4% in step 7/15: shorten-wiring
0.2% in step 11/15: eliminate-redundant-labels
0.2% in step 8/15: detect-indirect-calls
1.2% not specifically accounted for
3.0% in supervisor
0.3% not specifically accounted for
70.5% in compilation to Inter
50.3% in //Sequence::undertake_queued_tasks//
4.6% in //MajorNodes::pre_pass//
3.3% in //MajorNodes::pass_1//
1.7% in //ImperativeDefinitions::assess_all//
1.5% in //RTPhrasebook::compile_entries//
1.3% in //RTKindConstructors::compile//
1.1% in //Sequence::lint_inter//
0.5% in //MajorNodes::pass_2//
0.5% in //Sequence::undertake_queued_tasks//
0.5% in //World::stage_V//
0.3% in //ImperativeDefinitions::compile_first_block//
0.3% in //Sequence::undertake_queued_tasks//
0.1% in //Closures::compile_closures//
0.1% in //CompletionModule::compile//
0.1% in //InferenceSubjects::emit_all//
0.1% in //RTKindConstructors::compile_permissions//
0.1% in //Task::make_built_in_kind_constructors//
2.8% not specifically accounted for
26.1% in running Inter pipeline
9.7% in step 14/15: generate inform6 -> auto.inf
5.8% in step 5/15: load-binary-kits
5.4% in step 6/15: make-synoptic-module
1.7% in step 9/15: make-identifiers-unique
0.3% in step 12/15: eliminate-redundant-operations
0.3% in step 4/15: compile-splats
0.3% in step 7/15: shorten-wiring
0.3% in step 8/15: detect-indirect-calls
0.1% in step 11/15: eliminate-redundant-labels
1.5% not specifically accounted for
2.9% in supervisor
0.4% not specifically accounted for

View file

@ -0,0 +1,4 @@
Laboratory is a room.
Definition: an object is foo rather than bar if I6 condition "("
says so (it is broken).

View file

@ -0,0 +1,13 @@
Inform 7 v10.2.0 has started.
I've now read your source text, which is 21 words long.
I've also read Basic Inform by Graham Nelson, which is 7792 words long.
I've also read English Language by Graham Nelson, which is 2330 words long.
I've also read Standard Rules by Graham Nelson, which is 34311 words long.
Problem__ PM_InterSchemaErrors
>--> In the sentence 'an object is foo rather than bar if I6 condition
"("says so (it is broken)' (source text, line 3), you use a fragment of
code written in Inform 6 syntax which seems to be malformed in some way. I
delegate all that work to a lesser compiler: I gave it '(()' to compile,
and it came back with this: 1. unexpected '(' 2. unexpected '(' 3.
unexpected ')'
Inform 7 has finished.

View file

@ -593,3 +593,27 @@ void SourceProblems::quote_genre(int N, copy_error *CE) {
if (Str::eq(name, I"extensionbundle")) name = I"extension";
Problems::quote_stream(N, name);
}
@ These are errors generated by the //building// module, but which we want to
tidy up and present in the usual Inform 7 way.
=
void SourceProblems::inter_schema_errors(inter_schema *sch) {
Problems::quote_source(1, current_sentence);
Problems::quote_stream(2, sch->converted_from);
StandardProblems::handmade_problem(Task::syntax_tree(), _p_(PM_InterSchemaErrors));
Problems::issue_problem_segment(
"In the sentence %1, you use a fragment of code written in Inform 6 "
"syntax which seems to be malformed in some way. I delegate all that "
"work to a lesser compiler: I gave it '%2' to compile, and it came "
"back with this: ");
schema_parsing_error *err;
int c = 1;
LOOP_OVER_LINKED_LIST(err, schema_parsing_error, sch->parsing_errors) {
Problems::quote_stream(1, err->message);
Problems::quote_number(2, &c);
Problems::issue_problem_segment("%P%2. %1 ");
c++;
}
Problems::issue_problem_end();
}

View file

@ -658,11 +658,16 @@ void InterSchemas::throw_error(inter_schema_node *at, text_stream *message) {
=
void InterSchemas::internal_error_on_schema_errors(inter_schema *sch) {
if (LinkedLists::len(sch->parsing_errors) > 0) {
#ifdef CORE_MODULE
SourceProblems::inter_schema_errors(sch);
#endif
#ifndef CORE_MODULE
WRITE_TO(STDERR, "Parsing error(s) in the internal schema '%S':\n",
sch->converted_from);
schema_parsing_error *err;
LOOP_OVER_LINKED_LIST(err, schema_parsing_error, sch->parsing_errors)
WRITE_TO(STDERR, "- %S\n", err->message);
internal_error("malformed schema");
#endif
}
}

View file

@ -228,7 +228,7 @@ Note the use of //Produce::down// and //Produce::up// to step up and down the
hierarchy: these functions are always called in matching ways.
@ The //pipeline// module makes heavy use of the Produce API. Surprising,
//inform7// calls it in only a few places -- but in fact that it is because
//inform7// calls it in only a few places -- but in fact that is because
it provides still another middleware layer on top. See //runtime: Emit//.
But it's really only a very thin layer, allowing the caller not to have to
pass the |I| argument to every call (because it will always be the Inter tree