Important: The maple2intrep and intrep2maple commands have been deprecated. Use the superseding commands ToInert and FromInert instead to translate between Maple expressions and corresponding inert forms.

•

The maple2intrep function is used to convert a Maple procedure f into an intermediate representation for the procedure that is suitable for manipulating the code of f. The intermediate representation is an abstract syntax tree. The maple2intrep function also deduces the types of all parameters, local variables, and global variables in f. The intrep2maple function is used to convert an abstract syntax tree t to a Maple procedure.

•

The abstract syntax tree has the following structure. Express it by using a modified BNF grammar where:

* indicates zero or more occurrences

+ indicates one or more occurrences

[] indicate optional terms, and

| indicates alternatives.

tree ::= Proc( Name( declaration ),

Parameters( declaration* ),

Options( sequence ),

Description( string ),

Locals( declaration* ),

Globals( declarations* ),

StatSeq( statement* ) )

declaration ::= name :: type

statseq ::= StatSeq( statement* )

statement ::= expression |

Assign( name, expression ) |

If( [condition, statseq]+, [statseq] ) |

For( name, from, by, to, while, statseq ) |

For( name, in, while, statseq ) |

Return( sequence ) |

Error( sequence ) |

Break( ) |

Next( ) |

Read( string ) |

Save( sequence ) |

Comment( ... ) |

Quote( expression ) |

Ditto1( ) |

Ditto2( ) |

Ditto3( ) |

tree |

Nargs( ) | Args[i] | Args

•

In the abstract syntax tree, the names and Maple expressions become global and will evaluate.

Note: In the event that the parameter or local names in the procedure have global values, and it is desirable to use local names instead (to prevent evaluation problems with respect to the variable names), the option outputvars&equals;locals can be used.

When working with the abstract syntax tree, be careful not to evaluate parts of the tree, or else, use the `tools/rename` command to rename all symbols in the tree to unique names that do not evaluate. The library routine `tools/unrename` can be used to undo this renaming. An example is given below.

Examples

Important: The maple2intrep and intrep2maple commands have been deprecated. Use the superseding commands ToInert and FromInert instead to translate between Maple expressions and corresponding inert forms.

Maplesoft™, a subsidiary of Cybernet Systems Co. Ltd. in Japan, is the leading provider of high-performance software tools for engineering, science, and mathematics. Its product suite reflects the philosophy that given great tools, people can do great things.