The simplest case of this is .h and .c(pp) ?¬?les in C(++) generation,
but other examples abound even where the output language is not so quaintly
repetitive.
For instance, for each source code ?¬?le we output, we often want to add a line to a
make?¬?le. It is most convenient to be able to append that line to the make ?¬?le at the
point where we start to generate the corresponding source code ?¬?le. Using output
templates, we would be forced to duplicate the navigation code that brought us to the
appropriate points in the model.
11.2.4 Crawler: Model Navigation and Output Streams
A DSMgenerator has two tasks: to navigate and read its way around the model, and to
output text based on the model. Model visitors require the modeling language
elements to match the output format elements. Output templates force the navigation
to be sub-ordinate to the output format. A third kind of generator, a crawler, gives
more freedom, while still allowing these two simpler kinds of generation where they
are possible.
Where an output template consists primarily of ?¬?xed text, interspersed with
escaped command sequences, a crawler consists primarily of command sequences,
with ?¬?xed text escaped simply by placing it in string quotes. At its simplest, then, a
crawler looks like an output template, but with the escaping turned inside out.
Pages:
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504