Maple für Professional
Maple für Akademiker
Maple für Studenten
Maple Personal Edition
Maple Player
Maple Player für iPad
MapleSim für Professional
MapleSim für Akademiker
Maple T.A. - Testen & beurteilen
Maple T.A. MAA Placement Test Suite
Möbius - Online-Courseware
Machine Design / Industrial Automation
Luft- und Raumfahrt
Fahrzeugtechnik
Robotics
Energiebranche
System Simulation and Analysis
Model development for HIL
Anlagenmodelle für den Regelungsentwurf
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematikausbildung
Technik
Allgemein- und berufsbildende Schulen
Testen und beurteilen
Studierende
Finanzmodelle
Betriebsforschung
Hochleistungsrechnen
Physik
Live-Webinare
Aufgezeichnete Webinare
Geplante Veranstaltungen
MaplePrimes
Maplesoft-Blog
Maplesoft-Mitgliedschaft
Maple Ambassador Program
MapleCloud
Technische Whitepapers
E-Mail Newsletters
Maple-Bücher
Math Matters
Anwendungs-Center
MapleSim Modell-Galerie
Anwenderberichte
Exploring Engineering Fundamentals
Lehrkonzepte mit Maple
Maplesoft Welcome-Center
Resource-Center für Lehrer
Help-Center für Studierende
CodeGeneration[LanguageDefinition][Define] - define a target language module
Calling Sequence
CodeGeneration[LanguageDefinition][Define](lang, extend=ext_lang, f1, f2,...)
Parameters
lang
-
string; name of target language
ext_lang
(optional) string; name of language to extend
f1, f2, ...
function calls with the function name being one of AddFunction, AddFunctions, AddOperator, AddPrintHandler, AddType, or SetLanguageAttribute
Description
The Define function defines a language for use with CodeGeneration.
f1, f2, ... can be any number of function calls, with the function's name (zeroth operand) being one of AddFunction, AddFunctions, AddOperator, AddPrintHandler, AddType, SetLanguageAttribute. These function calls accept exactly the same syntax as the Printer functions of the same name.
When ext_lang is provided, the resulting language definition module is identical to the module for language ext_lang, except where the function calls f1, f2, ... override the data of ext_lang. This provides a convenient mechanism for altering a language in simple ways and testing the result.
Note: In the user-defined procedures added through the function calls f1, f2, ... , it is often necessary to refer to exports of a Printer module, such as Indent, Print, or GetPrecedence. For correct behavior, every occurrence of these Printer exports within user-defined procedures must be explicitly declared as Printer exports by prefixing them with 'Printer:-', for example, Printer:-Indent, Printer:-Print. Otherwise, these references will not be properly handled by Define.
Examples
Define a custom language DefineExample, using the pre-defined ANSI C as a base, which uses tab characters for indentation and := for assignment. Translate a simple expression to the language DefineExample.
LanguageDefinition[Define]("DefineExample", extend = "C", SetLanguageAttribute( "Indent_Char" = " ", # use tab character for indentation "Indent_Base" = 1, "Indent_Increment" = 1 ), AddOperator( Names:-Assignment = ":=" ), AddPrintHandler( Names:-Integer = proc(x) Printer:-Print( convert(x, 'string') ) end proc ) );
cg := sin(x);
See Also
Add, Language Definition Overview, LanguageDefinition, LanguageModule, Printer
Download Help Document
Copyright © MathResources Inc. All Rights Reserved.
www.mathresources.com