Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@ryansg.com>2020-01-13 16:41:06 -0500
committerMike Gerwitz <mike.gerwitz@ryansg.com>2020-02-26 10:49:00 -0500
commit6939753ca04416082720a0e773a3491686f25a4d (patch)
treefc60e5152b74274b814b57156417b8b7a2cda338 /src
parent85a4934db55b8f3f4b8f0f82a75d31c967963a96 (diff)
downloadtame-6939753ca04416082720a0e773a3491686f25a4d.tar.gz
tame-6939753ca04416082720a0e773a3491686f25a4d.tar.bz2
tame-6939753ca04416082720a0e773a3491686f25a4d.zip
TAMER: POC: Output xmle
This is a working proof-of-concept that will be finalized in future commits.
Diffstat (limited to 'src')
-rw-r--r--src/current/compiler/js.xsl32
-rw-r--r--src/current/compiler/linker.xsl29
-rw-r--r--src/current/standalone.xsl22
3 files changed, 26 insertions, 57 deletions
diff --git a/src/current/compiler/js.xsl b/src/current/compiler/js.xsl
index cba8678..a756db1 100644
--- a/src/current/compiler/js.xsl
+++ b/src/current/compiler/js.xsl
@@ -62,7 +62,7 @@
@return compiled JS
-->
-<template match="lv:package" mode="compiler:entry">
+<template name="compiler:entry">
<!-- enclose everything in a self-executing function to sandbox our data -->
<text>( function() { </text>
<!-- to store debug information for equations (we have to put this out here
@@ -76,7 +76,7 @@
</template>
-<template match="lv:package" mode="compiler:entry-rater">
+<template name="compiler:entry-rater">
<!-- the rater itself -->
<value-of select="$compiler:nl" />
<text>function rater( arglist, _canterm ) {</text>
@@ -107,16 +107,13 @@
<text>/**@expose*/var genclasses = {};</text>
</template>
-<template match="lv:package" mode="compiler:entry-classifier">
+<template name="compiler:classifier">
<!-- allow classification of any arbitrary dataset -->
<value-of select="$compiler:nl" />
<text>rater.classify = function( args, _canterm ) {</text>
return rater( args, _canterm ).classes;
<text> };</text>
-</template>
-<template match="lv:package" mode="compiler:exit-classifier">
- <!-- TODO: make sure fromMap has actually been compiled -->
<text>rater.classify.fromMap = function( args_base, _canterm ) { </text>
<text>var ret = {}; </text>
<text>rater.fromMap( args_base, function( args ) {</text>
@@ -136,8 +133,10 @@
<text> }; </text>
</template>
-<template match="lv:package" mode="compiler:exit-rater">
+<template name="compiler:exit-rater">
+ <param name="name" as="xs:string "/>
<param name="symbols" as="element( preproc:sym )*" />
+ <param name="mapfrom" as="element()*" />
<value-of select="$compiler:nl" />
<text>return { </text>
@@ -152,7 +151,7 @@
<!-- make the name of the supplier available -->
<text>/**@expose*/rater.supplier = '</text>
- <value-of select="substring-after( @name, '/' )" />
+ <value-of select="substring-after( $name, '/' )" />
<text>'; </text>
<text>/**@expose*/rater.meta = meta;</text>
@@ -174,20 +173,8 @@
$symbols[ @type='class' ] )" />
<text> }; </text>
- <variable name="mapfrom" select="
- preproc:symtable/preproc:sym[
- @type='map'
- ]/preproc:from[
- not(
- @name = parent::preproc:sym
- /preceding-sibling::preproc:sym[
- @type='map'
- ]/preproc:from/@name
- )
- ]
- " />
-
<!-- mapped fields (external names) -->
+ <value-of select="$compiler:nl" />
<text>/**@expose*/rater.knownFields = {</text>
<for-each select="$mapfrom">
<if test="position() > 1">
@@ -221,6 +208,7 @@
<text>'</text>
<value-of select="substring-after( @name, ':class:' )" />
<text>':'</text>
+ <!-- yields -->
<value-of select="@yields" />
<text>'</text>
</for-each>
@@ -239,7 +227,7 @@
<value-of select="substring-after( @name, ':class:' )" />
<text>':'</text>
<!-- todo: escape -->
- <value-of select="translate( @desc, &quot;'&quot;, '' )" />
+ <value-of select="translate( normalize-space(@desc), &quot;'&quot;, '' )" />
<text>'</text>
</for-each>
</function>
diff --git a/src/current/compiler/linker.xsl b/src/current/compiler/linker.xsl
index b1f6c3f..3fb96c4 100644
--- a/src/current/compiler/linker.xsl
+++ b/src/current/compiler/linker.xsl
@@ -799,8 +799,6 @@
</with-param>
</call-template>
- <apply-templates select="." mode="compiler:entry" />
-
<apply-templates select="." mode="l:link-meta">
<with-param name="deps" select="$deps" />
@@ -808,9 +806,6 @@
<apply-templates select="." mode="l:link-worksheet">
<with-param name="deps" select="$deps" />
</apply-templates>
- <apply-templates select="." mode="l:link-classifier">
- <with-param name="deps" select="$deps" />
- </apply-templates>
<apply-templates select="." mode="l:link-params">
<with-param name="deps" select="$deps" />
</apply-templates>
@@ -824,9 +819,6 @@
<with-param name="deps" select="$deps" />
</apply-templates>
- <!-- common stuff -->
- <call-template name="compiler:static" />
-
<!-- finally, finish up -->
<call-template name="log:info">
<with-param name="name" select="'link'" />
@@ -908,21 +900,6 @@
</template>
-<template match="lv:package" mode="l:link-classifier">
- <call-template name="log:info">
- <with-param name="name" select="'link'" />
- <with-param name="msg">
- <text>** linking classifier...</text>
- </with-param>
- </call-template>
-
- <!-- link everything that shall be a part of the classifier -->
- <apply-templates select="." mode="compiler:entry-classifier" />
- <!-- TODO: get rid of me completely! -->
- <apply-templates select="." mode="compiler:exit-classifier" />
-</template>
-
-
<template match="lv:package" mode="l:link-params">
<param name="deps" />
@@ -990,8 +967,6 @@
</with-param>
</call-template>
- <apply-templates select="." mode="compiler:entry-rater" />
-
<!-- TODO: this list of exclusions is a mess -->
<apply-templates select="." mode="l:do-link">
<with-param name="symbols" select="
@@ -1008,10 +983,6 @@
<sequence select="l:link-exit-fragments(
$rater-exit-fragments,
. )" />
-
- <apply-templates select="." mode="compiler:exit-rater">
- <with-param name="symbols" select="$deps" />
- </apply-templates>
</template>
diff --git a/src/current/standalone.xsl b/src/current/standalone.xsl
index 809a765..59b29fa 100644
--- a/src/current/standalone.xsl
+++ b/src/current/standalone.xsl
@@ -36,10 +36,7 @@
xmlns:preproc="http://www.lovullo.com/rater/preproc">
-<output
- indent="yes"
- omit-xml-declaration="yes"
- />
+<output method="text" />
<include href="include/dslc-base.xsl" />
@@ -54,9 +51,22 @@
<template match="/" priority="5">
<!-- the rater itself -->
<text>var rater = </text>
+ <!-- (moved from linker during TAMER POC linker) -->
+ <call-template name="compiler:entry" />
+ <call-template name="compiler:classifier" />
+ <call-template name="compiler:entry-rater" />
+
<value-of disable-output-escaping="yes" select="/lv:package/l:exec/text()" />
<text>; </text>
+ <!--(moved from linker during TAMER POC linker) -->
+ <call-template name="compiler:exit-rater">
+ <with-param name="name" select="/*/@name" />
+ <with-param name="symbols" select="/*/l:dep/preproc:sym" />
+ <with-param name="mapfrom" select="/*/l:map-from/l:from" />
+ </call-template>
+ <call-template name="compiler:static" />
+
<!-- maps may or may not exist -->
<variable name="map" select="/lv:package/l:map-exec" />
<variable name="retmap" select="/lv:package/l:retmap-exec" />
@@ -64,7 +74,7 @@
<!-- store a reference to the mapper in rater.fromMap() -->
<text>rater.fromMap = </text>
<choose>
- <when test="$map">
+ <when test="/lv:package/l:dep/preproc:sym[@type='map'][1]">
<value-of disable-output-escaping="yes" select="$map/text()" />
</when>
@@ -79,7 +89,7 @@
<!-- return map -->
<text>rater._retmap = </text>
<choose>
- <when test="$retmap">
+ <when test="/lv:package/l:dep/preproc:sym[@type='retmap'][1]">
<value-of disable-output-escaping="yes" select="$retmap/text()" />
</when>