Compiling with C# and Java - Downloading the Exercises Kit

P.D. Terry, Rhodes University

(Last updated 17 September 2021)

This directory contains instructions for downloading and installing the Exercises Kit for Compiling with C# and Java by P.D. Terry (Pearson Education, 2005, 2017).

*** This version of the Exercises Kit is designed for case studies that would match the "static" release of Coco/R. In that release, the generated classes export static methods only, as is the case for all the case studies discussed in the text book.

Software developed by Pat Terry, Rhodes University, Grahamstown, South Africa. (p.terry@ru.ac.za)

The instructions are given from the perspective of a user running a 32-bit version of the Microsoft (tm) Windows operating system, and it is assumed that the user has installed either or both of a .NET SDK (Software Development Kit) or a Java SDK.


For efficiency, the components of the Exercises Kit are supplied in the form of a set of compressed (.zip) files; the files were compressed with the 32-bit version of Info-ZIP's compression utility, but can be decompressed using Info-ZIP's software or some other decompressor such as WinZip.


Before downloading any of the components of the Exercises Kit, create a top level directory (folder) into which the compressed files can be saved. In the descriptions that follow it will be assumed that this directory is called

           c:\exercise

From a "Dos Window" this directory can be created with a command like

           mkdir c:\exercise
It can, of course, also be created from within Windows Explorer.


Once the top level directory has been created, save in it those of the following files for the components of the Exercises Kit that you wish to install:


After downloading and uncompressing the essential components of the Exercises Kit, then, if you have not previously installed the Resource Kit for the textbook, some further action may have to be taken before it can be used:


Developing your own applications, or experimenting with the case studies in the kit, is conveniently carried out as follows:

Arrange your source and support files into part of a working directory hierarchy. For illustration the top level of this system is assumed to be C:\work. We assume the attributed Cocol grammar to be stored in a file Grammar.atg, that a driver frame file has been stored in a file Grammar.frame and that there are some support routines in a file Support.cs or Support.java (again, these names are used merely for illustration).

For the C# version the files should be set up as:

               C:\work
                    Grammar.atg
                    Grammar.frame
                    C:\work\Grammar\
                         Support.cs

and for the Java version the files should be set up differently:

               C:\work
                    C:\work\Grammar\
                         Grammar.atg
                         Grammar.frame
                         Grammar.manifest
                         Support.java

Grammar.manifest (which applies only to the Java version) is optional; if present it would typically read

           Manifest-Version: 1.0
           Main-Class: Grammar/Grammar

and can be used by the system to build a jar file for the application, named Grammar.jar.

It is possible for both sets of files to coexist. For example, in the "chap06" directory of the source, once installed, you would find

               C:\exercise\probsrce\chap06            work directory
                    Parva.atg                         C# version of attributed grammar
                    Parva.frame                       C# version of driver frame file
                    C:\exercise\probsrce\chap06\parva subdirectory
                         Parva.atg                    Java version of attributed grammar
                         Parva.frame                  Java version of driver frame file
                         Parva.manifest               Manifest file to build Parva.jar
                         Table.cs                     C# version of symbol table class
                         Table.java                   Java version of symbol table class
                         . . .

Clearly there are other ways of arranging the system, and experienced users may wish to experiment in this regard.


The C:\exercise\command directory contains various batch files/scripts to expedite the use of Coco/R. They can only be immediately useful if the PATH environment variable has been modified to include this "command" directory, if the environment variable RESOURCE is defined to point to the top level of the Source Kit directory hierarchy, and the CLASSPATH environment variable defined so as to gain access to specialised library classes. Instructions for this were given earlier.

The following batch files execute Coco/R, but do not compile and link the application:

The following batch files allow for applications to be built completely from a Cocol attributed grammar:

The following batch commands may need editing. They provide ways of dealing with some of the environment variables needed by the rest of the system.


Disclaimer

While every attempt has been made to ensure that the material in this distribution performs properly, the author can accept no liability for any damage or loss, including special, incidental, or consequential, caused by the use of the software, directly or indirectly.

However, please bring any problems that you may experience to the attention of the author.

Pat Terry
Computer Science Department
Rhodes University
GRAHAMSTOWN 6140
South Africa
Tel: +27-46-603-8292 (Office)
Tel: +27-73-728-6329 (Mobile)
e-mail: p.terry@ru.ac.za
Date of this release: 17 September 2021