shell options are -ec, NOT -ce
[unix-history] / usr / src / old / dbx / languages.c
CommitLineData
2a24676e 1/*
8a90f3aa
KB
2 * Copyright (c) 1983 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
2a24676e 16 */
86d66dd9 17
2a24676e 18#ifndef lint
8a90f3aa
KB
19static char sccsid[] = "@(#)languages.c 5.2 (Berkeley) %G%";
20#endif /* not lint */
86d66dd9
ML
21
22/*
23 * Language management.
24 */
25
26#include "defs.h"
27#include "languages.h"
28#include "c.h"
29#include "pascal.h"
2fd0f574 30#include "modula-2.h"
86d66dd9
ML
31#include "asm.h"
32
33#ifndef public
2fd0f574 34
86d66dd9
ML
35typedef struct Language *Language;
36
37typedef enum {
2fd0f574
SL
38 L_PRINTDECL, L_PRINTVAL, L_TYPEMATCH, L_BUILDAREF, L_EVALAREF,
39 L_MODINIT, L_HASMODULES, L_PASSADDR,
40 L_ENDOP
86d66dd9
ML
41} LanguageOp;
42
43typedef LanguageOperation();
2fd0f574
SL
44
45Language primlang;
46
86d66dd9
ML
47#endif
48
49struct Language {
50 String name;
51 String suffix;
2fd0f574 52 LanguageOperation *op[20];
86d66dd9
ML
53 Language next;
54};
55
56private Language head;
57
58/*
59 * Initialize language information.
60 *
61 * The last language initialized will be the default one
62 * for otherwise indistinguised symbols.
63 */
64
65public language_init()
66{
2fd0f574 67 primlang = language_define("$builtin symbols", ".?");
86d66dd9 68 c_init();
1c6133da 69 fortran_init();
86d66dd9 70 pascal_init();
2fd0f574 71 modula2_init();
86d66dd9
ML
72 asm_init();
73}
74
75public Language findlanguage(suffix)
76String suffix;
77{
78 Language lang;
79
80 lang = head;
81 if (suffix != nil) {
82 while (lang != nil and not streq(lang->suffix, suffix)) {
83 lang = lang->next;
84 }
85 if (lang == nil) {
86 lang = head;
87 }
88 }
89 return lang;
90}
91
92public String language_name(lang)
93Language lang;
94{
95 return (lang == nil) ? "(nil)" : lang->name;
96}
97
98public Language language_define(name, suffix)
99String name;
100String suffix;
101{
102 Language p;
103
104 p = new(Language);
105 p->name = name;
106 p->suffix = suffix;
107 p->next = head;
108 head = p;
109 return p;
110}
111
112public language_setop(lang, op, operation)
113Language lang;
114LanguageOp op;
115LanguageOperation *operation;
116{
117 checkref(lang);
2fd0f574 118 assert(ord(op) < ord(L_ENDOP));
86d66dd9
ML
119 lang->op[ord(op)] = operation;
120}
121
122public LanguageOperation *language_op(lang, op)
123Language lang;
124LanguageOp op;
125{
126 LanguageOperation *o;
127
128 checkref(lang);
129 o = lang->op[ord(op)];
130 checkref(o);
131 return o;
132}