Extract classify/@terminate into own template

Note that next-match does not cause a return from the template, as odd as it
looks.
master
Mike Gerwitz 2021-01-29 15:47:49 -05:00
parent 1517a03994
commit 97caefab1b
1 changed files with 15 additions and 11 deletions

View File

@ -635,6 +635,21 @@
</template>
<template mode="compile" priority="7"
match="lv:classify[ @terminate='true' ]">
<next-match />
<variable name="var" as="xs:string"
select="compiler:class-var( . )" />
<text>if (_canterm &amp;&amp; </text>
<value-of select="$var" />
<text>) throw Error( '</text>
<value-of select="replace( @desc, '''', '\\''' )" />
<text>');</text>
</template>
<!--
Raise $inner of type $from to $outer of type $to with universal or
existential ($ue) quantification
@ -756,17 +771,6 @@
<sequence select="concat( $var, '=', $reduce,
'(', $yield-to, '=', $js, ');' )" />
<!-- support termination on certain classifications (useful for eligibility
and error conditions) -->
<if test="$classify/@terminate = 'true'">
<text>if (_canterm &amp;&amp; </text>
<value-of select="$var" />
<text>) throw Error( '</text>
<value-of select="replace( $classify/@desc, '''', '\\''' )" />
<text>');</text>
<value-of select="$compiler:nl" />
</if>
</function>