tame/tamer/tests/xmli
Mike Gerwitz bdd98a5d92 tamer: asg: Require that all template parameters be referenced in body
This ensures that each metavariable defined within a template (a template
parameter) has, by the time that the template definition is ended, at least
one reference to each metavariable.

This has practical benefits---ensuring that you haven't forgotten to use a
metavariable; ensuring that you clean up when code is removed; and ensuring
that you didn't accidentally delete some reference that you didn't intend to
(at least in the case of _all_ references...)---but the rationale for it in
this commit is a bit different.  More on that below.

This does introduce the negative effect of making it more difficult to
consume inputs without utilizing them, acting more like a relevant type
system (in terms of substructural type systems and with respect to
metavariables, at least).  You can for now reference them in contexts that
would reasonably have no effect on the program or be optimized away, but in
the future it'd be nice to explicitly state "hey this isn't intended to be
used yet", especially if you're creating shells of templates, or trying to
maintain BC in a particular situation.  But more on that in the future.

For now, the real reason for this change is because of how I intend for
template expansion to work: by walking the body.  Rather than having to
check both the parameters of the template and then expand the body
separately, we can simply trust that each parameter is referenced.  Then,
after rebinding metavariable references, we can perform the same check on
the expansion template to see if there were arguments provided that do not
correspond to parameters.

This also adds flexibility with parameters that are used
conditionally---we'll be able to have conditionally required parameters in
error reporting.

More information on this is coming, though; it'll be included in the docs of
the commit that introduces the changes.

DEV-13163
2023-09-19 15:58:33 -04:00
..
classify tamer: Replace wip-asg-derived-xmli flag with command line option 2023-06-13 23:23:51 -04:00
combined tamer: Replace wip-asg-derived-xmli flag with command line option 2023-06-13 23:23:51 -04:00
cp tamer: Replace wip-asg-derived-xmli flag with command line option 2023-06-13 23:23:51 -04:00
empty tamer: Replace wip-asg-derived-xmli flag with command line option 2023-06-13 23:23:51 -04:00
meta-interp tamer: NIR->xmli interpolation and template param 2023-07-18 12:31:28 -04:00
package tamer: Replace wip-asg-derived-xmli flag with command line option 2023-06-13 23:23:51 -04:00
rate tamer: Replace wip-asg-derived-xmli flag with command line option 2023-06-13 23:23:51 -04:00
template tamer: asg: Require that all template parameters be referenced in body 2023-09-19 15:58:33 -04:00
.gitignore tamer: tests/xmli: Formatted and more informative output 2023-03-10 14:27:59 -05:00
README.md tamer: Replace wip-asg-derived-xmli flag with command line option 2023-06-13 23:23:51 -04:00
test-xmli tamer: xmli reconstruction of desugared interpolated metavars 2023-07-17 14:20:05 -04:00

README.md

XMLI System Test

The xmli file is an intermediate file that serves as a handoff between TAMER and the XSLT-based compiler:

xml -> (TAMER) -> xmli -> (TAME XSLT) -> xmlo

TAMER gets the first shot at processing, and then the compilation process continues with the XSLT-based compiler. This allows TAMER to incrementally augment and manipulate the source file and remove responsibilities from TAME XSLT.

Tests in this directory ensure that this process is working as intended. TAMER's failure to perform a proper handoff will cause TAME XSLT to compile sources incorrectly, since TAMER will have rewritten them to something else.

This handoff is more than just echoing tokens back into a file---it derives a new program from the state of the ASG. This program may have a slightly different representation than the original sources, but it must express an equivalent program, and the program must be at least as performant when emitted by TAME XSLT.

Experimental Features

If a file is-experimental exists in a test directory, then --emit xmlo-experimental will be used in place of --emit xmlo.

Running Tests

Test are prefixed with test-* and are executable. They must be invoked with the environment variable PATH_TAMEC set to the path of tamec relative to the working directory.

Test cases are organized into sub-directories with src.xml and expected.xml files. src.xml will be compiled with tamec, its output formatted with xmllint --format, and diff'd against the xmllint-formatted output of expected.xml.