Annotation of 43BSD/ucb/dbx/languages.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1983 Regents of the University of California.
                      3:  * All rights reserved.  The Berkeley software License Agreement
                      4:  * specifies the terms and conditions for redistribution.
                      5:  */
                      6: 
                      7: #ifndef lint
                      8: static char sccsid[] = "@(#)languages.c        5.1 (Berkeley) 5/31/85";
                      9: #endif not lint
                     10: 
                     11: static char rcsid[] = "$Header: languages.c,v 1.5 84/12/26 10:39:49 linton Exp $";
                     12: 
                     13: /*
                     14:  * Language management.
                     15:  */
                     16: 
                     17: #include "defs.h"
                     18: #include "languages.h"
                     19: #include "c.h"
                     20: #include "pascal.h"
                     21: #include "modula-2.h"
                     22: #include "asm.h"
                     23: 
                     24: #ifndef public
                     25: 
                     26: typedef struct Language *Language;
                     27: 
                     28: typedef enum {
                     29:     L_PRINTDECL, L_PRINTVAL, L_TYPEMATCH, L_BUILDAREF, L_EVALAREF,
                     30:     L_MODINIT, L_HASMODULES, L_PASSADDR,
                     31:     L_ENDOP
                     32: } LanguageOp;
                     33: 
                     34: typedef LanguageOperation();
                     35: 
                     36: Language primlang;
                     37: 
                     38: #endif
                     39: 
                     40: struct Language {
                     41:     String name;
                     42:     String suffix;
                     43:     LanguageOperation *op[20];
                     44:     Language next;
                     45: };
                     46: 
                     47: private Language head;
                     48: 
                     49: /*
                     50:  * Initialize language information.
                     51:  *
                     52:  * The last language initialized will be the default one
                     53:  * for otherwise indistinguised symbols.
                     54:  */
                     55: 
                     56: public language_init()
                     57: {
                     58:     primlang = language_define("$builtin symbols", ".?");
                     59:     c_init();
                     60:     fortran_init();
                     61:     pascal_init();
                     62:     modula2_init();
                     63:     asm_init();
                     64: }
                     65: 
                     66: public Language findlanguage(suffix)
                     67: String suffix;
                     68: {
                     69:     Language lang;
                     70: 
                     71:     lang = head;
                     72:     if (suffix != nil) {
                     73:        while (lang != nil and not streq(lang->suffix, suffix)) {
                     74:            lang = lang->next;
                     75:        }
                     76:        if (lang == nil) {
                     77:            lang = head;
                     78:        }
                     79:     }
                     80:     return lang;
                     81: }
                     82: 
                     83: public String language_name(lang)
                     84: Language lang;
                     85: {
                     86:     return (lang == nil) ? "(nil)" : lang->name;
                     87: }
                     88: 
                     89: public Language language_define(name, suffix)
                     90: String name;
                     91: String suffix;
                     92: {
                     93:     Language p;
                     94: 
                     95:     p = new(Language);
                     96:     p->name = name;
                     97:     p->suffix = suffix;
                     98:     p->next = head;
                     99:     head = p;
                    100:     return p;
                    101: }
                    102: 
                    103: public language_setop(lang, op, operation)
                    104: Language lang;
                    105: LanguageOp op;
                    106: LanguageOperation *operation;
                    107: {
                    108:     checkref(lang);
                    109:     assert(ord(op) < ord(L_ENDOP));
                    110:     lang->op[ord(op)] = operation;
                    111: }
                    112: 
                    113: public LanguageOperation *language_op(lang, op)
                    114: Language lang;
                    115: LanguageOp op;
                    116: {
                    117:     LanguageOperation *o;
                    118: 
                    119:     checkref(lang);
                    120:     o = lang->op[ord(op)];
                    121:     checkref(o);
                    122:     return o;
                    123: }

unix.superglobalmegacorp.com

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