Creating a Printer module
Customizing a Printer module
A Printer module encodes the instructions necessary to print intermediate code to a specific programming language.
As used above, the term printing refers to the process of translating intermediate code into a string which encodes the equivalent commands in some specific programming language.
Every translator has an associated Printer module. In particular, each language definition module must have an export named Printer, which corresponds to a Printer module.
Essentially, for each name nm in CodeGeneration:-Names, a Printer supplies a Print Handler, which is responsible for ``printing'' (i.e. translating) any subexpression of the Intermediate Code structure that has nm as its zeroth operand.
To create a new, generic Printer module, you can call CodeGeneration[LanguageDefinition][DefaultPrinter]().
It is frequently desirable, however, to use the Printer module from some existing language definition. This is particularly useful when ``extending'' an existing translator, or when the many but not all of the details of translation for the new language are identical to those of an existing one. To make a copy of the Printer module for language name langname, you can call CodeGeneration[LanguageDefinition][Get](langname):-Printer.
Once obtained, a Printer module can be transformed and customized by calling its package functions. The following table lists the package functions of a Printer module.
For examples of creating and customizing a Printer module, see DefaultPrinter, or Get.
Download Help Document
Copyright © MathResources Inc. All Rights Reserved.
What kind of issue would you like to report? (Optional)
Thank you for submitting feedback on this help document. Your feedback will be used
to improve Maple's help in the future.