Maple Professionel
Maple Académique
Maple Edition Étudiant
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professionel
MapleSim Académique
Maple T.A. - Suite d'examens de classement
Maple T.A. MAA Placement Test Suite
Möbius - Didacticiels de mathématiques en ligne
Machine Design / Industrial Automation
Aéronautique
Ingénierie des véhicules
Robotics
Energie
System Simulation and Analysis
Model development for HIL
Modélisation du procédé pour la conception de systèmes de contrôle
Robotics/Motion Control/Mechatronics
Other Application Areas
Enseignement des mathématiques
Enseignement de l’ingénierie
Enseignement secondaire et supérieur (CPGE, BTS)
Tests et évaluations
Etudiants
Modélisation financière
Recherche opérationnelle
Calcul haute performance
Physique
Webinaires en direct
Webinaires enregistrés
Agenda des évènements
Forum MaplePrimes
Blog Maplesoft
Membres Maplesoft
Maple Ambassador Program
MapleCloud
Livres blancs techniques
Bulletin électronique
Livres Maple
Math Matters
Portail des applications
Galerie de modèles MapleSim
Cas d'Etudes Utilisateur
Exploring Engineering Fundamentals
Concepts d’enseignement avec Maple
Centre d’accueil utilisateur Maplesoft
Centre de ressources pour enseignants
Centre d’assistance aux étudiants
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