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.
master
Mike Gerwitz 2016-11-17 08:52:37 -05:00
parent 246ccbb1db
commit c199f4739e
3 changed files with 89 additions and 8 deletions

View File

@ -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' )" />

View File

@ -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>

View File

@ -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>