The Interface Generator (itf)

The Interface tool is invoked from the Generators Environment and takes as input a source interface description file, with file extension `.itf'.

An option to introduce an `Interface of Implemented Machine' is available under the Tool Bar Introduce.

The general form of an interface description is given in a BNF-like syntax as follows:
the syntax exp1 | exp2 indicates exp1 or exp2 (choice),
<< exp >> indicates zero or more occurrences of exp (repetition) and
[| exp |] indicates optionality.

  interface_description ::=   INTERFACE
                                interface_name | interface_name(params)
                              [|
                               IMPORTS
                                 imp_construct << , imp_construct >>
                              |]
                              OPERATIONS
                                operation_list
                              END

  interface_name        ::=  Identifier

  imp_construct         ::=  Identifier ( param << , param >> )

  param                 ::=  Identifier |  Bnumber

  operation_list        ::=  Identifier << , Identifier >>
The interface name must be that of a MACHINE for which an appropriate analysed implementation exists (see below). The OPERATIONS clause identifies those operations which the user wants to appear in the interface (i.e. be `in-scope' for testing) and should be valid operations of the referenced specification; an error will be reported otherwise.

If the MACHINE is parameterised, the parameters must be set in the INTERFACE; an error will be reported otherwise.

Since the interface is the top level of a development, all machines which are SEEN but not IMPORTED at a lower level need to be imported at this interface level. If such a machine is parameterised, actual parameters must, of course, be supplied at import, and so the optional IMPORTS clause provides the point at which such parameters may be set.

The introduction of an `Interface of Implemented Machine' option described above automatically provides the correct description - in template form - of the interface, including the introduction of the IMPORTS clause where necessary. This is the recommended method of introducing an interface into a development; the only task for the user is to provide (where necessary) actual parameters, and the interface is the built completely automatically.

Two types of interface may be built, dictated by the setting of the Interface Option.


The non-Motif Interface

The Interface tool will generate an implementation which allows the user to test the named operations of the implementation developed by the user and corresponding to the named specification. That implementation should be built using the SLIB constructs and data types; other concrete data types will not be recognised by the Interface generator and will result in an error. Where the user's operations require input/have output, the interface implementation will produce appropriate prompts and call the relevant library procedures.

The Interface generator produces two specification/implementation pairs: for example, if the INTERFACE name is `fifi', the following constructs are generated:

  1. fifiIo.mch and fifiIoI.imp

    This specification/implementation pair concerns the i/o relating to the `in-scope' operations; the specification comprises an enumerated set of operation names, with weakest specification operations to display the menu of operation names, and to select one of the names from the set. The implementation is achieved by importing using the `basic_io' SLIB machine.

  2. fifiItf.mch and fifiItfI.imp

    This pair has a single operation `main' (specified as `skip') and is implemented by importing (or seeing, depending on the way the user has built the implementation of the original specification) the specification for which the interface is being generated, the generated i/o machine, and the SLIB constructs `basic_io', `file_dump', `token_io' and `Bool_TYPE'; another generated construct, EnumItf is also imported, if required. The operation is implemented as an initialised loop, enabling the user to quit, display the menu or select an operation (calling the i/o machine), prompting for input (where appropriate), calling the selected operation of the users development, and displaying output (where appropriate).

The construct `EnumItf.enm' will also be produced if the user's specification contains an enumerated set. The ENUMERATION, if produced, enables i/o to be constructed for the user's enumerated sets (by using the Enumerator tool).

After each of these constructs have been generated, the appropriate jobs are placed on the job queue (enumeration, analysis, translation and linking), and, if the process is successful, it will result in executable code, accessed through the Translators Environment by calling the `Run' tool with the generated interface implementation. Errors are dealt with in the usual way:

Non-Motif Interface See figure.


The Motif Interface

The Interface tool will generate and compile Motif source code directly; the resulting code may be accessed in the Translators Environment by calling the `Run' tool with the generated interface.

This option is much faster than the non-Motif version (since no intermediate Abstract Machines are generated, and there is consequently no need for enumeration, analysis, and translation).

A Motif development environment must be installed on the user's system for this option to function, and the X Link Libraries setting of the Options should reflect the version of X installed.

The resulting Motif interface pops up a window presenting a push-button menu of operation names:

Motif Interface Operations Menu See figure.

and prompts for input as a form (i.e. operations with more than one input variable appear as a single form to fill in), with enumerations appearing as cascading menus:

Motif Interface Input See figure.

Output is displayed in the Display Area:

Motif Interface Display See figure.


A full on-line help listing is available in the Contents Page
Also available in the form of a complete Index.
Blogo © B-Core (UK) Limited, Last updated: 22 Feb 2002