1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
debug : TARGET += debug
# Hammerhead: amd64-only
SUBDIRS = $(MACH64)
debug: $(SUBDIRS)
include ../../Makefile.subdirs
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
.KEEP_STATE:
PROG = esc
include $(SRC)/cmd/fm/eversholt/Makefile.esc.com
EFTCLASS = writer
LOCALOBJS = escmain.o
OBJS = $(LOCALOBJS) $(COMMONOBJS)
SRCS = $(LOCALOBJS:.o=.c) $(COMMONSRCS)
CPPFLAGS += -I../common
CFLAGS += -DESC $(CTF_FLAGS)
CFLAGS64 += -DESC $(CTF_FLAGS_64)
LDLIBS += -lumem
all debug: $(PROG)
install: all $(ROOTPROG)
$(PROG): $(OBJS)
$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
$(CTFMRG)
$(POST_PROCESS)
clean:
$(RM) $(OBJS) y.output y.tab.c y.tab.h
clobber: clean
$(RM) $(PROG)
esclex.o: escparse.o
%.o: ../common/%.c
$(COMPILE.c) $<
$(CTFCONVO)
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# Copyright 2025 Hammerhead Project
#
# Hammerhead: Include Makefile.cmd first to load Makefile.master
# (defines COMPILE.c, COMPILE64.c needed by Makefile.esc.com's pattern rules)
include $(SRC)/cmd/Makefile.cmd
include ../Makefile.com
include $(SRC)/cmd/Makefile.cmd.64
install: all $(ROOTPROG64)
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* escmain.c -- main routine for esc, the eversholt compiler
*
* argument processing and the general flow through all the other
* modules is driven by this file.
*/
#include <stdio.h>
#include <string.h>
#ifdef sun
#include <stdlib.h>
#else
#include <getopt.h>
#endif /* sun */
#include "out.h"
#include "stats.h"
#include "alloc.h"
#include "stable.h"
#include "literals.h"
#include "lut.h"
#include "esclex.h"
#include "eftwrite.h"
#include "ptree.h"
#include "tree.h"
#include "check.h"
#include "version.h"
/* stuff exported by yacc-generated parsers */
extern void yyparse(void);
extern int yydebug;
/*
* This external definition has to be here. If we put it in literals.h
* lint complains about the declaration not being used within the block
* when compiling literals.c.
*/
extern void literals_init(void);
static const char *Usage =
"[-SYdghpqvy] [-Dname[=def]] [-I dir] [-Uname] [-o outfile] esc-files...";
static const char *Help =
"\tinput files are run through cpp and concatenated.\n"
"\t-D name[=def] Pass to cpp\n"
"\t-I dir Pass to cpp\n"
"\t-S Print stats for compiler memory usage, etc.\n"
"\t-U name Pass to cpp\n"
"\t-Y Enable parser debug output\n"
"\t-d Enable general debug output\n"
"\t-g Print generated iterators (use with -p)\n"
"\t-h Print this help message\n"
"\t-o outfile Emit compiled EFT to \"outfile\"\n"
"\t-p Print complete parse tree\n"
"\t-q Quiet mode: suppress warnings\n"
"\t-v Enable verbose output\n"
"\t-y Enable lexer debug output";
int Debug;
int Verbose;
int Warn = 1; /* the esc compiler should issue language warnings */
extern int Pchildgen; /* flag to ptree for printing generated iterators */
#define MAXARGS 8192
char Args[MAXARGS];
#define MAXCPPARGS 4000
static char Cppargs[MAXCPPARGS];
int
main(int argc, char *argv[])
{
char flagbuf[] = " -D";
char **av;
int c;
int stats = 0;
int lexecho = 0;
const char *outfile = NULL;
int count;
int i;
int pflag = 0;
alloc_init();
out_init(argv[0]);
stats_init(1); /* extended stats always enabled for esc */
stable_init(0);
literals_init();
lut_init();
tree_init();
eftwrite_init();
/* built a best effort summary of args for eftwrite() */
count = 0;
for (i = 1; i < argc; i++) {
char *ptr = argv[i];
if (count < MAXARGS - 1)
Args[count++] = ' ';
while (count < MAXARGS - 1 && *ptr)
Args[count++] = *ptr++;
}
Args[count] = '\0';
while ((c = getopt(argc, argv, "D:I:SU:Ydgho:pqvy")) != EOF) {
switch (c) {
case 'D':
case 'I':
case 'U':
if (strlen(optarg) + strlen(Cppargs) + 4 >= MAXCPPARGS)
out(O_DIE, "cpp args too long (max %d bytes)",
MAXCPPARGS);
flagbuf[2] = c;
(void) strcat(Cppargs, flagbuf);
(void) strcat(Cppargs, optarg);
break;
case 'S':
stats++;
break;
case 'Y':
yydebug++;
break;
case 'd':
Debug++;
break;
case 'g':
Pchildgen++;
break;
case 'h':
case '?':
out(O_PROG, "eversholt compiler version %d.%d",
VERSION_MAJOR, VERSION_MINOR);
out(O_DIE|O_USAGE, "%s\n%s", Usage, Help);
/*NOTREACHED*/
break;
case 'o':
outfile = optarg;
break;
case 'p':
pflag++;
break;
case 'q':
Warn = 0;
break;
case 'v':
Verbose++;
break;
case 'y':
lexecho++;
break;
default:
out(O_DIE|O_USAGE, Usage);
/*NOTREACHED*/
}
}
out(O_PROG|O_VERB, "eversholt compiler version %d.%d",
VERSION_MAJOR, VERSION_MINOR);
argc -= optind;
av = &argv[optind];
if (argc < 1) {
out(O_ERR, "no esc source files given");
out(O_DIE|O_USAGE, Usage);
/*NOTREACHED*/
}
lex_init(av, Cppargs, lexecho);
check_init();
yyparse();
(void) lex_fini();
tree_report();
if (count = out_errcount())
out(O_DIE, "%d language error%s encountered, exiting.",
OUTS(count));
if (outfile)
eftwrite(outfile);
if (pflag)
ptree_name_iter(O_OK, tree_root(NULL));
if (stats) {
out(O_OK, "Stats:");
stats_publish();
}
out_exit(0);
/*NOTREACHED*/
return (0);
}
|