Add - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


CodeGeneration[LanguageDefinition]

  

Add

  

add language definition

  

Get

  

get language definition

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

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

CodeGeneration[LanguageDefinition][Get](langname)

Parameters

langname

-

string; name of target language

moddef

-

procedure or module definition; defines a target language

Description

• 

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.

Examples

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

withCodeGeneration:

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:

LanguageDefinitionAddAddExample,langdef

Translatesinx,language=AddExample

cg := (double) Sine(x);

See Also

Define

Language Definition Overview

LanguageDefinition

LanguageModule