CodeGeneration[LanguageDefinition][Add] - add language definition
CodeGeneration[LanguageDefinition][Get] - get language definition
|
Calling Sequence
|
|
CodeGeneration[LanguageDefinition][Add](langname, moddef)
CodeGeneration[LanguageDefinition][Get](langname)
|
|
Parameters
|
|
langname
|
-
|
string; name of target language
|
moddef
|
-
|
module definition; defines a target language
|
|
|
|
|
Description
|
|
•
|
The Add function adds the module definition that defines 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 module definition defining language 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.
>
|
|
>
|
moddef := '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':
|
>
|
|
>
|
|
|
|
Download Help Document
Copyright © MathResources Inc. All Rights Reserved.
www.mathresources.com
Was this information helpful?