next up previous contents index
Next: Cookbook Up: Running It Previous: Interfacing with Yacc and

   
Interfacing with Structure Files and the Synthesizer Generator

The functions CSGIOread_phylum and CSGIOwrite_phylum read and write structure files that are fully compatible with the structure files produced by Synthesizer Generator editors4. The correspondence between the primitive phyla is indicated in the following table.

SSL primitive phylum Kimwitu primitive phylum
INT int
STR casestring

To convert an SSL abstract syntax to a Kimwitu abstract syntax, one has to replace the occurrences of primitive phyla. It is convenient, but not essential, to also change SSL list phyla into Kimwitu list phyla, which can involve a renaming of SSL operators.

Since structure files encode a term directly on a file, a concrete syntax is not necessary. They have a number of properties that make them particularly suitable for interfacing separate programs, generated by either the SG or Kimwitu. These programs do not have to be generated from exactly the same term description in order to be able to communicate through structure files. In the following we call the structure file format (format for short) insensitive for such differences in the term description if this is the case. The format is insensitive for attributes because attribute values do not appear in the file. The format is insensitive for renaming of phyla, but not for renaming of operators. It is also sensitive for changes in the definition of operators such as adding or deleting component phyla. The format is insensitive for the definition or existence of operators that do not appear in the term to be written. This is essential because a tool would want to have `local' phyla definitions. The format is also insensitive for storage options. Whether or not a term is shared internally is dependent only on the definition of the phyla at the reader program.

Below we give an example of usage of structure files. The abstract syntax is as follows:  


/* Abstract syntax */ funnytree: Str(casestring) | Cons(funnytree funnytree) ;

A structure file on this phylum could be written with the following code.


/* an example of structure file i/o */ #include <stdio.h> #include "csgiok.h" #include "k.h"
void main() { char *io; funnytree ft;
ft = Str(mkcasestring("foo")); ft = Cons(ft, ft); ft = Cons(ft, ft); io = CSGIOwrite_funnytree(stdout, ft); if (io != (char *)0) printf("%s\n", io); }

The reading of such a structure file then looks like this.


/* an example of structure file i/o */ #include <stdio.h> #include "csgiok.h" #include "k.h"
void main() { char *io; funnytree ft;
io = CSGIOread_funnytree(stdin, &ft); if (io== (char *)0) print_funnytree(ft); else printf("%s\n", io); }


next up previous contents index
Next: Cookbook Up: Running It Previous: Interfacing with Yacc and

2000-04-17