
Contents
See AlsoThe Ada-Utilities toolset is an integrated collection of tools for analysis, transformation, and prettyprinting of Ada 83 and Ada 95 code. The tools include:
Ada-Audit is a tool for creating, viewing, and maintaining a database of style and standards violations. Although delivered with definitions keyed to the Software Productivity Consortium (SPC) Ada Quality and Style Guidelines for Professional Programmers, Ada-Audit is extensible and customizable.
Ada-Prettyprint is a high-quality prettyprinter for Ada 83 and Ada 95. It also follows the presentation rules of the SPC Guidelines, but can be tailored to follow your project's coding standards.
The Scripting Language provides programmatic access to Ada code as hierarchical objects. Using the Scripting Language, you can analyze and transform Ada code using structural, rather than textual, operations. When used in conjunction with Ada-Audit, the scripting language enables you to extend the checked style standards. When used standalone, the scripting language is an Ada language-sensitive alternative to text-based languages (e.g., perl) for Ada code analysis and management.
Ada-Grep is an Ada language-sensitive version of the UNIX grep utility that supports text searches in restricted syntactic contexts. It is similar to findstr on Microsoft Windows.
Ada-ASSURED has three roles. First, it is the Ada analysis engine that underlies the other tools of Ada-Utilities. Second, it provides an interactive development environment for authoring and testing scripts. Third, it is an Ada language-sensitive editor.
See Ada-ASSURED Installation Guide section on Install Script for details on how to invoke the installation script.
For evaluation, we provide a demonstration license for both Ada-ASSURED and Ada-Utilities.
cd aahome/files/This will only remove Ada-Utilities from your system, not Ada-ASSURED.
./deinstall.Ada-Utilities
To remove Ada-ASSURED from your system, you should:
cd aahome
rm -rf Ada-ASSURED3.5 Ada-ASSURED install.full
Ada-Prettyprint is a high-quality prettyprinter for Ada 83 and Ada 95. Ada-Prettyprint follows the SPC Quality and Style Guidelines for Professional Programmers; however, it may be tailored to follow your project's coding standards.
Ada-Prettyprint can output either ASCII or (under X Windows) PostScript. It can also be used to output a summary of style and standards diagnostics.
To format a group of files, use the command:
pprint filelist ...For each input file f in filelist, formatted ASCII file f.pp is output, and file f is unchanged.
X Windows Under X Windows, to output a group of files to a PostScript printer, use the command:
pprint -ps -xrm 'aa85*sendToPrinter:true' filelist ...To output to PostScript files rather than a printer, use the command:
pprint -ps -xrm 'aa85*sendToPrinter:false' filelist ...which outputs PostScript file f.pp.ps for each input file f in filelist, and leaves file f unchanged. The -xrm flag is not needed when the given setting for aa85*sendToPrinter is set as a default Ada-ASSURED parameter.
Microsoft Under Microsoft Windows, to output a group of files to a printer use the command:
pprint -print filelist
Style and Standards Diagnostics
To output standards and style diagnostics for a group of files, use the command:
pprint -view MESSAGES filelist ...(or one of the corresponding PostScript variants). For each input file f in filelist, output file f.enf contains the diagnostics, and file f is unchanged. The diagnostics are the same as would appear in the MESSAGES view of Ada-ASSURED, as described in Chapter 16 of Ada-ASSURED User Guide and Reference Manual. Ada-Audit offer essentially the same facility, and in addition, is customizable.
The prettyprinter is customized by customizing Ada-ASSURED. Use Ada-ASSURED interactively to determine the formatting parameters you want. Then create startup scripts and preference files so that those parameters get established automatically on each invocation of Ada-ASSURED. Having done so, the same rules will be used to format code either interactively (in Ada-ASSURED) or in batch (using pprint).
Indentation and absolute right margin are controlled by command set-parameters. Call sg:set-parameters in a Scheme startup script to set new default parameters for these. Command set-parameters is documented in Chapter 14 of the Ada-ASSURED User Guide and Reference Manual.
The look of PostScript output is controlled by the parameters of command print-setup. These include headers, footers, orientation, line numbers, margins, scaling, etc. Call sg:print-setup in a Scheme startup script to set new default parameters for these. Command print-setup is documented in Chapter 14 of the Ada-ASSURED User Guide and Reference Manual.
Prettyprinting options appear in the style sheet created by command set-enforcement-parameters. They are documented in Chapter 16 of the Ada-ASSURED User Guide and Reference Manual. After setting the appropriate preferences interactively, invoke command save-enforcement-parameters to record your choices. Subsequent uses of pprint will take the preferences into account.
The prettyprinter can customized so that it performs transformations on the code prior to saving it. This can be used to remove unwanted parts of the code, such as unneeded blank lines. To use this feature, copy the definition of the function aa:pprint from aa.common.stk in the scripts directory, and put it in aa.user.stk. This function is invoked for every file passed to pprint. Code that performs the desired transformations can be placed between the call to sg:open and the call to sg:save-as.
Scripts are written in a dialect of Scheme extended with numerous primitives for accessing and manipulating Ada code. Such scripts are potentially much more powerful than text-based tools such as perl, awk and sed because the script-writer has access to the structure of an Ada program, not just the text. For example, instead of writing a regular expression that attempts to locate all procedure declarations in a text file, you just traverse the structured representation of the Ada file stopping at each construct labeled as a procedure-declaration.
The scripting language is fully documented in:
The structured representation of Ada code is defined by a grammar, which appears in: Ada Grammar
In Ada-Utilities, the scripting language is enabled for batch processing of multiple Ada files. In contrast, when Ada-ASSURED is used as an editor, the scripting language is used for editor extension and integration. In batch mode, Ada-ASSURED is controlled wholly by scripts and there is no user interaction. Other differences are:
The utility aa-batch is used to run Ada-ASSURED in batch mode. The aa-batch utility evaluates a specified script file and invokes a specified function on a list of files. For example,
aa-batch -start "run" myscript.stk file1.a file2.a
will evaluate file myscript.stk and invoke the function run on file1.a and file2.a. The aa-batch manpage contains the manual page on aa-batch with a more thorough description of the utility.
As an example, the following instructions show how to run a batch mode script to count the number of statements in a file.
(define (stmt_count)
(let ((count 0)) ;; local variable
(sg:traverse (sg:buffer-term) ;; traverse structure
((|Statement| _ _ _) ;; look for Statements
(set! count (+ 1 count)))) ;; increment count
(display "number of statements = ") ;; write to stdout
(display count)
(newline) ;; write a newline
)
)
aa-batch -start "stmt_count" statement_count.stk test.a
Read /u1/sarah/.aa_enforcement_params
Executing sg-init.stk
number of statements = 103
indicating that test.a has 103 statements.
The output of the aa-batch command can be redirected to a file using the standard UNIX redirection mechanisms. For example,
aa-batch -start "stmt_count" statement_count.stk test.a > test.out
will create the file test.out containing the line:
number of statements = 103
The lines,
Read /u1/sarah/.aa_enforcement_params
Executing sg-init.stk
are sent to standard error, along with any error messages from evaluating the script.
The Ada-Grep utility is an Ada language-sensitive version of the UNIX utility grep (similar to findstr under Microsoft Windows). An additional argument is provided to narrow the search to a particular Ada syntactic structure. For example, the command
aa-grep -w "i" "identifier,identifier2" file1.a file2.areturns all lines in files file1.a and file2.a that contain an identifier named ``i''.
A combined grammar for Ada 83 and Ada 95 is given in Ada Grammar. Any syntactic category in the appropriate grammar except those marked marked with a ~ can be specified as a target category for aa-grep.
See the manual page in the aa-grep manpage for examples of usage as well as details concerning the arguments of aa-grep.