Language Definition Module
|
Description
|
|
|
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.
|
|
|
Examples
|
|
>
|
|
>
|
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':
|
>
|
|
>
|
|
|
|
Download Help Document
Copyright © MathResources Inc. All Rights Reserved.
www.mathresources.com
Was this information helpful?