2 Source Browser And Editor

Sif [1] is a general grammar-based editor, but it is especially useful for browsing and editing BETA programs. Modularity is in BETA handled by means of the fragment system [MIA 99-42] used for combining fragments into a whole BETA program.

Sif contains a number of basic components: a source browser (Ymer), a fragment group editor and a fragment form editor. Sif is integrated with the BETA compiler that gives a good support for locating and correcting semantic errors.

Figure 1: Source browser and editor

[23kb 735x653 GIF]

Sif includes the following functionality:

Source Browser
The source browser makes it possible to browse in projects. A project can be a collection of files, a file directory or parts of the dependency graph of a BETA program. Links in the fragment structure like ORIGIN and INCLUDE can be followed easily.
Fragment Group Editor
The fragment group editor is a high-level editor used to manipulate the dependency graph of BETA programs, e.g. to create and delete whole fragment forms in fragment groups and to create and modify links like ORIGIN and INCLUDE between the fragment groups.
Fragment Form Editor
The fragment form editor is a structure editor that works inside fragment forms. Structure editing is a powerful technique for editing programs without introducing syntax errors. At the fragment form level Sif also provides useful browsing facilities, based on the syntactic and semantic structure of BETA programs.
Structure editing
The basic idea of structure editing is that the program is manipulated in terms of its logical structure rather than the textual elements such as characters, words and lines. The advantage of this approach is that only logically coherent parts can be inserted or deleted and thereby preserving the syntactical rules of the language at any time.
Structure editing is especially useful for application-oriented languages intended for end-users, casual users and beginners that may have difficulties in remembering the concrete syntax. Also a program constructed by structure editing needs not be parsed, thereby saving time in the development phase.
Text editing
Structure editing has its greatest force at the higher levels of editing, i.e. for creating the overall structure of the program or for moving around large chunks of code. At the detailed level the textediting technique is more useful. Therefore the programmer may alternate freely between structure editing and textual editing in Sif. Any program part may be textually edited.
Incremental parsing
Any program part that has been textually edited is immediately parsed. Only the text-edited part of the program is parsed.
Adaptive incremental prettyprinting
The editor includes an adaptive prettyprinting algorithm which prints the program such that it always fits within the size of the window or paper.
Abstract presentation and browsing
The editor is able to present a program at any level of detail. At the top-level of a program the user may get an overview of classes and procedures. It is then possible to browse through the classes and procedures to see more and more details. This mechanism is completely general since the user may decide the level of granularity. Printing a program at different abstraction levels provides a good basis for documentation.
Integration of documentation and comments
The user decides whether or not to display comments. The user also decides whether to display a comment as part of the program or in separate window. A pretty-print of a program which includes just the class and procedure headings (an abstract presentation) and corresponding comments may be produced. This makes it possible to extract an interface specification from the program including the explaining comments.
Programmers are motivated for integrating code and documentation since comments are easy to hide. Large pieces of documentation need not to disturb the overview of the program. Conversely it is easy to extract a high-level presentation of the program including the comments.
Hypertext facilities
The editor includes hypertext facilities. The facility for handling comments is an example of a hypertext link between a program and a text piece. Another type of hypertext link is links from the use of a name in a program to the corresponding name declaration. Such semantic links are very useful especially when working with large programs. At the fragment group level, other examples like ORIGIN and INCLUDE links are links from SLOTs to their corresponding fragment forms and vice versa.
Metaprogramming system
The editor is built upon a metaprogramming system [MIA 91-14], which is available to the user. The user has the possibility to program his or her own metaprogramming tools. It is possible to integrate such tools with the editor or simply to add functionality to the editor. This tailorability is provided by a flexible communication model and the object-oriented implementation language of the editor, which is BETA.
Grammar-basis
The editor is grammar-based, which means that it may support any language that can be described by means of a context free grammar. All the facilities mentioned above (except semantic links which require a semantic checker) are provided for any language that can be described in a context free grammar. Structure editing can not only be used on programs but any kind of documents with a formal or semi-formal structure. In the Mjølner Tool manuals the main focus will be on program editing in BETA. Editors have been generated for programming languages like BETA, SIMULA67, Pascal, Modula-2, for the query language SQL, for the specification languages SDL-92 and GDMO and finally for document types described in subsets of ODA and SGML. In addition the structure editor can be used to create or modify the grammars and prettyprint specifications for each language.

In the Mjølner Tool manuals the focus with respect to editing is on how to use the structure editor for developing programs in one of the already supported programming languages, especially the BETA language.

In [MIA 91-14] it is described how to generate a structure editor for a new language, and briefly how to add functionality to the editor or integrate the editor with another tool.

[Tutorial] [Reference Manual]


[1] Sif is the wife of the god Thor. Sif is well-known for her golden hair


Mjolner Integrated Development Tool - Overview
© 1991-2002 Mjølner Informatics
[Modified: Friday October 27th 2000 at 14:56]