Language Attributes - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


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

ArrayVariable_IndexEnd

0

string

end an array index

ArrayVariable_IndexSeparator

0

string

string to separate indices

 

 

 

in multiply-indexed arrays

ArrayVariable_IndexStart

0

string

begin an array index

ArrayVariable_RangeStart

0

integer

offset for array (typically 0 or 1)

Block_Begin

0

string

begin a block of statements

Block_DelimitCondition

1

boolean

true if statement arg1 must be

 

 

 

printed within block delimiters; false

 

 

 

otherwise

Block_End

0

string

end a block of statements

Comment

1

string

format arg1 as a source-code comment

Comment_FormatEachLine

0

boolean

true if multi-line comments

 

 

 

must be formatted line-by-line;

 

 

 

false otherwise

Endline

0

integer

string used to end an output line

For_Begin

4

string

begin a for loop. arg1 is the loop

 

 

 

variable; arg2 the starting value;

 

 

 

arg3 the end value; arg4 the step size

For_End

0

string

end of a for loop

Global

1

string

declare arg1 as a global variable

HasArrayReturn

0

boolean

true if procedures that return

 

 

 

arrays are permitted; false otherwise

HasBuiltinPower

0

boolean

true if language has a built-in

 

 

 

exponentiation operator; false

 

 

 

otherwise

HasSimultaneousAssignment

0

boolean

if true, the target language

 

 

 

supports simultaneous assignments;

 

 

 

false otherwise

If_Begin

1

string

`If' statement in if/then/else

 

 

 

statement block; arg1 is the condition

If_Else

0

string

`Else' statement in if/then/else block

If_Elsif

1

string

`Else if' condition in if/then/else

 

 

 

block; arg1 is the condition

If_End

0

string

end of if/then/else block

Indent_Base

0

integer

number of indentation characters

 

 

 

to print for every indented line

Indent_Char

0

string

character used for indentation

Indent_Increment

0

integer

number of indentation characters

 

 

 

to print for each level of indentation

LibraryInclusion

1

string

library inclusion command

Module_Begin

0

string

begin a module definition

Module_End

0

string

end a module definition

Name_IsDistinct

2

boolean

test if arg1 and arg2 are

 

 

 

distinct identifiers in this language.

Name_IsValid

1

boolean

tests whether arg1 is a valid

 

 

 

identifier in this language

ParameterSequence_Begin

1

string

start of parameter sequence

ParameterSequence_Delimiter

0

string

delimiter between parameters

ParameterSequence_Empty

1

string

string to display if procedure

 

 

 

has no parameters.

ParameterSequence_End

0

string

end of parameter sequence

ParameterSequence_MaxOnLine

0

integer

maximum number of parameters to

 

 

 

display on a single output line

Procedure_Begin

2

string

start of a procedure.

 

 

 

arg1 is the procedure return type;

 

 

 

arg2 is its parameter sequence.

Procedure_End

1

string

end of a procedure.

 

 

 

arg1 is the procedure return type

Procedure_ParametersInBody

0

boolean

true if declarations for the

 

 

 

procedure parameters are placed in the

 

 

 

body of the translated procedure;

 

 

 

false otherwise

Statement_End

0

string

marker for end of statement

String_Delimiter

0

string

marker for start and end of

 

 

 

string literals

While_Begin

1

string

start of while loop; arg1 is

 

 

 

the loop condition

While_End

0

string

end of while loop

See Also

ApplyLanguageAttribute

GetLanguageAttribute

Printer

SetLanguageAttribute