Intermediate Code Names - Maple Help

Home : Support : Online Help : Programming : Code Generation Package : Intermediate Code Names

Intermediate Code Names

 • The basic structure on which both built-in and user-created language definitions operate is the intermediate form, an expression tree made of nested function calls representing a simplified form of the Maple input.
 • For a detailed listing of the members of the CodeGeneration:-Names subpackage and their function within the intermediate form, see Intermediate Code Structure.
 • The names of the functions in the intermediate form are members of the Names subpackage of the CodeGeneration package.  When writing a language definition module, it is frequently necessary to refer to these names, and is therefore often useful to use the use statement with the CodeGeneration:-Names subpackage.

Examples

 > $\mathbf{use}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{CodeGeneration}:-\mathrm{Names}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{{\mathrm{CodeGeneration}}_{\mathrm{LanguageDefinition}}}_{\mathrm{Define}}\left("SomeLanguage",\mathrm{extend}="default",\mathrm{AddOperator}\left(\mathrm{Assignment}=":="\right),\mathrm{AddPrintHandler}\left(\mathrm{Integer}=\left(x→\mathrm{Printer}:-\mathrm{Print}\left(\mathrm{convert}\left(x,'\mathrm{string}'\right)\right)\right)\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end use}:$
 > $\mathrm{CodeGeneration}\left[\mathrm{Translate}\right]\left(\left[x=2\right],\mathrm{language}="SomeLanguage"\right)$
 x := 2;
 > $\mathrm{CodeGeneration}\left[\mathrm{LanguageDefinition}\right]\left[\mathrm{Define}\right]\left("SomeOtherLanguage",\mathrm{extend}="SomeLanguage",\mathrm{AddFunction}\left("GAMMA",\left[\mathrm{numeric}\right]::\mathrm{numeric},"gamma"\right),\mathrm{AddFunction}\left("GAMMA",\left[\mathrm{integer}\right]::\mathrm{numeric},"gamma"\right),\mathrm{AddFunction}\left("factorial",\left[\mathrm{integer}\right]::\mathrm{numeric},x→\mathrm{Printer}:-\mathrm{Print}\left(\mathrm{CodeGeneration}:-\mathrm{Names}:-\mathrm{Sum}\left(\mathrm{CodeGeneration}:-\mathrm{Names}:-\mathrm{FunctionCall}\left(\mathrm{Name}\left("GAMMA"\right),\mathrm{CodeGeneration}:-\mathrm{Names}:-\mathrm{ExpressionSequence}\left(x\right),\left[\mathrm{integer}\right]::\mathrm{numeric}\right),\mathrm{CodeGeneration}:-\mathrm{Names}:-\mathrm{Integer}\left(1\right)\right)\right)\right)\right):$
 > $\mathrm{CodeGeneration}\left[\mathrm{Translate}\right]\left(n!,\mathrm{language}="SomeOtherLanguage"\right)$
 cg := gamma(n) + 1;