Summary of Language Attributes in Printer Modules
Description
A language attribute is a piece of data associated with a Printer module and referenced by a unique string. The value of a language attribute may be set by a call to SetLanguageAttribute and later retrieved by using the GetLanguageAttribute or ApplyLanguageAttribute functions. This value may be an expression or a procedure.
Frequently, the generated output for a particular Maple input statement varies only in minor details between the supported languages. For example, a Maple if/elif/end if statement is translated to a sequence of conditions and blocks of statements, though the actual syntax of the condition check and the statement blocks will be language-specific.
Language attributes are used to specify these language-specific details of translation without obligating the author of a language module to override PrintHandler routines with AddPrintHandler. Typically their values are set during the definition of a language module, and accessed at execution time by PrintHandler procedures.
The following table lists all the language attributes used in language definitions distributed with CodeGeneration.
ArrayVariable_IndexEnd
ArrayVariable_IndexSeparator
ArrayVariable_IndexStart
ArrayVariable_RangeStart
Block_Begin
Block_DelimitCondition
Block_End
Comment
Comment_FormatEachLine
Endline
For_Begin
For_End
Global
HasArrayReturn
HasBuiltinPower
HasSimultaneousAssignment
If_Begin
If_Else
If_Elsif
If_End
Indent_Base
Indent_Char
Indent_Increment
LibraryInclusion
Module_Begin
Module_End
Name_IsDistinct
Name_IsValid
ParameterSequence_Begin
ParameterSequence_Delimiter
ParameterSequence_Empty
ParameterSequence_End
ParameterSequence_MaxOnLine
Procedure_Begin
Procedure_End
Procedure_ParametersInBody
Statement_End
String_Delimiter
While_Begin
While_End
The following table lists the type and purpose of the language attributes given above. The names arg1, arg2, ... refer to required arguments in the case that the language attribute is a procedure.
Name
Args
Type
Purpose
0
string
end an array index
string to separate indices
in multiply-indexed arrays
begin an array index
integer
offset for array (typically 0 or 1)
begin a block of statements
1
boolean
true if statement arg1 must be
printed within block delimiters; false
otherwise
end a block of statements
format arg1 as a source-code comment
true if multi-line comments
must be formatted line-by-line;
false otherwise
string used to end an output line
4
begin a for loop. arg1 is the loop
variable; arg2 the starting value;
arg3 the end value; arg4 the step size
end of a for loop
declare arg1 as a global variable
true if procedures that return
arrays are permitted; false otherwise
true if language has a built-in
exponentiation operator; false
if true, the target language
supports simultaneous assignments;
`If' statement in if/then/else
statement block; arg1 is the condition
`Else' statement in if/then/else block
`Else if' condition in if/then/else
block; arg1 is the condition
end of if/then/else block
number of indentation characters
to print for every indented line
character used for indentation
to print for each level of indentation
library inclusion command
begin a module definition
end a module definition
2
test if arg1 and arg2 are
distinct identifiers in this language.
tests whether arg1 is a valid
identifier in this language
start of parameter sequence
delimiter between parameters
string to display if procedure
has no parameters.
end of parameter sequence
maximum number of parameters to
display on a single output line
start of a procedure.
arg1 is the procedure return type;
arg2 is its parameter sequence.
end of a procedure.
arg1 is the procedure return type
true if declarations for the
procedure parameters are placed in the
body of the translated procedure;
marker for end of statement
marker for start and end of
string literals
start of while loop; arg1 is
the loop condition
end of while loop
See Also
ApplyLanguageAttribute
GetLanguageAttribute
Printer
SetLanguageAttribute
Download Help Document