Introduction to Grok Scripts
By Ric Holt - Last updated November 6, 1997
The
Grok language
and processor are introduced in a separate
document.
Grok is a tool that can help you manipulate facts, such as those
generated using cfx and fbgen, i.e., tuples of the form:
relation source target
For example, this tuple means that procedure P calls procedure Q:
call P Q
This form of tuple is called RSF (for Rigi Standard Form).
Grok can be used to do these three things for you:
- Read facts and sets
- Create new facts and sets
- Write fact bases and sets
Basic Grok Scripts used for Creating Landscapes
We will describe three basic Grok scripts that can be used
in creating landscapes. You can, of course, modify these scripts
or write your own scripts.
- fileLevelFacts.grok:
This grok script takes the file factbase.rsf created by
cfx/fbgen and induces the facts in it up to the module (file) level.
For example, suppose that in factbase.rsf, a fact states that
procedure P1 calls procedure P2.
If file F1 contains P1 and file F2 contains P2,
this script will create a call from from F1 to F2.
- createHighLevel.grok:
Starting with the output
from the preceding grok script, this script merges the intermediate
of relations into a set of high level relations
(currently useproc, usevar, and implementby).
This removes clutter from the landscapes being produced,
by concentrating on simple dependencies (usage of variables
and procedures) and the implementby relation between files
(sometimes highlighting dangerous source dependancies).
- createSSgraph.grok:
Starting with the output of
preceding grok script, this script
separates out the facts related to one particular subsystem,
say subsystem SSn, and creates a separate TA file
for SSn. This file in turn can be read by the lslayout
program which will add drawing addributes, such as
(x, y) locations for boxes, to allow SSn to be displayed
as a landscape by the program lsedit.
Shell Scripts to Run Grok Scripts
The
grok script distribution contains shell scripts which
handle the execution of grok to generate landscape TA.
In particular, the shell script
fact2ta runs these steps:
- fileLevelFacts.grok creates file fileLevelFacts.rsf.
- createHighLevel.grok creates files usevar.rsf,
useproc.rsf and implementby.rsf.
- makeSStupFiles (a shell script) which runs
createSSgraph.grok repeatedly for each subsystem
to create the .tup TA files.
Also supplied are two other shell scripts:
- buildls - sample script for creating landscape TA files from
a directory containing C language source code and the contain.rsf
subsystem decomposition.
- clean - removes all files generated by running buildls.