Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <gerwitzm@lovullo.com>2016-11-17 08:52:37 -0500
committerMike Gerwitz <gerwitzm@lovullo.com>2016-11-17 23:55:23 -0500
commitc199f4739e17e841d90d6bfffce3806b8d0f2254 (patch)
tree513e25644c4f36e7e90438891d9aa555e75a020f
parent246ccbb1db561c4f133294c0f2eed7171647794a (diff)
downloadtame-c199f4739e17e841d90d6bfffce3806b8d0f2254.tar.gz
tame-c199f4739e17e841d90d6bfffce3806b8d0f2254.tar.bz2
tame-c199f4739e17e841d90d6bfffce3806b8d0f2254.zip
Extract template symbol generation
* src/current/include/preproc/symtable.xsl (preproc:symtable)[lv:template]: Extracted template. * src/symtable/symbols.xsl: (preproc:symtable)[lv:template]: Added template. test/symtable/symbols.xsl: Added test case.
-rw-r--r--src/current/include/preproc/symtable.xsl8
-rw-r--r--src/symtable/symbols.xsl42
-rw-r--r--test/symtable/symbols.xspec47
3 files changed, 89 insertions, 8 deletions
diff --git a/src/current/include/preproc/symtable.xsl b/src/current/include/preproc/symtable.xsl
index e7ead95..245a78d 100644
--- a/src/current/include/preproc/symtable.xsl
+++ b/src/current/include/preproc/symtable.xsl
@@ -670,14 +670,6 @@
</xsl:template>
-<xsl:template match="lv:template" mode="preproc:symtable" priority="9">
- <!-- do not process template bodies; we're only interested in the symbols
- they produce after expansion -->
- <preproc:sym name="{@name}"
- type="tpl" dim="0" desc="{@desc}" />
-</xsl:template>
-
-
<xsl:template match="lv:rate" mode="preproc:symtable" priority="5">
<xsl:variable name="external" select="boolean( @external='true' )" />
diff --git a/src/symtable/symbols.xsl b/src/symtable/symbols.xsl
index 21bf54b..ddfbfca 100644
--- a/src/symtable/symbols.xsl
+++ b/src/symtable/symbols.xsl
@@ -246,7 +246,49 @@
statically into the program for static reference without having to
actually invoke the program.
@end table
+
+
+ @menu
+ * Templates: Template Symbols. @code{tpl}
+ @end menu
+-->
+
+
+<!--
+ @node Template Symbols
+ @subsection Template Symbols
+
+ Templates produce a single @code{tpl}@tie{}symbol representing the
+ macro itself.
+ At the time of parsing,
+ we do not care about the body of the template@mdash{
+ }when applied, it will expand into code that will be further
+ processed recursively during another pass to produce the
+ appropriate symbols for that expansion.
+-->
+
+<!--
+ Produce a @code{tpl} symbol with the following attributes:
+
+ @table @code
+ @item name
+ Name of the template as provided by @pkgns{template/@@name}.
+
+ @item dim
+ Always @samp{0};
+ templates are processed as macros before compilation.
+
+ @item desc
+ Template description as provided by @pkgns{template/@@desc}.
+ @end table
-->
+<template mode="preproc:symtable" priority="5"
+ match="lv:template">
+ <preproc:sym type="tpl"
+ name="{@name}"
+ dim="0"
+ desc="{@desc}" />
+</template>
</stylesheet>
diff --git a/test/symtable/symbols.xspec b/test/symtable/symbols.xspec
new file mode 100644
index 0000000..53e8dde
--- /dev/null
+++ b/test/symtable/symbols.xspec
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!--
+ Tests semantic analysis for symbol generation
+
+ Copyright (C) 2016 LoVullo Associates, Inc.
+
+ This file is part of TAME.
+
+ TAME is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see
+ <http://www.gnu.org/licenses/>.
+-->
+<description xmlns="http://www.jenitennison.com/xslt/xspec"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:x="http://www.jenitennison.com/xslt/xspec"
+ xmlns:lv="http://www.lovullo.com/rater"
+ xmlns:preproc="http://www.lovullo.com/rater/preproc"
+ xmlns:foo="http://www.lovullo.com/_junk"
+ stylesheet="../../src/symtable/symbols.xsl">
+
+
+ <scenario label="lv:template">
+ <context mode="preproc:symtable">
+ <lv:template name="_foo_"
+ desc="Test template">
+ <foo:ignored-content />
+ </lv:template>
+ </context>
+
+ <expect label="derives symbol data from template">
+ <preproc:sym type="tpl"
+ name="_foo_"
+ dim="0"
+ desc="Test template" />
+ </expect>
+ </scenario>
+</description>