Tool Integration
Tool Integration
This chapter introduces some of the ways in which Ada-ASSURED can
integrate with other tools. The material is described in the
following sections:
Ada-ASSURED's compile command invokes an Ada compiler and directs its error messages to the Ada-ASSURED buffer named *compilation*. The next-error command sequences through these errors, opening the offending file (if necessary) and selecting the appropriate line.
Ada-ASSURED is delivered with the option to integrate with many popular compilers. At installation time, one of these compilers was chosen as the default. This section describes:
File Ada-ASSURED/scripts/compiler-commands.stk contains a table of all compiler integrations delivered with Ada-ASSURED. Each compiler has a name used as a key for indexing the table.
The script language variable sg:compiler-choice contains the name of the compiler currently bound to the compile command. The variable is initialized with the default compiler that was chosen at installation time.
To change the default compiler, just assign sg:compiler-choice a
different compiler name. For example, to use the GNU Ada compiler,
execute the script language statement
(set! sg:compiler-choice "GNAT")
This can be done while Ada-ASSURED is running using
eval-string, or at startup by including the statement in a
startup script.
See file Ada-ASSURED/scripts/compiler-commands.stk for the names of integrated compilers. See Chapter Scripting Language for details on startup scripts.
The commands this-error and next-error operate on compiler output lines that have the following canonical format:
file-name : line-number : textCompilation output lines having any other format are ignored by these commands.
Compiler integration consists in specifying the means for calling a given compiler and filtering its error messages into the canonical format. The script language variable sg:compiler-command-data contains the table of integrated compilers. Each entry in the table is a sextuple, as follows:
The compiler name.
The command line used by the compile command to invoke the compiler with appropriate flags and arguments. On execution of compile, each occurrence of %F within this string is replaced by the full pathname of the file contained in the buffer from which the compile command was invoked.
It may be possible to set command line options so that the compiler produces output in the canonical format. If so, no filtering is required, and the filter string entry should be the null string (""). Otherwise, the filter string should be a pipe into a command that filters the compiler output into the canonical form. Refer to the various sed and awk scripts in Ada-ASSURED/files as examples.
This entry provides a parallel filtering mechanism that uses Scheme (STk) code instead of command pipe filters. The STk filter is a closure taking a single string argument that is applied to each compilation line in turn before it is output.
To use only STk filtering, specify the compilation scheme filter to be the desired closure, and specify the filter string to be the null string ("").
To use both filter string and STk filtering, simply specify both: the filter string will be applied first. (See the example below.)
If no STk filter is desired, the compilation scheme filter entry should be #f.
If there are initializations to run before the compiler is invoked, specify them here in an STk closure taking zero arguments; otherwise, specify #f.
If there are finalizations to run after the compiler is invoked and its output is filtered, specify them here in an STk closure taking zero arguments; otherwise, specify #f.
As an example, consider this compiler entry for the fictitious TorquemAda compiler.
("TorquemAda_2000"
"torque.exe \"%F\""
"2>&1"
,(lambda (s)
(regexp-replace "([^:]*): line (.*) col" s "\\2:\\1: col")
(set! torque-count (+ torque-count 1)))
,(lambda () (eval '(define torque-count 0)))
,(lambda () (sg:write-message (format #f "~a lines" torque-count))))
The filter string is used to redirect standard error to the standard output.
The compilation scheme filter entry is a closure of one argument, used to filter the compiler lines (and to count them). It has the effect of translating, say
foo.ada : Error: line 17 col 3 -- undeclared identifier.
to
foo.ada : 17 : Error : col 3 -- undeclared identifier.
The compiler scheme filter initialization entry defines a global variable used to count the number of error lines.
The compiler scheme filter finalization entry is a closure of zero arguments.
Technical notes:
The reason for the antiquotation of (i.e., the comma preceding) the lambda expressions is that the compiler entries are made within the context of quasiquotation (`(...)): they must be antiquoted to become ordinary expressions again. Quoted strings are unaffected by quasiquotation, and thus do not require antiquotation.
The reason that
,(lambda () (eval '(define torque-count 0)))
is used instead of
,(lambda () (define torque-count 0))
is so that torque-count will be defined in the global
environment, and thus be available to the compilation scheme
filter closure.
Ada-ASSURED can run as a server, responding to messages received from other tools. The messages are scripts that Ada-ASSURED executes. For example, if Ada-ASSURED receives the message:
(sg:open "demo.a" "compilation" "No") (sg:goto-xline 100)then file demo.a will be opened with line 100 selected. Utility routine sg-client is provided for sending messages to Ada-ASSURED. For example, execution of
sg-client -instance aa83 -startup aahome/bin/aa83will send the given message to all Ada-ASSURED processes running on the given display. If none is running, aa83 will be invoked first. Note that the above command should be entered all on one line.
-command "(sg:open "demo.a" "compilation" "No") (sg:goto-xline 100)"
See the man entry for sg-client for further details.
Ada-ASSURED can invoke other tools, either directly using shell-command, or from within a script. Here is an example for each windowing system.
Suppose, for example, that you wish to escape to vi to perform some special editing action on the current structural selection. This can be done by invoking the following script procedure vi:
This script works as follows:(define (vi) (sg:save-selection-to-file "Text" "/tmp/ssel" "BASEVIEW") (system "xterm -e /usr/ucb/vi /tmp/ssel") (sg:cut-structure) (sg:insert-file-structure "/tmp/ssel"))
Suppose, for example, that you wish to escape to notepad to perform some special editing action on the current structural selection. This can be done by invoking the following script procedure notepad:
This script works as follows:(define (notepad) (sg:save-selection-to-file "Text" "C:/temp/ssel" "BASEVIEW") (system "notepad C:/temp/ssel") (sg:cut-structure) (sg:insert-file-structure "C:/temp/ssel"))