/* ======================================================================== bisl.h - global header for BISL compiler Copyright 1996 Micah Beck / Simon D. Levy University of Tennessee All distributions of this product must include source code. Source code is not to be distributed in any modified form. ======================================================================== */ #include #include #include #ifndef __dlist_h #define __dlist_h #include "dlist.h" #endif #define nilchk(x) if (!(x)) fatal_error("couldn't allocate memory") #define new(x, t) nilchk(x = (t *)calloc(1, sizeof(t))) #define safe_strdup(s, t) nilchk(s = strdup(t)) #define DEFAULT_FONT "Chicago" #define DEFAULT_SIZE 14 #define DEFAULT_STYLE "PLAIN" #define DEFAULT_COLOR "black" /* ======================================================================== data structures ======================================================================== */ typedef enum { n_Image = 0, /* node tags */ n_Sound, n_URL, n_Text, n_Back } NTAG; typedef enum { /* constraint tags */ c_Dclick = 0, c_Click, c_Roll, c_Tog } CTAG; typedef enum { /* tuple tags */ t_Region= 0, t_Visual, t_Place } TTAG; typedef enum { /* region tags */ r_Circ= 0, r_Rect } RTAG; typedef enum { /* visual tags */ v_Giff= 0, v_String } VTAG; typedef enum { b_And = 1, /* Boolean operators */ b_Or, b_Not } OPER; typedef struct { /* *** Cartesian coordinate point */ int x; /* horizontal offset from left */ int y; /* vertical offset from top */ } POINT; typedef struct { /* *** sound */ char *fname; /* file name */ } SNDSTRUCT; typedef struct { /* *** URL */ char *uname; /* URL string */ } URLSTRUCT; typedef struct { /* *** string */ char *string; /* contents */ char *font; /* font id */ char *style; /* text style */ int size; /* text size */ char *color; /* text color */ } STRSTRUCT; typedef struct { /* *** rectangle */ POINT *ul_point; /* upper-left */ POINT *lr_point; /* lower-right */ } RECSTRUCT; typedef struct { /* *** circle */ POINT *center; /* center */ int radius; /* radius */ } CIRSTRUCT; typedef struct { /* *** giff */ char *fname; } GIFSTRUCT; typedef struct { /* *** placement */ POINT *ul_point; /* upper-left */ struct VISSTRUCT *visptr; /* visual to place */ struct NODE *node; /* backwards pointer to node */ int depth; /* placement depth */ } PLASTRUCT; typedef struct { /* *** background image */ struct VISSTRUCT *visptr; /* name */ } BAKSTRUCT; typedef struct { /* *** region */ RTAG what; /* what it is (circle, rect, ...) */ union { RECSTRUCT *recptr; CIRSTRUCT *cirptr; } uval; PLASTRUCT *plaptr; /* image-placement */ } REGSTRUCT; typedef struct VISSTRUCT { /* *** visual */ VTAG what; /* what it is (giff, string, ...) */ union { GIFSTRUCT *gifptr; STRSTRUCT *strptr; } uval; PLASTRUCT *plaptr; /* image-placement */ } VISSTRUCT; typedef struct /* *** tuple *** */ { TTAG what; /* what kind of tuple */ union { PLASTRUCT *plaptr; /* image placement */ REGSTRUCT *regptr; /* region */ VISSTRUCT *visptr; /* visual */ } uval; } TUPL; typedef struct NODE /* *** node in graph */ { NTAG what; /* what it is (image, sound, ...) */ union { PLASTRUCT *plaptr; /* placement (image or text) */ SNDSTRUCT *sndptr; /* sound */ URLSTRUCT *urlptr; /* URL */ BAKSTRUCT *bakptr; /* background image */ REGSTRUCT *regptr; } uval; struct BEXP *constraint; /* expression constraining this node */ int count; /* display precedence */ } NODE; typedef struct CSTR /* *** constraint in graph */ { char *name; /* symbolic name */ CTAG what; /* what is it (click, rollover, ...) */ TUPL *tupl_from; /* tuple from which it points, or... */ struct CSTR *cstr_to; /* constraint to which it points */ Dlist nodes_to; /* nodes to which it points (via Bool. exp.) */ int count; /* for back-end */ } CSTR; typedef struct BEXP /* *** Boolean expression over constraintss */ { OPER oper; /* Boolean operator */ CSTR *cstr; /* terminal is a constraint */ struct BEXP *left; /* left child */ struct BEXP *right; /* right child */ } BEXP; /* ======================================================================== function prototypes ======================================================================== */ void add_cstr(char *, CSTR *); /* add constraint-symbol to table */ TUPL *add_place(TUPL *, char *); /* add placement to region-tuple */ void add_tupl(char *, TUPL *); /* add node-symbol to table */ CSTR *find_cstr(char *); /* find constraint-symbol in table */ TUPL *find_tupl(char *); /* find node-symbol in table */ void compilc_file(char *); /* compile named file */ void constrain_node(NODE *, BEXP *); /* constrain node with Boolean exp. */ void set_input(FILE *); /* set parser input to file */ void gen_code(char *, Dlist, Dlist); /* generate Java code */ void init_syms(void); /* initialize symbol table */ NODE *make_back(char *); /* make a new background node */ NODE *make_image(char *); /* make a new image node */ POINT *make_point(int, int); /* make a new Cartesian coordinate */ NODE *make_sound(char *); /* make a new sound node */ NODE *make_text(char *); /* make a new text node */ NODE *make_url(char *); /* make a new URL node */ CSTR *make_cstr1(CTAG, char *); /* make a new out-only constraint */ CSTR *make_cstr2(CTAG, char *); /* make a new in-out constraint */ TUPL *make_circ(POINT *, int); /* make a new circle-tuple */ TUPL *make_giff(char *); /* make a new giff-tuple */ TUPL *make_place(char *, POINT *, /* make a new placement-tuple */ int); TUPL *make_rect(POINT *, POINT *); /* make a new rectangle-tuple */ TUPL *make_string(char *, char *, /* make a new tuple-string */ char *, int, char *); void fatal_error(char *); /* report fatal error */ void handlc_error(char *); /* platform-specific error-handler */ BEXP *make_infix(BEXP *, BEXP *, OPER); /* make Boolean infixed expression */ BEXP *make_prefix(BEXP *, OPER); /* make Boolean prefixed expression */ BEXP *make_terminal(char *); /* make Boolean terminal expression */