;Syntax10.Scn.Fnt ZParcElemsAllocSyntax14b.Scn.Fnt7 ZStyleElemsAlloc ParagraphSyntax12b.Scn.Fnt)  Z Syntax; ParagraphSyntax12.Scn.Fnt*Syntax10i.Scn.Fnt#%}-:%% Z ] Z ParagraphV Z ` Paragraph Z b ParagraphL @ Z Paragraphg Z 8FoldElemsNew#Syntax10.Scn.Fnt22 VAR a, b; BEGIN a := b + 1; INC(a); END Foo; 8 Z ParagraphO  Beautifier for Oberon-2 R. Lichtenberger January 1996  1. Introduction It is a sad phenomenon that most programs are written, barely tested and never read again until the need for reuse of parts of the program arises. But then the code seems most obscure and bugs that cannot be localized or fixed. While on the one hand it is impossible to write a program which makes source code perfectly readable and easy to maintain it is possible to automatically change the format of a source code in order to make the codes apearance uniform and so make it at least more easy to read. The Beautifier tries to accomplish this task. 2. Features o The indentation can automatically be set throughout the whole source code o Comments and exported names can be put into italic or bold font respectively o Procedures can be folded automatically, using FoldElems o Unneccessary semicolons can be removed o Missing spaces can be inserted before and after operators The Beautifier follows the style guidlines of the Institut fr Informatik, Abteilung Systemsoftware, Johannes Kepler University, Linz, Austria.. 3. Usage The beautifier is used by five commands: Beautifier.Format * | ^ | filename Automatically sets correct indentation and puts comments and exported names into italic or bold font respectively. Format also removes superflouus blanks / tabs at the end of a line. Beautifier.FoldProc * | ^ | filename Automatically inserts FoldElems, which allow to hide the Procedure body. In addition, the Module body is folded as well. Beautifier.RemoveSemicolons * | ^ | filename Removes Semicolons from the text that are not needed. Beautifier.SpaceOps * | ^ | filename Inserts missing spaces before/after operators and before formal parameter lists. Also deletes stretches of more than two spaces, if they are not at the beginning of a line or within strings / comments. Beautifier.Beautify * | ^ | filename Performs Format, FoldProc, RemSemicolons and SpaceOps. All four commands need one of the follwing parameters: * the marked viewer shall be formatted ^ the selection contains the file which shall be formatted filename the file named filename shall be formatted Examples: Assume a viewer is marked (you can mark a viewer by pointing to it and pressing the F1 key) which contains the following source-code: MODULE A; IMPORT Out; VAR a, b:INTEGER; BEGIN a:=b; Out.String("This = is a string"); END A. If you launch the command Beautifier.Format *, the code will immediately change into: MODULE A; IMPORT Out; VAR a, b:INTEGER; BEGIN a:=b; Out.String("This = is a string"); END A. Next assume you save this text into a file named Test.Mod and then close the viewer. If you launch the command Beautifier.RemSemicolons Test.Mod, then Test.Mod will be opened in a viewer and changed so that the semicolon after the Out.String(...) operation is removed. Finally you mark Test.Mod and launch Beautifer.SpaceOps. Again a viewer is opened and the it's contents will look like: MODULE A; IMPORT Out; VAR a, b: INTEGER; BEGIN a := b; Out.String("This = is a string") END A. To show the functionality of FoldProc consider the following code fragment: PROCEDURE Foo; VAR a, b; BEGIN a := b + 1; INC(a); END Foo; If you let Beautifer.FoldProc operate in any of the three ways shown above, the code will change into: PROCEDURE Foo; Note that you have to use Folds.Compile to compile text containing FoldElems. 4. Warning Please read the following lines carefully to avoid incidental loss of data: Always assure that you only try to format Oberon-2 Source Code. Try to compile it first, or the result could probably be far from a beautification. In addition always keep a backup before trying to beautify your source code. If you encounter problems with the Beautifer or notice a bug please contact: Robert Lichtenberger Langacker 16 4343 Mitterkirchen AUSTRIA e-mail: tanis@sport2.uibk.ac.at Minor typos in commands corrected, BdT, Oct-97