Language Definition Module - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Code Generation Package : Language Definition : CodeGeneration/LanguageDefinition/LanguageModule

Language Definition Module



A language definition module is a repository of information necessary for translating intermediate code to a specific target language.

Language Module Exports


A language definition module is a Maple module with the exports PrintTarget, and Printer.  These exports must satisfy certain criteria:


Printer - a valid Printer module.


PrintTarget - a procedure that returns a string, the translated output. In most cases, PrintTarget simply calls Printer:-PrintTarget.

Additional Notes


For Add to work correctly, you must use single-quotes to delay the evaluation of your language module before adding it with Add.  In other words, your module must be of the form 'module() ... end module', and must evaluate to a module definition, not a module. For more information on module definitions, see type,moduledefinition.


The body of the module definition must contain a sequence of calls to Printer commands that define language-specific data, as well as any utility procedures.


Once defined, the module definition must be added to CodeGeneration using the Add command.



m := 'module()
   export PrintTarget, Printer;
   PrintTarget := proc() Printer:-PrintTarget(args); end proc:
   Printer := eval(LanguageDefinition[Get]("default")):-Printer;
   Printer:-AddFunction("sin", [numeric]::numeric, "sine");
   Printer:-AddOperator(Names:-Assignment = "=");
end module':



t0 = sine(x);

See Also

Add, Define, Get, Printer

Download Help Document

Copyright © MathResources Inc. All Rights Reserved.

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam