Printer
PrintTarget
print translated code
Calling Sequence
Parameters
Description
Examples
Printer:-PrintTarget(ic, digits, precision, func_precision, namelist)
-
Printer module
ic
Intermediate Code expression
precision
symbol; precision of variables of numeric type
func_precision
symbol; precision of function arguments and return values
namelist
list; names appearing in intermediate code
The PrintTarget command initiates printing of the Intermediate Code expression ic according to the printing rules previously defined for the module Printer. PrintTarget returns a string, which corresponds to the translated output.
In most cases, PrintTarget is called by the PrintTarget procedure of the language definition module containing this Printer, perhaps with some pre- or postprocessing. For example, in a language definition module m, the command m:-PrintTarget may call m:-Printer:-PrintTarget.
Note: The following defines a Fortran translator that converts the output of Printer:-PrintTarget all to uppercase.
with⁡CodeGeneration:
UppercaseFortran77 := 'module() export Printer, PrintTarget; Printer := eval(LanguageDefinition[Get]("Fortran")):-Printer; PrintTarget := proc() StringTools[UpperCase](Printer:-PrintTarget(args)); end proc: end module':
LanguageDefinitionAdd⁡UppercaseFortran,UppercaseFortran77
p1 := proc() sin(x+y*z)+trunc(x); end proc:
Translate⁡p1,language=Fortran
doubleprecision function p1 () p1 = dsin(y * z + x) + dble(int(dint(x))) return end
Translate⁡p1,language=UppercaseFortran
DOUBLEPRECISION FUNCTION P1 () P1 = DSIN(Y * Z + X) + DBLE(INT(DINT(X))) RETURN END
See Also
LanguageModule
Download Help Document