Annotation of 43BSDTahoe/new/xns/compiler/compiler.h, revision 1.1

1.1     ! root        1: /*     Header file for XNS Courier compiler    */
        !             2: 
        !             3: /* $Header: compiler.h,v 2.2 86/06/06 07:28:35 jqj Exp $ */
        !             4: /* $Log:       compiler.h,v $
        !             5:  * Revision 2.2  86/06/06  07:28:35  jqj
        !             6:  * many mods for better symbol table management:  added CurrentModule,
        !             7:  *  made check_dependency, make_symbol, check_def set/use/use a symbol
        !             8:  *  table instead of a module name string, etc.  Result is that we can
        !             9:  *  now handle DEPENDS UPON 2 versions of same program.
        !            10:  * 
        !            11:  * Revision 2.1  86/05/16  05:44:42  jqj
        !            12:  * make enumeration tags local to modules rather than global, to allow
        !            13:  * DEPENDS UPON two versions of the same program.  For same reason, use
        !            14:  * gensymed symbol names that include version number.
        !            15:  * 
        !            16:  * Revision 2.0  85/11/21  07:21:30  jqj
        !            17:  * 4.3BSD standard release
        !            18:  * 
        !            19:  * Revision 1.5  85/05/23  06:19:24  jqj
        !            20:  * *** empty log message ***
        !            21:  * 
        !            22:  * Revision 1.5  85/05/23  06:19:24  jqj
        !            23:  * Public Beta-test version, released 24 May 1985
        !            24:  * 
        !            25:  * Revision 1.4  85/03/26  06:09:31  jqj
        !            26:  * Revised public alpha-test version, released 26 March 1985
        !            27:  * 
        !            28:  * Revision 1.3  85/03/11  16:38:47  jqj
        !            29:  * Public alpha-test version, released 11 March 1985
        !            30:  * 
        !            31:  * Revision 1.2  85/02/21  11:04:54  jqj
        !            32:  * alpha test version
        !            33:  * 
        !            34:  * Revision 1.1  85/02/15  13:58:15  jqj
        !            35:  * Initial revision
        !            36:  * 
        !            37:  */
        !            38: 
        !            39: #include <stdio.h>
        !            40: 
        !            41: #define MAXSTR         200
        !            42: #define streq(s, t)    (strcmp(s, t) == 0)
        !            43: #define New(t)         ((t *) calloc(1, sizeof(t)))
        !            44: 
        !            45: /*
        !            46:  * error message severity types
        !            47:  */
        !            48: enum severity {
        !            49:        WARNING,
        !            50:        ERROR,
        !            51:        FATAL,
        !            52: };
        !            53: 
        !            54: /*
        !            55:  * Cons cell for lisp operations.
        !            56:  */
        !            57: struct cons {
        !            58:        struct cons *c_cdr;
        !            59:        struct cons *c_car;
        !            60: };
        !            61: typedef struct cons *list;
        !            62: 
        !            63: #define NIL    ((list) 0)
        !            64: #define car(x) ((x)->c_car)
        !            65: #define cdr(x) ((x)->c_cdr)
        !            66: #define caar(x)        ((x)->c_car->c_car)
        !            67: #define cdar(x)        ((x)->c_car->c_cdr)
        !            68: #define cadr(x)        ((x)->c_cdr->c_car)
        !            69: #define cddr(x)        ((x)->c_cdr->c_cdr)
        !            70: 
        !            71: #define ONIL   ((struct object *) 0)
        !            72: #define ocar(x)        ((x)->o_car)
        !            73: #define ocdr(x)        ((x)->o_cdr)
        !            74: 
        !            75: #define TNIL   ((struct type *) 0)
        !            76: 
        !            77: /*
        !            78:  * Object classes.
        !            79:  */
        !            80: enum class {
        !            81:        O_UNKNOWN = 0,          /* make_symbol starts with this */
        !            82:        O_TYPE,                 /* a typename symbol */
        !            83:        O_CONSTANT,             /* a constantname symbol */
        !            84:        O_ENUMTAG,              /* an enumeration tag */
        !            85:        O_SYMBOLTABLE           /* a symbol table */
        !            86: };
        !            87: 
        !            88: /*
        !            89:  * Type constructors.
        !            90:  */
        !            91: enum constr {
        !            92:        C_NUMERIC = 1,
        !            93:        C_BOOLEAN,
        !            94:        C_STRING,
        !            95:        C_ENUMERATION,
        !            96:        C_ARRAY,
        !            97:        C_SEQUENCE,
        !            98:        C_RECORD,
        !            99:        C_CHOICE,
        !           100:        C_PROCEDURE,
        !           101:        C_ERROR
        !           102: };
        !           103: 
        !           104: /*
        !           105:  * Object structure, for types, and constants.
        !           106:  * These are the symbol table entries!
        !           107:  */
        !           108: struct object {
        !           109:        struct object *o_cdr, *o_car;   /* for a binary tree symbol table */
        !           110:        enum class o_class;
        !           111:        char *o_name;                   /* Courier name of this symbol */
        !           112:        char *o_module;                 /* name of module it appears in */
        !           113:        int o_modnumber;                /* number of module it appears in */
        !           114:        int o_modversion;               /* version of module it appears in */
        !           115:        union {
        !           116:                struct type *u_type;
        !           117:                struct constant *u_constant;
        !           118:                struct enumtag *u_enum;
        !           119:                struct symtab *u_symboltable;
        !           120:        } o_union;
        !           121: };
        !           122: #define o_type         o_union.u_type
        !           123: #define o_constant     o_union.u_constant
        !           124: #define o_enum         o_union.u_enum
        !           125: #define o_symboltable  o_union.u_symboltable
        !           126: 
        !           127: #define class_of(x)    (((struct object *) x)->o_class)
        !           128: #define name_of(x)     (((struct object *) x)->o_name)
        !           129: #define value_of(x)    (((struct object *) x)->o_value->cn_value)
        !           130: #define enumvalue_of(x)        (((struct object *) x)->o_enum->en_value)
        !           131: #define enumname_of(x) (((struct object *) x)->o_enum->en_name)
        !           132: 
        !           133: 
        !           134: /*
        !           135:  * Type structure.
        !           136:  *
        !           137:  * Formats of various lists are as follows.
        !           138:  * a-b is an a of type b.
        !           139:  * . indicates a cons operation.
        !           140:  * ... indicates a list of elements of the preceding form.
        !           141:  *
        !           142:  * enumeration:
        !           143:  *     ((name-objectptr . value-numericstring) ...)
        !           144:  *     [ the value is irrelevant, since it is stored in the enumtag]
        !           145:  * record, error, procedure arguments, procedure results:
        !           146:  *     (((name-string) . type-typeptr) ...)
        !           147:  * choice:
        !           148:  *     ((((name-symbol . value-numericstring) ...) . type-typeptr) ...)
        !           149:  *             [value may be nil if it is inherited from someplace]
        !           150:  */
        !           151: struct type {
        !           152:        enum constr type_constr;        /* constructor */
        !           153:        char *type_pfname;              /* name of pack function */
        !           154:        char *type_ufname;              /* name of unpack function */
        !           155:        char *type_name;                /* name of C type */
        !           156:        int type_xsize;                 /* size of external form in 16-bit
        !           157:                                           words, or -1 if variable */
        !           158:        union {
        !           159:                list u_list;            /* enumeration, record, error */
        !           160:                struct {
        !           161:                        int u_size;
        !           162:                        struct type *u_basetype;
        !           163:                } u_array;              /* array, sequence */
        !           164:                struct {
        !           165:                        struct type *u_designator;
        !           166:                        list u_candidates;
        !           167:                } u_choice;             /* choice */
        !           168:                struct {
        !           169:                        list u_args, u_results, u_errors;
        !           170:                } u_procedure;          /* procedure */
        !           171:        } type_u;
        !           172: };
        !           173: #define typename(tp) (tp->type_name)
        !           174: 
        !           175: #define type_list type_u.u_list
        !           176: #define type_array type_u.u_array
        !           177: #define type_size type_array.u_size
        !           178: #define type_basetype type_array.u_basetype
        !           179: #define type_choice type_u.u_choice
        !           180: #define type_designator type_choice.u_designator
        !           181: #define type_candidates type_choice.u_candidates
        !           182: #define type_procedure type_u.u_procedure
        !           183: #define type_args type_procedure.u_args
        !           184: #define type_results type_procedure.u_results
        !           185: #define type_errors type_procedure.u_errors
        !           186: 
        !           187: /*
        !           188:  * These definitions allow access from an object pointer
        !           189:  * known to be a type.
        !           190:  */
        !           191: #define t_constr       o_type->type_constr
        !           192: #define t_pfname       o_type->type_pfname
        !           193: #define t_ufname       o_type->type_ufname
        !           194: #define t_name         o_type->type_name
        !           195: #define t_xsize                o_type->type_xsize
        !           196: #define t_list         o_type->type_u.u_list
        !           197: #define t_size         o_type->type_u.u_array.u_size
        !           198: #define t_basetype     o_type->type_u.u_array.u_basetype
        !           199: #define t_designator   o_type->type_u.u_choice.u_designator
        !           200: #define t_candidates   o_type->type_u.u_choice.u_candidates
        !           201: #define t_args         o_type->type_u.u_procedure.u_args
        !           202: #define t_results      o_type->type_u.u_procedure.u_results
        !           203: #define t_errors       o_type->type_u.u_procedure.u_errors
        !           204: 
        !           205: 
        !           206: /*
        !           207:  * constant definition structure.
        !           208:  *
        !           209:  *   Formats for cn_value follow:
        !           210:  * numeric constants, error constants
        !           211:  *     e.g.:  34
        !           212:  * string constants
        !           213:  *     e.g.:  "abc\"def"
        !           214:  * enumeration constants
        !           215:  *     e.g.:  red
        !           216:  *
        !           217:  *   Formats for cn_list follow:
        !           218:  * record
        !           219:  *     ((name-string . constant) ...)
        !           220:  * choice:
        !           221:  *     (name-symbol . constant)
        !           222:  * array, sequence
        !           223:  *     (constant ...)
        !           224:  * error
        !           225:  *     (errorvalue-string . argsrecord-typtr)
        !           226:  * note that procedure and error constants are special.
        !           227:  */
        !           228: struct constant {
        !           229:        enum constr cn_constr;
        !           230:        char *cn_name;                  /* name of the C constant */
        !           231:        char *cn_seqvalname;            /* only for sequence constants */
        !           232:        union {
        !           233:                list u_list;            /* ConstructedConstant */
        !           234:                char *u_value;          /* PredefinedConstant */
        !           235:                                        /* EnumerationConstant */
        !           236:        } cn_union;
        !           237: };
        !           238: #define cn_list cn_union.u_list
        !           239: #define cn_value cn_union.u_value
        !           240: 
        !           241: 
        !           242: /*
        !           243:  * enumeration definition structure.
        !           244:  */
        !           245: struct enumtag {
        !           246:        char * en_name;                 /* C name for this tag */
        !           247:        unsigned short en_value;
        !           248: };
        !           249: 
        !           250: /*
        !           251:  * symbol table structure
        !           252:  */
        !           253: struct symtab {
        !           254:        struct object *s_syms;
        !           255:        list s_dependencies;            /* a list of modulews */
        !           256: };
        !           257:        
        !           258: /*
        !           259:  * Kinds of translation functions
        !           260:  */
        !           261: enum translation {
        !           262:        EXTERNALIZE,
        !           263:        INTERNALIZE,
        !           264: };
        !           265: 
        !           266: /*
        !           267:  * Predefined types.
        !           268:  */
        !           269: extern struct type
        !           270:        *Boolean_type,
        !           271:        *Cardinal_type, *LongCardinal_type,
        !           272:        *Integer_type, *LongInteger_type,
        !           273:        *String_type,
        !           274:        *Unspecified_type, *LongUnspecified_type,
        !           275:        *NilRecord_type,
        !           276:        *StreamEnum_type;
        !           277: 
        !           278: /*
        !           279:  * symbol table management routines
        !           280:  */
        !           281: extern struct object
        !           282:        *check_def(), *make_symbol(), *make_module(), *check_dependency();
        !           283: /*
        !           284:  * routines for entering types in the parse tree
        !           285:  */
        !           286: extern struct type
        !           287:        *make_type(),
        !           288:        *enumeration_type(), *array_type(),
        !           289:        *sequence_type(), *record_type(), *choice_type(),
        !           290:        *procedure_type(), *error_type();
        !           291: /*
        !           292:  * routines for entering constants in the parse tree
        !           293:  */
        !           294: extern struct constant
        !           295:        *Boolean_constant(), *Numeric_constant(),
        !           296:        *String_constant(),
        !           297:        *array_constant(), *choice_constant(), 
        !           298:        *record_constant(), *enumeration_constant();
        !           299: /*
        !           300:  * list headers for all the procedures and errors seen in this module
        !           301:  */
        !           302: extern list Procedures, Errors;
        !           303: /*
        !           304:  * basic lispish functions
        !           305:  */
        !           306: extern list cons(), nconc();
        !           307: /*
        !           308:  * files we'll be using
        !           309:  */
        !           310: extern FILE *header, *header1, *support1, *support2, *client, *server;
        !           311: 
        !           312: /*
        !           313:  * random global variables
        !           314:  */
        !           315: extern char *CurrentProgram;
        !           316: extern struct object *CurrentModule;
        !           317: extern int CurrentVersion, CurrentNumber;
        !           318: extern char *input_file;
        !           319: extern int recursive_flag;
        !           320: 
        !           321: /*
        !           322:  * more functions
        !           323:  */
        !           324: extern char *refstr(), *xfn(), *copy(), *gensym(), *make_full_name();
        !           325: extern char *malloc(), *calloc(), *strcpy();

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.