<\body> Mathemagix source programs are of type and correspond to parse trees of the original Mathemagix source files. Mathemagix programs can be highly ambiguous. During the first phase of the compilation, they are therefore transformed into typed programs of type , each of which has a unique type. The file |../../unstable/syntax/mmx_syntax.mmx> contains several utility routines for the manipulation of programs. These utility routines are usually prefixed by or . The type is an abbreviation for . source programs> Internally, an program is encoded by an expression tree of type (which equals ), each subtree being either of type or . The private conversion routines between the types and are and . The public routines for the syntactic manipulation of programs are <\explain> MMX> MMX> Boolean> Literal> program is a leaf and converting a leaf to a literal.> <\explain> MMX> Boolean> Int> MMX> <|explain> Creation of a compound tree, testing whether an program is a compound tree, obtaining the arity of a compound tree and accessing a child of a compound tree. <\explain> MMXS> MMXS> MMXS> MMXS> MMX> MMX> <|explain> Commodity accessors for the determination of all components of a compound tree (>), of all arguments of a primitive or function call (), of all but its last arguments (), and its last argument (). <\explain> <|explain> Given vectors and of the same length , return the syntactic substitution of each by in . The following syntactic constructors can be used for building declarations: <\explain> <\mmx> $forall (ql: MMXS, decl: MMX): MMX <|explain> These modifiers alter the semantics of a declaration . In the cases of and , the parameter contains a list of signifiers (see below) over which we quantify. In the case of , the parameter contains a list of hypothesis. <\explain> <\mmx> $macro (lhs: MMX, rhs: MMX): MMX <|explain> Declaration of a macro. The left-hand side is either a literal or an expression , where , , ..., are all literals. The right-hand side contains the replacement. <\explain> <\mmx> $header (var: MMX, tp: MMX): MMX of type . should be a literal.>> <\explain> <\mmx> $of (var: MMX, tp: MMX): MMX <|explain> Syntactic construction of a (or typed variable) ``'', for use in combination with , , , , , . etc. should be a literal (exception: typed bodies of lambda expressions).> <\explain> <\mmx> $define (lhs: MMX, rhs: MMX): MMX <\mmx> $assign (lhs: MMX, rhs: MMX): MMX <|explain> Declaration of a constant a mutable variable. The left-hand side is a typed variable of the form ``>'' and the right-hand side contains the (initial) value. In the case of an initialization using inside a constructor, the left-hand side is a literal. <\explain> <\mmx> $category (name: MMX, def: MMX): MMX <\mmx> $class (name: MMX, def: MMX): MMX <\mmx> $module (name: MMX, def: MMX): MMX <|explain> Declaration of a category, class or module. The can be of the form in the case of compound categories, types or modules, where each of the arguments is a signifier. The following predicates can be used for the detection and analysis of declarations: <\explain> <\mmx> declaration?: MMX -\ Boolean <|explain> Checks whether a program is a variable declaration or a forward declaration. <\explain> <\mmx> forall?: MMX -\ Boolean Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> <|explain> Predicates corresponding to , , , , , , , , , , , , , , , , , and . The following accessors can be used in order to analyze declarations: <\explain> <\mmx> postfix .id: MMX -\ Literal <\explain> <\mmx> postfix .var: MMX -\ MMX <\mmx> <\mmx> postfix .of: MMX -\ MMX variable declaration.> <\explain> <\mmx> postfix .lhs: MMX -\ MMX MMX> <|explain> Find the left-hand side and the right-hand side of a (possibly forward) declaration. The right hand side of a forward declaration is the symbolic constant . <\explain> <\mmx> mmx$begin: Tuple MMX -\ MMX MMX> <|explain> Sequential block of instructions. In the case of , the block may also contain local declarations. When using , it is assumed that the local declarations have already been processed. primitive really necessary?> <\explain> <\mmx> $if (cond: MMX, thenp: MMX): MMX <|explain> Conditional instructions or expressions. <\explain> <\mmx> $and (cond1: MMX, cond2: MMX): MMX <|explain> Fundamental boolean operations <\explain> <\mmx> $loop (mods: MMXS, body: MMX): MMX <|explain> Looping construct, where is a list of looping modulators, as described below. <\explain> <\mmx> $for (init: MMX): MMX <|explain> Elementary looping modulators. The modulator contains a variable declaration, or an instruction to be executed once before the loop, or an expression of the form ``'', where is a generator. The and modulators allow for the execution as long as until a certain condition is satisfied. The modulator executes an instruction each time we complete one cycle of the loop. <\explain> <\mmx> $in (sf: MMX, gen: MMX): MMX <|explain> Allows the construction of ``'' as needed by one of the variants of the looping modulator. Here is a signifier of the form ``'' and a generator. <\explain> <\mmx> mmx$break: () -\ MMX MMX> <|explain> Construct for breaking or continuing a loop. <\explain> <\mmx> $lambda (args: MMXS, tbody: MMX): MMX <|explain> Construction of a lambda expression with arguments and a typed body . Each of the arguments and the typed body should be signifiers. <\explain> <\mmx> mmx$return: () -\ MMX MMX> <|explain> Returning the result of a lambda expression. <\explain> <\mmx> $try (body: MMX, handlers: Tuple MMX): MMX <|explain> Constructors for exception handling. The construct attempts to execute . If an error is raised using the construct, then we attempt to handle it using one of the . On failure, the error is reraised outside the block. The following predicates can be used for the detection and analysis of constrol structures: <\explain> <\mmx> begin?: MMX -\ Boolean Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> Boolean> <|explain> Predicates corresponding to , , , , , , , , , , , , , , , and . The following accessors can be used in order to analyze lambda expressions: <\explain> <\mmx> postfix .lambda_args: MMX -\ MMXS MMX> MMX> <|explain> Find the arguments, the (non typed) body and the return type of a lambda expression. The following constants correspond to the syntactic versions of the most basic atomic types: <\explain> <\mmx> mmx$Void: MMX <|explain> The type is used for the generation of the trivial category. The type is used internally as a quantifier for and types. The following functions can be used for the syntactic construction of compound types <\explain> <\mmx> $Alias: MMX -\ MMX MMX> MMX> <|explain> In the case of and , the first argument constains a list of quantifiers and the second argument a quantified type. Each of the arguments should be a signifier. <\explain> <\mmx> mmx$true: MMX mmx$false: MMX mmx$this: MMX mmx$import: MMX mmx$cpp: MMX <|explain> Special constants and keywords. <\explain> <\mmx> mmx$compiled: MMX <|explain> Standard hypothesis for use with . <\explain> <\mmx> mmx$convert: MMX <|explain> Special functions. The following syntactic constructs are invisible to the programmer, but used internally by the compiler. <\explain> <\mmx> $READ (inst: MMX, field: MMX): MMX <|explain> Read and write acces to a of the instance of a class. <\explain> <\mmx> $METHOD (lamb: MMX): MMX <|explain> Assuming that we are inside a class, this construct indicates that the function is a method of the class. During the compilation, a special ``method environment'' is attached to the class environment, which allows other methods to be accessed through short names. <\explain> <|explain> Assuming that we are inside a class, this construct indicates that is the body of a constructor. Such a body is a succession of statements of the form , where is an intern class field and its initial value. <\explain> <|explain> Declares a new type to be equivalent to . <\explain> <\mmx> $PENALTY (pen: Penalty, x: MMX): MMX <|explain> The first routine explicitly attaches a penalty to an object ; if has type , then the result has type . The second routine removes the penalty from an object of type . <\explain> <\mmx> $EXPLICIT (pen: Penalty, x: MMX): MMX <|explain> The first routine converts an object of type to an object of type . The second routine performs the inverse conversion. <\explain> <\mmx> $FORALL (ql: MMXS, tmpl: MMX): MMX <|explain> Template construction and template instantiation. <\explain> <\mmx> $EXISTS (ql: MMXS, tmpl: MMX): MMX <|explain> Abstraction and concretization. <\explain> <\mmx> $as_void (expr: MMX): MMX <|explain> Low level cast of to . In particular, is used as an equivalent for $Void>> in the implementation of >. . If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.> <\initial> <\collection>