diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/current/include/preproc/symtable.xsl | 18 | ||||
-rw-r--r-- | src/symtable/symbols.xsl | 93 |
2 files changed, 91 insertions, 20 deletions
diff --git a/src/current/include/preproc/symtable.xsl b/src/current/include/preproc/symtable.xsl index e12e5a4..069c22b 100644 --- a/src/current/include/preproc/symtable.xsl +++ b/src/current/include/preproc/symtable.xsl @@ -71,6 +71,7 @@ <xsl:include href="path.xsl" /> <xsl:include href="../../tame/src/symtable.xsl" /> +<xsl:include href="../../tame/src/symtable/symbols.xsl" /> <!-- we will recurse through the entire tree rather than performing a series of @@ -757,23 +758,6 @@ </xsl:template> -<!-- Will be completed during post-processing so that typedefs can be - properly resolved --> -<xsl:template match="lv:param" mode="preproc:symtable" priority="5"> - <xsl:variable name="dim"> - <xsl:call-template name="preproc:param-dim" /> - </xsl:variable> - - <!-- we use the primitive data type derived from the typedef to ensure that - the system can still make use of the type even when the typedef is not - exported; indeed, typedefs are simply restrictions that need only be - known for compiling (at least at present). Also note the keep="true" to - ensure that all param symbols are retained after linking --> - <preproc:sym name="{@name}" keep="true" - type="param" dtype="{@type}" dim="{$dim}" desc="{@desc}" tex="{@sym}" /> -</xsl:template> - - <xsl:template match="lv:typedef" mode="preproc:symtable" priority="5"> <!-- FIXME: this is a kluge --> <xsl:variable name="dtype" as="xs:string?" 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 |