Set up

Download this script to your home account and open it in your favourite editor.

Start up grok by simply typing

grok

We will cut and paste line by line from the script to this interactive grok session.

Grok exercise 1

Download the following RSF factbase: rawFacts.rsf.

Write a grok script called ex1.grok that computes and outputs dependencies between files for this small system.

You can load an RSF factbase in grok with getdb rawFacts.rsf

Place the output in a file called ex1.out.rsf

Grok exercise 2

Write a grok script called ex2.grok that does the following:

  1. Loads the area.ta factbase we created in the previous lab. You can do this with getta area.ta
  2. Outputs in ex2.out.rsf only the contain relation but substitutes human-readable names rather than the unique identifiers javex creates.

Test that your script works with tab2ps.ta as well.

Grok exercise 3

Write a grok script called ex3.grok that adds a new attribute to every method called fullName. Its value is the name of the class containing the method, followed by a dot, followed by the method name.

The script should take two arguments: the input TA file, and the output TA file.

Grok exercise 4

Write a grok script called ex4.grok that reads TA facts and outputs RSF containment facts between top-level directories and methods only, i.e. shows what top-level directory contains which method. For each method, output its fullName (calculated in Exercise 3).

The script should take two arguments: the input TA file, and the output RSF file.

Grok exercise 5

Extend the ex2.grok script into one called ex5.grok that substitutes human readable names for all relations rather than just contain.

It should also take two arguments as above.

More info on using Grok

You can access grok's help by typing ? after you run grok. You can then select from a number of different sections.

Notice the second-last section in the TA documentation link called "Relations with special meanings". It pertains to how grok treats TA.