Commit Graph

100 Commits (e5bbd49166bd9d59aec6efae19482ab0724c9c4c)

Author SHA1 Message Date
Mike Gerwitz 1f545a11ff preproc: Expand templates in extracted classes
any/all blocks within classifications are extracted into their own
classifications.  When they have sibling nodes, the extracted
classifications did not have their templates expanded.  Ouch.
2018-02-19 11:30:49 -05:00
Mike Gerwitz f15a1bb063 Copyright update (R-T Specialty) 2018-02-01 13:11:52 -05:00
Mike Gerwitz c5fcc3ccd2 template: Add prefix and suffix conditional support (feature)
* src/current/include/preproc/template.xsl (preproc:apply-template-cmp): Add
  @prefix and @suffix.
2018-02-01 13:08:03 -05:00
Mike Gerwitz 9c4fbdace9 symtable: Only consider first lv:rate ancestor for parent (bugfix)
This is a situation that should never happen (I haven't yet determined
whether or not we should support this type of thing in the future), but when
it does, do something intelligent.

* src/current/include/preproc/symtable.xsl (preproc:symtable)[c:*[@generates]]:
  Consider only first ancestor lv:rate.
2018-02-01 13:07:51 -05:00
Mike Gerwitz 854f87a60d template: Remove accidental debug output
* src/current/include/preproc/template.xsl (preproc:apply-template)[@*]:
  Remove debug output.
2018-01-25 15:39:20 -05:00
Mike Gerwitz 78ea30e7b5 Retain unknown template param references during expansion
For example, with template-generating templates, if a reference is unknown
and therefore determined to be blank, an attribute might be completely
removed while the template is being generated.  (See the /when package in
core for an example.)  That is not good.

* src/current/include/preproc/template
  (preproc:expand-template): Add `tpl' tunneling param to
    preproc:apply-template application.
  (preproc:apply-template)[@*]: Retain param reference if applying template
    does not define it.
2018-01-25 14:53:31 -05:00
Mike Gerwitz 87a059f0c8 Retain template conditionals verbatim if param unknown
This is important for template-generating templates.

* src/current/include/preproc/template.xsl (lv:if,lv:unlesS):
  Retain conditional nodes verbatim when referenced param is unknown.
2018-01-18 15:44:12 -05:00
Mike Gerwitz 211387ce2f Mark generated @yields on classes and rate-each as such on symbols
* src/current/include/preproc/expand.xsl
  (lv:classify): Set `@preproc:yields-generated' if `@yields' was not
    previously defined.
* src/current/include/preproc/macros.xsl:
  (lv:rate-each): Set `@preproc:yields-generated` if `@yields' was not
    previously defined.
* src/current/include/preproc/symtable.xsl:
  (lv:rate, lv:classify): Set `@preproc:generated` on symbol if
    `@preproc:yields-generated'.
2018-01-16 12:12:33 -05:00
Mike Gerwitz f8d21c1c5f summary: Correct height of pipes denoting length
* src/current/include/calc-display.xsl
  (c:sum[@of], c:length-of): Add `\left', `\right'.
* src/current/summary.xsl: Update "N.B." section.
2018-01-11 08:42:04 -05:00
Mike Gerwitz a62d155eb0 Resolve lv:param-add/@value before processing
* src/current/include/preproc/template.xsl
  (preproc:gen-param-value)[lv:param-add]: Resolve value of @value before
    processing numeric expression (to support template variables).  Error
    when any values are not numeric rather than producing NaN.
2018-01-04 11:05:58 -05:00
Mike Gerwitz d8c7d8fee2 Ignore constant parsing for template param references
This is imperfect, but will work based on current assumptions.

* src/current/include/preproc/expand.xsl (preproc:expand)[c:const,lv:const):
  If '@' is found, do not perform expansion.
2018-01-04 11:04:55 -05:00
Mike Gerwitz 4ed63b3661 summary: Remove index underscores from TeX
They corrupt the display.  This solution isn't ideal, though.

* src/current/include/calc-display.xsl: Use new `preproc:tex-index'.
  (preproc:tex-index): Add function.
* src/current/summary.xsl: Use `preproc:tex-index' for @index display.
2017-12-22 11:07:24 -05:00
Mike Gerwitz 55bd91d05e summary: Simplify display of generators in let list
* src/current/include/display.xsl (preproc:dim-to-str): New function.
  (summary:desc): Use it.  Display appropriate generator dimensions as a
  string rather than hard-coding to `vector'.  Remove yield symbol ref.
2017-12-21 13:39:05 -05:00
Mike Gerwitz 61279a36dc summary: Remove parenthesis from let list symbol refs
* src/current/include/display.xsl: Remove parenthesis around let list
  symbols.
* src/current/summary.xsl: Remove parenthesis around generator symbol.
2017-12-21 13:32:09 -05:00
Mike Gerwitz aba2e7a5b2 summary: Add const description in let list
* src/current/include/display.xsl (summary:desc): Include const @desc in let
  list.
2017-12-21 13:28:17 -05:00
Mike Gerwitz 97977332d5 summary: Correct length notation
Vector length is customarily denoted by |V|.

* src/current/include/calc-display.xsl (c:sum, c:length-of): Use new
  notation.
* src/current/summary.xsl: Update N.B. with new notation.
2017-12-21 13:18:41 -05:00
Mike Gerwitz 39e83a80d0 preproc: Add `param-sym-value' for templates
* src/current/include/preproc/template.xsl
  (preproc:gen-param-value)[lv:param-sym-value]: New template.
* src/current/rater.xsd (templateParamGenGroup): Add `param-sym-value'.
2017-12-21 10:42:20 -05:00
Mike Gerwitz 0f88b902a9 summary: Correct rendering of externs 2017-12-20 16:49:34 -05:00
Mike Gerwitz c59ed64d4e macros: Ignore preproc:tpl-barrier during class conversion
* src/current/include/preproc/macros.xsl
  (preproc:macros): Only consider lv:* in counts.  Ignore preproc:*.
2017-12-19 16:51:18 -05:00
Mike Gerwitz c99e4d00f6 symtable: Override local status of imported symbols
When a symbol is imported as local, and subsequently directly imported using
another package with @export, the symbol needs to be overridden as
non-local.

* src/current/include/preproc/symtable.xsl
  (preproc:sym-discover): Deduplicate based on local status.
  (preproc:symtable-process-symbols): Retain non-local symbols when only
    local version of the symbol exists.
2017-12-19 16:48:44 -05:00
Mike Gerwitz 62c4ce402c preproc: Copy rate-each/@dim only if it exists
If it is copied an yields an empty value, then it is later converted into a
0, which is wholly incorrect in the case of generators.

* src/current/include/preproc/macros.xsl (preproc:macros)[lv:rate-each]:
  Conditionally copy `@dim'.
2017-12-19 14:21:08 -05:00
Mike Gerwitz dd42267bc9 summary: Render package descriptions on entry form 2017-12-14 12:13:21 -05:00
Mike Gerwitz c98ece9d68 summary: Group params on entry form by package
* src/current/include/entry-form.xsl: Group entry form params.
2017-12-14 12:13:21 -05:00
Mike Gerwitz dc5e5b74dc summary: Correct rendering of classifications using equations
* src/current/include/calc-display.xsl (calc-iversons)[recurse]: Add
    parameter.  Conditionally recurse.
* src/current/summary.xsl (match-desc): Properly process c:* children.
2017-12-14 12:13:21 -05:00
Mike Gerwitz 2ccf78544a summary: Angry fruit salad
This adds a great deal of colorful styling to make the Summary Page a bit
easier to understand at a glance.
2017-12-14 12:13:18 -05:00
Mike Gerwitz 22b4d37317 preproc: Optimize away c:{sum,product} containing preprocessed lv:*
This optimization (which already existed) is supposed to remove
c:sum/c:product nodes if they contain one or fewer calculations, but it
failed to remove them when inline templates were used (because it creates,
well, a template inline).

Instead, we'll assume that any lv:* nodes handled by the preprocessor will
be okay.  In the case of inline templates, they receive a preproc attribute
identifying what created it.

I hope this is a valid assumption.  This will be thoroughly tested.  If only
we had test cases for the preprocessor.

* src/current/include/preproc/expand.xsl: (preproc:expand)[c:sum,c:product]:
    Consider optimization for `lv:*[@preproc:*]'.
2017-12-13 13:50:24 -05:00
Mike Gerwitz 5e5458dd3b summary: Add param text case dfn below input
The idea is to provide some guidance with how YAML test cases are supposed
to appear.

This just adds to the massive cluster that is the `entry-form.js'.

* src/current/include/entry-form.xsl (entry-form)[preproc:sym]: Add
    `entry-testcase-dfn' div.
* src/current/scripts/entry-form.js: Invoke `updateParamTestcaseDfn' in
    various event listeners.
  (populateBucket): Invoke `updateParamTestcaseDfn'.
  (updateParamTestcaseDfn, getParamTestcaseDfnElement): New functions.
* src/current/summary.css: Style `.entry-testcase-dfn'.
2017-12-11 15:25:31 -05:00
Mike Gerwitz d612c593b2 summary: Add param names and links aside desc in entry form
This existed in the old summary pages.  Since we'll be having certain people
reference ids, they need to be easily visible from somewhere.

* src/current/include/entry-form.xsl (preproc:sym)[entry-form]: Add param
    name and link.
* src/current/summary.css: Style it.
2017-12-11 14:03:02 -05:00
Mike Gerwitz 838ddb6e32 summary: Correct rendering of nested c:let expressions
If nested c:let expressions contained values of the same name, they would
all be rendered, rather than just the one intended.

* src/current/include/display.xsl (do-gen-let-list): Pass let symbol to
    `_gen-let-list-item'.
  (_gen-let-list-item): Render only values part of context let expression.
    [letsym]: New parameter.
2017-12-11 10:50:51 -05:00
Mike Gerwitz e78c3cbe98 symtable: Add @lparent to let lparam symbols
* src/current/include/preproc/symtable.xsl (preproc:symtable)[c:let]:
    Add @lparam to symbol.
2017-12-11 10:50:49 -05:00
Mike Gerwitz a38327b505 expand: Continue macro expansion after @dim conversion
This was recently introduced and was noticed because c:let/@name was not
being generated under certain circumstances.

* src/current/include/preproc/expand.xsl (preproc:expand): Continue applying
    templates after @dim expansion (rather than copying child nodes).
2017-12-11 10:42:52 -05:00
Mike Gerwitz f38e6c896b Add template barriers for metadata
This (hopefully) prevents metadata from leaking outside of template
expansions where they are not wanted.

* src/current/include/preproc/macros.xsl (preproc:macropass): Strip
    cruft (new barrier nodes) on final pass.
* src/current/include/preproc/template.xsl (preproc:expand-template):
    Enclose template expansion in preproc:tpl-barrier (which is stripped on
    the final pass).
  (preproc:apply-template)[lv:param-meta]: Document template.  "Hoist"
    node (set attribute) if not contained within lv:param-copy.
  (preproc:gen-param-value)[lv:param-inherit]: Consider hoisted nodes behind
    barrier.
2017-12-08 14:48:59 -05:00
Mike Gerwitz 2f8ce0f234 Mark toplevel nodes affected by template expansion
This allows for debugging expansions, which are otherwise confusing and
difficult.  This will be valuable information for the Summary Pages as
well (see future commit).

* src/current/include/preproc/template.xsl (preproc:expand-template): Mark
    toplevel nodes after expansion.
  (preproc:mark-tpl-expansion): Add templates.
2017-12-08 13:53:12 -05:00
Mike Gerwitz c5e67861c9 depgen: Do not perform dependency generation within templates
This makes me slightly uncomfortable because I haven't researched why
exactly this was not a problem before.  We encountered this issue using an
inline template iterating over the symbol table yielding a `c:value-of',
which is admittedly something that we haven't done before.

Hopefully it's an isolated case.

I diffed the offending object file and the entire linked tax calculator and
they were bit-for-bit identical, so we're probably good.

* src/current/include/depgen.xsl (preproc:depgen): Do not perform dependency
    generation within templates.
2017-12-06 14:39:54 -05:00
Mike Gerwitz 2878d1099c Defer inline-templates with sym-set until symtable is available
Other code relied on expand-sequence, but this really should be implicit,
since it is deceptively useless otherwise.

* src/current/include/preproc/template.xsl (preproc:macros): Defer
    processing of inline-template with sym-set until symbol table is
    available.
2017-12-05 15:07:29 -05:00
Mike Gerwitz 0fb1bae487 Add c:sum/@dim
This allows the result of a rate block to be a matrix; there was previously
no way for a named value to be assigned a matrix unless it was a parameter.

This is a bit of a kluge---the compiler won't discover the proper type
information and won't perform the proper safeguards.

* src/current/calc.xsd (sum)[@dim]: Add attribute.
* src/current/compiler/js-calc.xsl: Add xs namespace.
  (compile-calc): Do not perform casting when @dim > 1.
* src/current/include/preproc/expand.xsl
  (lv:rate-each): Include @dim in c:sum expansion.
* src/current/include/preproc/macros.xsl:
  (c:*/@generates): Use @dim to determine symbol dimensions.
* src/current/include/preproc/expand.xsl: Parse @dim aliases (e.g. "vector",
  "matrix").
2017-12-04 13:39:55 -05:00
Mike Gerwitz ef1e6735b6 entry-form: Correct rendering of params using imported typedefs
If a param referenced a typedef that was imported from another package, the
summary page displayed an error rather than rendering the field.  This is a
problem for testing using summary pages!

Long-standing bug with a fairly easy fix.

* src/current/include/entry-form.xsl:
  (entry-form-field lv:param): Consider correct symbol (was using param
    symbol, not typedef).
  [typesrc]: Modernize syntax.
  [typedef]: Allow for non-root-child elements.  The old version of TAME
    required toplevel typedefs; that's no longer the case.
2017-11-29 13:22:29 -05:00
Mike Gerwitz e52d6c1eb0 depgen: Add error for rate block name conflicts
This can occur during template expansion if the user is not careful in
ensuring that all generated blocks will have unique names.  The error was
not useful: it failed type validation, which results in an internal error in
the compiler (from the user's perspective) and outputs no useful information
to aid in debugging.

* src/current/include/depgen.xsl
  (preproc:depgen preproc:sym): User-friendly error if more than one rate
    element.
  [rate]: Allow multiple rate elements.
2017-11-29 13:19:41 -05:00
Mike Gerwitz dbb368ab34 macros.xsl: Remove unnused param boolean class generation
A classification used to be generated for each param for convenience;
this has been deprecated by the progui package generation (when `q:'
is used).

* src/current/include/preproc/macros.xsl: Remove template.
2017-07-12 15:58:39 -04:00
Mike Gerwitz 2af0daceb3 Remove @keep support from linker
And everything else.

This is a big (important) change; it addresses one of the greatest
pains of the system.

Keeps were added during the DSL rewrite (to support symbols and such)
to work around the issue that there was no symbol-driven map; it
allowed symbols to persist disjoint from the `__yield' dependency
graph so that they could be mapped back and used by external systems.

The problem with that is that it's both messy (coupling the concept of
external dependencies with the actual code) and difficult to work
with.  It had a huge performance impact on the linker for two reasons:

  - Checking whether a package had already been seen and importing the
    keeps on first visit was expensive because of tree searching and
    manipulation; and
  - _every_ keep was imported and processed by the linker, even if it
    wouldn't end up being used by a particular program.

The later especially had huge performance impacts on the entire
system.

The entire dependency graph is now map-driven, with the exception of
the implicit `__yield' (which will eventually be moved into the map as
well and the magic `lv:yield' removed in favor of a template).

Performance-wise: our largest program ("dwelling") has many thousands
of symbols and the largest package imported the majority of them, many
of them unneeded, as the result of @keep subgraphs.  Compilation of
the largest package within that (for the UI) took about a minute and a
half and ate up ~6GiB of RAM, for what really is a trivial task of
resolving externs, some basic symbol processing, a topological sort,
and ordering code fragments.

After this change, it takes ~15s and less than 2GiB of RAM.  Still a
lot---and more improvements can be made---but much, much better.

@keep and friends was left in rater.xsd so that nothing breaks while
code is cleaned up; it'll be removed in the future.

* src/current/compiler/linker.xsl: Remove @keep support.
* src/current/dot/attr-keep.xsl: Remove now-unneeded template.
* src/current/dot/defnode.xsl: Remove @keep and related.
* src/current/include/preproc/eligclass.xsl: Remove @keep and related.
* src/current/include/preproc/expand.xsl: Remove @keep and related.
* src/current/include/preproc/macros.xsl: Remove @keep and related.
* src/current/include/preproc/symtable.xsl: Remove @keep and related.
* src/current/rater.xsd: Add TODO to remove @keep and friends.
2017-07-12 15:58:37 -04:00
Mike Gerwitz 52c1bb5ebe Properly resolve paths of symbols of imports
This solves a long-standing problem whereby relative paths are not
properly resolved, leading to incorrect symbol conflicts when relative
paths to the same package vary between two imports.

See doc/notes/path-processing for an illustration.

* src/current/include/preproc/path.xsl
  (preproc:resolve-relative-import): Add function.
  (preproc:resolv-path, preproc:resolve-path, preproc:get-path): Add
  functions to invoke existing templates.
* src/current/include/preproc/symtable.xsl (preproc:symimport): Use
  `preproc:resolve-relative-import'.
* doc/notes/path-processing: Add notes.
2017-07-12 14:32:33 -04:00
Mike Gerwitz 7d9fb48e11 Strip `xsl' namespace prefix from path.xsl
This also sets the XSLT version to 2.0.

* src/current/include/preproc/path.xsl: Strip `xsl' namespace prefix.
2017-07-12 10:10:45 -04:00
Mike Gerwitz 8e5666f845 Ignore externs in local polluting symbol processing
* src/current/include/preproc/symtable.xsl (preproc:symimport lv:import):
  Ignore symbols flagged as externs when processing local polluted symbols.
2017-07-05 13:52:02 -04:00
Mike Gerwitz 1d3aaf3339 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.
2016-11-17 23:55:23 -05:00
Mike Gerwitz f396858fb1 Extracted meta symbol generation
* src/current/include/preproc/symtable.xsl
  (preproc:symtable)[lv:meta]: Extracted template.

* src/symtable/symbols.xsl
  (preproc:symtable)[lv:meta]: Added template.

* test/symtable/symbols.xsl
  (lv:meta): Scenario added
2016-11-17 23:55:23 -05:00
Mike Gerwitz c199f4739e 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.
2016-11-17 23:55:23 -05:00
Mike Gerwitz 0c2ef00e51 lv:classify/@desc whitespace normalization during macropass
This allows for nice formatting with newlines (to avoid excessively long
lines) without affecting the output.

* src/current/include/preproc/expand.xsl
  (preproc:expand lv:classify/@desc): Normalize lv:classify/@desc whitespace
2016-10-25 11:40:08 -04:00
Mike Gerwitz 5a9fb0d142 lv:classify/@set stripped from macropass
This is no longer used.

* src/current/include/preproc/expand.xsl (lv:classify):
  Remove `@set' processing.
2016-10-25 11:37:46 -04:00
Mike Gerwitz c0d95b4a05 Add copyright headers to src/current/ 2016-08-24 12:38:03 -04:00
Mike Gerwitz ff01f39c1e Liberate current implementation of "Calc DSL"
(Copyright headers will be added in the next commit; these are the
original files, unaltered in any way.)

The internal project name at LoVullo is simply "Calc DSL".  This
liberates the entire thing.  If anything was missed, I'll be added
later.

To continue building at LoVullo with this move, symlinks are used for
the transition; this is the exact code that is used in production.

There is a lot here---over 25,000 lines.  Much of it is in disarray from
the environment surrounding its development, but it does work well for
what it was intended to do.

(LoVullo folks: fork point is 65723a0 in calcdsl.git.)
2016-08-24 12:38:00 -04:00