diff options
author | Mike Gerwitz <gerwitzm@lovullo.com> | 2016-11-17 08:56:40 -0500 |
---|---|---|
committer | Mike Gerwitz <gerwitzm@lovullo.com> | 2016-11-17 23:55:23 -0500 |
commit | 1d3aaf3339f30e43ee764e8dd898b382dc9e3e76 (patch) | |
tree | a9e878d95820fbbf1999dcf5d1c8a7eb73bbb7e4 /src/symtable/symbols.xsl | |
parent | f396858fb18b915a0f03e6d02c4aebb55b0000bc (diff) | |
download | tame-1d3aaf3339f30e43ee764e8dd898b382dc9e3e76.tar.gz tame-1d3aaf3339f30e43ee764e8dd898b382dc9e3e76.tar.bz2 tame-1d3aaf3339f30e43ee764e8dd898b382dc9e3e76.zip |
Extracted param symbol generation
The `preproc:param-dim' template must remain for now, as it is used by
others.
* src/current/include/preproc/symtable.xsl
(preproc:symtable)[lv:param]: Extracted template.
* src/symtable/symbols.xsl
(preproc:symtable)[lv:param]: Added template.
* test/symtable/symbols.xsl
(lv:param): Scenario added.
Diffstat (limited to 'src/symtable/symbols.xsl')
-rw-r--r-- | src/symtable/symbols.xsl | 93 |
1 files changed, 90 insertions, 3 deletions
diff --git a/src/symtable/symbols.xsl b/src/symtable/symbols.xsl index 14949c7..3738cea 100644 --- a/src/symtable/symbols.xsl +++ b/src/symtable/symbols.xsl @@ -32,6 +32,7 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:lv="http://www.lovullo.com/rater" xmlns:symtable="http://www.lovullo.com/tame/symtable" + xmlns:_symtable="http://www.lovullo.com/tame/symtable/_priv" xmlns:preproc="http://www.lovullo.com/rater/preproc"> <import href="symbols.xsl.apply" /> @@ -72,9 +73,7 @@ @item dim Dimensions of@tie{}@obj{} as an integer. - Standard dimensions are scalar@tie{}(0), - vector@tie{}(1), - and matrix@tie{}(2). + See @ref{_symtable:str-to-dim#1} for supported strings. @emph{Required} @item dtype @@ -129,6 +128,42 @@ <!-- + Convert a string dimension representation into an integer. + + Standard dimensions are @samp{scalar}@tie{}(0), + @samp{vector}@tie{}(1), + and @samp{matrix}@tie{}(2). + If no value is provided, + then @samp{scalar} is assumed. + All unknown strings will yield a value of @samp{-1}.@footnote{ + That's not to say that @tame{} can't support an arbitrary number + of dimensions; + this syntax just doesn't provide that utility.} +--> +<function name="_symtable:str-to-dim" as="xs:integer"> + <param name="str" as="xs:string?" /> + + <choose> + <when test="empty( $str ) or ( $str = 'scalar' )"> + <sequence select="0" /> + </when> + + <when test="$str = 'vector'"> + <sequence select="1" /> + </when> + + <when test="$str = 'matrix'"> + <sequence select="2" /> + </when> + + <otherwise> + <sequence select="-1" /> + </otherwise> + </choose> +</function> + + +<!-- @node Symbol Types @section Symbol Types @@ -249,6 +284,7 @@ @menu + * Parameters: Parameter Symbols. @code{param} * Templates: Template Symbols. @code{tpl} * Program Metadata: Program Metadata Symbols. @code{meta} @end menu @@ -256,6 +292,57 @@ <!-- + @node Parameter Symbols + @subsection Parameter Symbols + + Global parameters define all inputs to the program. +--> + + +<!-- + Produce a @code{param} symbol with the following attributes: + + @table @code + @item name + Name of the parameter as provided by @pkgns{param/@@name}. + + @item type + The datatype defining the parameter's domain, + as provided by @pkgns{param/@@type}. + + @item dim + Numeric dimension converted from its string representation in + @pkgns{param/@@set}.@footnote{ + The attribute name @pkgns{param/@@set} is unfortunate and simply + incorrect terminology with how it is used. + It will be changed in the future.} + + @item desc + Description as provided by @pkgns{param/@@desc}. + + @item tex + TeX symbol used when rendering parameter in an equation. + + @item keep + Always @samp{true} to ensure that the symbol is retained after + linking. + @end table +--> +<template match="lv:param" mode="preproc:symtable" priority="5"> + <variable name="dim" as="xs:integer" + select="_symtable:str-to-dim( @set )" /> + + <preproc:sym type="param" + name="{@name}" + dim="{$dim}" + desc="{@desc}" + dtype="{@type}" + tex="{@sym}" + keep="true" /> +</template> + + +<!-- @node Template Symbols @subsection Template Symbols |