add language definition - Maple Help

Online Help

All Products    Maple    MapleSim

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

CodeGeneration[LanguageDefinition][Add] - add language definition

CodeGeneration[LanguageDefinition][Get] - get language definition

Calling Sequence

CodeGeneration[LanguageDefinition][Add](langname, moddef)





string; name of target language



procedure or module definition; defines a target language



The Add function adds definition of the language langname to CodeGeneration's table of recognized languages.  This language is then available for use by Translate and Get.


The Get function retrieves the definition of langname.  Note that Get will return a module definition for any defined language, regardless of whether the language has been defined using Define or Add.


The module definition moddef must satisfy certain criteria: see LanguageModule.


Define a language "AddExample" that translates the sin function as "Sine". Add it to CodeGeneration with Add, and perform a translation.


langdef := proc() module()
   export PrintTarget, Printer;
    PrintTarget := proc() Printer:-PrintTarget(args); end proc:
    Printer := eval(LanguageDefinition[Get]("default")):-Printer;
    Printer:-AddFunction("sin", [anything]::anything, "Sine");
    Printer:-AddOperator(Names:-Assignment = ":=");
end module: end proc:



cg := (double) Sine(x);

See Also

Define, Language Definition Overview, LanguageDefinition, LanguageModule

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