Editor ScriptsAda-ASSURED has a built-in scripting language that can invoke any editor command, and has access to the complete syntactic structure of an Ada program.
Here is a sample script that defines command count to count the number of names in a file.
(sg:add-command "count"
(lambda()
(let ((n 0))
(sg:traverse
(sg:buffer-term)
((|Name| _ _) (set! n (+ n 1))))
(sg:write-message (number->string n)))))
The script traverses the current buffer, increments counter
n for each instance of syntactic construct
Name in the file, and prints the count in the status pane.
Invoke command new. Enter
buffer name count, select syntactic category TEXT,
and select Yes for a new window. Then strike RETURN.
Type the script into the new buffer count.
(Under Motif, you can just drag out the text above and paste
it into the new buffer using TRANSFER.)
Invoke
eval-buffer (menu:
Tools/Scripts/Eval Buffer), which installs the command.
Invoke the new command count in window line.a
by striking TAB, typing count, and striking RETURN.
The message 63 should appear in the status pane.
Tools can send Ada-ASSURED scripts to be executed using the utility sg-client. For example, Ada-ASSURED could be sent a script to load a given file and scroll to a given line. Thus, Ada-ASSURED can be used as an ``editor server'' by an Ada development environment.