Special symbols

The compiler uses several special symbols for representing auxiliary programs and storing special information in environments. A hopefully exhaustive list follows below. We will have to modify some names and ensure that no name clashes can occur.

Add section on global variables.

Constructs for auxiliary programs

as_void

This is a special converter for an expression of any type into Void.

BEGIN

Programs BEGIN (prg1, …, prgn) represent sequential blocks in which prg1 until prgn have already been declared. In particular, the declaration phase transforms input programs of the form begin (prg1, …, prgn) into auxiliary programs of the form BEGIN (prg1', …, prgk') which will next be passed to the routine compile.

READ

Programs READ (this, var: tp) represent read-only field access for class fields.

WRITE

Programs WRITE (this, var: tp) represent writable field access for class fields.

METHOD

Programs METHOD (lambda (this: This): R do prg) represent methods of classes and result in the possibility to denote this.var directly by var inside prg.

CONSTRUCT

Programs CONSTRUCT (prg, This) correspond constructors for the class This.

Lambda

The program Lambda (name, locs, params, body, rtype) stands for an unnested lambda expression with given name, parameters params, body and return type rtype. The parameter locs stands for non-global variables which are referred to from within the body, without being declared in the body and without being among the parameters.

group

This construct is used for auxiliary programs during the building phase. It corresponds to a block of commands which is not directly a begin.

A cleaner solution might be implemented.

Special environment variables

==> (sym)

If sym is a macro, then this environment variable is set to the body of that macro.

At the moment, macros with parameters are not yet implemented.

Macros importation is not yet handled either for modules.

%return_type (also mmx_return_type)

This variable contains the expected return type when compiling the body of a lambda expression.

%env_type (also mmc_env_type)

This variable contains the type of the environment under consideration, among top, lambda, class and module.

%class_name (also mmc_class_name)

Name of the current class or module being declared.

%class_mode (also mmc_class_name)

Current declaration mode for classes and modules among extern, intern, method or constructor.

%class_access (also mmc_class_access)

Current access mode for declarations among constant and mutable.

%class_privacy (also mmc_class_privacy)

Visibility of declarations among public and private.

%class_overload (also mmc_class_overload)

Overloading mode for declarations among preemptive (variables are completely redeclared in inner environment) or extensive (variables overload variables of the same name in the parent environment).

Not yet implemented.

%class_fields (also mmc_class_fields)

Vector with all fields of the current class being declared.

%class_methods (also mmc_class_methods)

Environment which is used for the compilation of methods. Methods are rewritten into the form METHOD (lambda (this: This): R do prg) and the METHOD primitive has the effect of selecting the method environment. This environment has macro declarations meth ==> this.name for all methods meth.

Converter management

converters ()

The environment variable with the list of all converter definitions in the current environement. This list of converters is constructed during the declaration phase. All other environment variables for converter management below are only used for caching potentially expensive computations.

:> (F, T)

The converter from an atomic type F into another atomic type T. This converter is given in the form of a function which takes a compiled program of type F on input and returns the compiled converted program of type T.

penalty (F, T)

Penalty for the conversion from F to T.

left_tr (F, T)

Left transitivity of the converter from F to T (true or false).

right_tr (F, T)

Right transitivity of the converter from F to T (true or false).

incoming ()

Table t with incoming converters. Given a type T, the value t[T] is again a table and t[T][F] is set if there is a converter from F to T.

outgoing ()

Table t with outgoing converters. Given a type F, the value t[F] is again a table and t[F][T] is set if there is a converter from F to T.

converter (F, T)

List of converters (of type CONVS) from a general type F into T.

joiner (T, U)

List of possible joins between types T and U (used by if-then-else).

applier (F, A)

List of possible function applications for a function of type F to a list of arguments of type A.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License. If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.