next up previous contents index
Next: Generated Functions Up: Output Previous: Output

   
Generated Data Types

For each phylum a C data type is generated. Its name is the same as the phylum so it can be arbitrarily used in a C program. Technically, it is a structure containing the attributes, a variant selector (cf. the operator) and a union of the alternatives. Note that this scheme allows type checking over C programs to check if a term is constructed from the correct phyla. An additional data type is YYSTYPE , which can be used in yacc-generated  parsers to construct terms. The generated C for the example in Section 1.1 and Section 1.2 is given below. Note, it is rarely necessary to directly refer to these C structures, as function definitions are much more convenient.   

typedef enum { ..., sel_Neg = 4, sel_Minus = 5, sel_Plus = 6, sel_Zero = 7, sel_Nilexprlist = 8, sel_Consexprlist = 9, ... } kc_enum_operators;
typedef struct kc_tag_expr *expr; /* note that a `expr' is a pointer to a `struct kc_tag_expr'*/ typedef struct kc_tag_exprlist *exprlist;
struct kc_tag_expr { kc_enum_operators prod_sel; union { struct { expr expr_1; } Neg; struct { expr expr_1; expr expr_2; } Minus; struct { expr expr_1; expr expr_2; } Plus; } u; float value; /* an attribute */ };
struct kc_tag_exprlist { kc_enum_operators prod_sel; union { struct { expr expr_1; exprlist exprlist_1; } Consexprlist; } u; };

The term processor generates a C type definition boolean  with constants True  and False  that have the usual C interpretation (namely int, 1, and 0).

The names of all the rewrite and unparse views are collected in enumeration types rview  respectively uview . Whether or not the user has used it, these types contains a value base_riew  respectively base_uview .


next up previous contents index
Next: Generated Functions Up: Output Previous: Output

2000-04-17