diff options
-rw-r--r-- | src/current/include/preproc/symtable.xsl | 8 | ||||
-rw-r--r-- | src/symtable/symbols.xsl | 42 | ||||
-rw-r--r-- | test/symtable/symbols.xspec | 47 |
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> |