Annotation of 43BSD/contrib/xns/compiler/compiler.h, revision 1.1

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