JET is run in
two phases: translation and generation. The ?¬?rst phase translates the template to a Java
program that will perform the actions speci?¬?ed in the template. The second phase
invokes this program on the input to generate the output. The name of the ?¬?le to be
generated is speci?¬?ed in the ?¬?rst JET tag.
T4 operates on input data consisting of a single C# object, normally a DSL Tools
model, and its commands are written in C#. It uses <# and #> to escape its command
sequences,<#??and #>for direct output, and<#??and #>to escape whole functions
or other class features.
272 GENERATOR DEFINITION
The CodeWorker scripting language operates on input data consisting of a tree
data structure, formed fromthe parse tree produced by a CodeWorker BNF template
from textual input. It uses <% or @ to delimit its commands, which are in
CodeWorker??™s own textual DSL. As CodeWorker uses its own language, it also has
to provide its own library of basic functions for manipulating strings, numbers, ?¬?les,
and so on.
One problem with an output template is that it only allows output to one ?¬?le or
stream. The structure and order of the generation is thus forced to follow that of
each output ?¬?le, with one generator per output ?¬?le. This is inef?¬?cient in cases
where the information needed for more than one ?¬?le can be found in the same place
in the models.
Pages:
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503