Structured editing is based on an abstract syntax specification. It ensures syntactic correctness since only complete syntactic elements can me removed from or added to a program. Two structured editing techniques are available:
The primary application of menu mode is the guided editing mode. This tool eliminates syntax errors and takes advantage of information inherent in the syntax to accelerate program construction. In this mode, clicking on an applicable template replaces the currently selected fragment with the menu entry.
To experiment with guided editing, open a new editor by clicking on
the button of the View pulldown in the main menu,
then click on
in the Editing-Tools
menu. A new window opens up, followed by a dialog box asking you for
the formalism name of the program to be developed from scratch. Enter
, in all capital letters. Several things happen:
The beginner menu's contents change as the current selection in the source editor changes. The currently selected subtree establishes a syntactic context, namely a phylum. This phylum appears in capital letters in the beginner menu, followed by patterns for operators that belong to this phylum. Each operator name is followed by its signature, where descendents are metavariable trees whose names are the phyla of valid descendents. Clicking on an operator name in this menu replaces the currently selected subtree by the operator's pattern. This pattern is in fact a subtree that is pretty printed in the source ctedit using the current pretty printer. You may go on replacing non-terminals this way to build your program. The expert menu is just like the beginner menu except that it displays less pattern information.
To replace atomic values, click on the button of
the Editing-Tools menu. This menu contains all atomic values and
tokens that currently appear in your program for the selected context.
Clicking on the <Edit> entry of this menu sends the tree or
metavariable tree text to GnuEmacs for edition. Or, you may click on an
existing atoms menu entry to replace the current selection with that atom.