Skip to content

Commit

Permalink
Add user-code emu-meta around the phrase "result of evaluating |Foo|"
Browse files Browse the repository at this point in the history
  • Loading branch information
syg committed Dec 10, 2021
1 parent 236ce06 commit 80959f0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Algorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export default class Algorithm extends Builder {
context.inAlg = true;
const { spec, node, clauseStack } = context;

const innerHTML = node.innerHTML; // TODO use original slice, forward this from linter
// Mark all "the result of evaluation Foo" language as having the
// "user-code" effect. Do this before ecmarkdown, otherwise productions like
// |Foo| get turned into tags and the regexp gets complicated.
const innerHTML = node.innerHTML.replace(/the result of evaluating ([a-zA-Z_|0-9]+)/g, 'the result of <emu-meta effects="user-code">evaluating $1</emu-meta>'); // TODO use original slice, forward this from linter

let emdTree;
if ('ecmarkdownTree' in node) {
Expand Down
6 changes: 6 additions & 0 deletions test/baselines/generated-reference/effect-user-code.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,10 @@ <h1><span class="secnum">18</span> XrefNotFirstChildOfEmuMeta()</h1>
<p>The abstract operation XrefNotFirstChildOfEmuMeta takes no arguments. Effect additions and suppressions via emu-meta only affect xrefs that are the first child of the emu-meta. Below, <emu-xref aoid="UserCode" id="_ref_14"><a href="#sec-user-code" class="e-user-code">UserCode</a></emu-xref>() gets autolinked and get an xref. Its parent element is an emu-meta, but since the xref is not the first child, it should not be interpreted to overried the effects of the <emu-xref aoid="UserCode" id="_ref_15"><a href="#sec-user-code" class="e-user-code">UserCode</a></emu-xref>() call. It performs the following steps when called:</p>
<emu-alg><ol><li>Perform <span class="e-user-code"><var>map</var>.[[DefineOwnProperty]](! <emu-xref aoid="UserCode" id="_ref_16"><a href="#sec-user-code">UserCode</a></emu-xref>())</span>.</li></ol></emu-alg>
</emu-clause>

<emu-clause id="sec-result-of-evaluating" type="abstract operation" aoid="ResultOfEvaluating">
<h1><span class="secnum">19</span> ResultOfEvaluating()</h1>
<p>The abstract operation ResultOfEvaluating takes no arguments. The phrase "the result of evaluating Foo" is automatically considered as can call user code. It performs the following steps when called:</p>
<emu-alg><ol><li>Let <var>res</var> be the result of <span class="e-user-code">evaluating <emu-nt>Foo</emu-nt></span>.</li></ol></emu-alg>
</emu-clause>
</div></body>
11 changes: 11 additions & 0 deletions test/baselines/sources/effect-user-code.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,14 @@ <h1>XrefNotFirstChildOfEmuMeta()</h1>
1. Perform <emu-meta effects="user-code">_map_.[[DefineOwnProperty]](! UserCode())</emu-meta>.
</emu-alg>
</emu-clause>

<emu-clause id="sec-result-of-evaluating" type="abstract operation">
<h1>ResultOfEvaluating()</h1>
<dl class="header">
<dt>description</dt>
<dd>The phrase "the result of evaluating Foo" is automatically considered as can call user code.</dd>
</dl>
<emu-alg>
1. Let _res_ be the result of evaluating |Foo|.
</emu-alg>
</emu-clause>

0 comments on commit 80959f0

Please sign in to comment.