1: #ifndef lint
2: static char RCSid[] = "$Header: constants.c,v 2.0 85/11/21 07:21:34 jqj Exp $";
3: #endif
4:
5: /* $Log: constants.c,v $
6: * Revision 2.0 85/11/21 07:21:34 jqj
7: * 4.3BSD standard release
8: *
9: * Revision 1.3 85/03/11 16:39:09 jqj
10: * *** empty log message ***
11: *
12: * Revision 1.3 85/03/11 16:39:09 jqj
13: * Public alpha-test version, released 11 March 1985
14: *
15: * Revision 1.2 85/02/21 11:05:02 jqj
16: * alpha test version
17: *
18: * Revision 1.1 85/02/15 13:55:22 jqj
19: * Initial revision
20: *
21: */
22:
23: /*
24: * Generate build symbol tables, etc. for constant declarations.
25: */
26:
27: #include "compiler.h"
28:
29: /*
30: * Allocate storage for constants
31: */
32: struct constant *
33: make_constant(constr)
34: enum constr constr;
35: {
36: struct constant *c;
37:
38: c = New(struct constant);
39: c->cn_constr = constr;
40: return(c);
41: }
42:
43:
44: /*
45: * Generate parse tree for simple constants -- Booleans
46: */
47: struct constant *
48: Boolean_constant(value)
49: char *value;
50: {
51: struct constant *c;
52:
53: c = make_constant(C_BOOLEAN);
54: c->cn_value = value;
55: return(c);
56: }
57:
58: /*
59: * Generate parse tree for simple constants -- strings
60: */
61: struct constant *
62: String_constant(value)
63: char *value;
64: {
65: struct constant *c;
66:
67: c = make_constant(C_STRING);
68: c->cn_value = value;
69: return(c);
70: }
71:
72: /*
73: * Generate parse tree for simple constants -- numeric values
74: * Note that we don't know the actual type of such constants;
75: * they are type-compatible with any numeric type.
76: */
77: struct constant *
78: Numeric_constant(value)
79: char *value;
80: {
81: struct constant *c;
82:
83: c = make_constant(C_NUMERIC);
84: c->cn_value = value;
85: return(c);
86: }
87: /*
88: * Generate parse tree for simple constants -- enumerations
89: * Note that we don't know the actual type of such constants;
90: * they are type-compatible with any numeric type.
91: */
92: struct constant *
93: enumeration_constant(value)
94: char *value;
95: {
96: struct constant *c;
97:
98: c = make_constant(C_ENUMERATION);
99: c->cn_value = value;
100: return(c);
101: }
102:
103: /*
104: * Generate parse tree for complex constants -- arrays and sequences
105: * Note that we treat them all as arrays, and allow sequences to
106: * be type-compatible with arrays at declaration time.
107: */
108: struct constant *
109: array_constant(values)
110: list values;
111: {
112: struct constant *c;
113:
114: c = make_constant(C_ARRAY);
115: c->cn_list = values;
116: return(c);
117: }
118:
119: /*
120: * Generate parse tree for complex constants -- records
121: * As a special case, NIL record constants are also type-compatible
122: * with some arrays and all sequences.
123: */
124: struct constant *
125: record_constant(values)
126: list values;
127: {
128: struct constant *c;
129:
130: c = make_constant(C_RECORD);
131: c->cn_list = values;
132: return(c);
133: }
134:
135: /*
136: * Generate parse tree for complex constants -- choices
137: */
138: struct constant *
139: choice_constant(values)
140: list values;
141: {
142: struct constant *c;
143:
144: c = make_constant(C_CHOICE);
145: c->cn_list = values;
146: return(c);
147: }
Defined functions
Defined variables
RCSid
defined in line
2;
never used