OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [lcc/] [lburg/] [lburg.1] - Blame information for rev 193

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 hellwig
.TH LBURG 1 "local \- 11/30/94"
2
 
3
.\" $Id: lburg.1,v 2.1 1994/11/30 21:53:18 drh Exp $
4
 
5
.SH NAME
6
 
7
lburg \- lcc's code-generator generator
8
 
9
.SH SYNOPSIS
10
 
11
.B lburg
12
 
13
[
14
 
15
.I option
16
 
17
]...
18
 
19
[ [
20
 
21
.I input
22
 
23
]
24
 
25
.I output
26
 
27
]
28
 
29
.br
30
 
31
.SH DESCRIPTION
32
 
33
.PP
34
 
35
.I lburg
36
 
37
reads an lcc-style BURG specification from
38
 
39
.I input
40
 
41
and writes a pattern-matching code generator to
42
 
43
.IR output .
44
 
45
If
46
 
47
.I input
48
 
49
is `\-' or is omitted,
50
 
51
.I lburg
52
 
53
reads the standard input;
54
 
55
If
56
 
57
.I output
58
 
59
is `\-' or is omitted,
60
 
61
.I lburg
62
 
63
writes to the standard output.
64
 
65
.PP
66
 
67
.I lburg
68
 
69
accepts specifications that conform to the following EBNF grammar.
70
 
71
Terminals are enclosed in single quotes or are
72
 
73
given in uppercase, all other symbols are nonterminals or English phrases,
74
 
75
{X} denotes zero or more instances of X, and [X] denotes an optional X.
76
 
77
.PP
78
 
79
.nf
80
 
81
.RS
82
 
83
.ft CW
84
 
85
spec:     `%{' configuration `%}' { dcl } `%%' { rule }
86
 
87
               [ `%%' C code ]
88
 
89
 
90
 
91
dcl:      `%start' nonterm
92
 
93
          `%term' { ID `=' INT }
94
 
95
 
96
 
97
rule:     nonterm `:' tree template [ C expression ]
98
 
99
 
100
 
101
tree:     term `(' tree `,' tree `)'
102
 
103
          term `(' tree `)'
104
 
105
          term
106
 
107
          nonterm
108
 
109
 
110
 
111
nonterm:  ID
112
 
113
 
114
 
115
template: `"' { any character except double quote } `"'
116
 
117
.RE
118
 
119
.fi
120
 
121
.PP
122
 
123
Specifications are structurally similar to
124
 
125
.IR yacc 's.
126
 
127
Text between
128
 
129
`\f(CW%{\fP'
130
 
131
and
132
 
133
`\f(CW%}\fP'
134
 
135
is called the configuration section; there may be several such segments.
136
 
137
All are concatenated and copied verbatim into the head of the output.
138
 
139
Text after the second
140
 
141
`\f(CW%%\fP',
142
 
143
if any, is also copied verbatim into the output, at the end.
144
 
145
.PP
146
 
147
Specifications consist of declarations, a
148
 
149
`\f(CW%%\fP'
150
 
151
separator, and rules.
152
 
153
Input is line-oriented; each declaration and rule must appear on a separate line,
154
 
155
and declarations must begin in column 1.
156
 
157
Declarations declare terminals \(em the operators in subject
158
 
159
trees \(em and associate a unique, positive external symbol
160
 
161
number with each one.
162
 
163
Nonterminals are declared by their presence
164
 
165
on the left side of rules.  The
166
 
167
\f(CW%start\fP
168
 
169
declaration optionally declares a nonterminal as the start symbol.
170
 
171
In the grammar above,
172
 
173
\f(CWterm\fP
174
 
175
and
176
 
177
\f(CWnonterm\fP
178
 
179
denote identifiers that are terminals and nonterminals.
180
 
181
.PP
182
 
183
Rules define tree patterns in a fully parenthesized prefix
184
 
185
form. Every nonterminal denotes a tree.
186
 
187
Each operator has a fixed
188
 
189
arity, which is inferred from the rules in which it is used.
190
 
191
A chain rule is a rule whose pattern is another nonterminal.
192
 
193
If no start symbol is declared, the nonterminal defined by the first rule is used.
194
 
195
.PP
196
 
197
Each rule ends with an expression that computes the cost of matching
198
 
199
that rule; omitted costs
200
 
201
default to zero. Costs of chain rules must be constants.
202
 
203
.PP
204
 
205
The configuration section configures the output
206
 
207
for the trees being parsed and the client's environment.
208
 
209
As shown, this section must define
210
 
211
\f(CWNODEPTR_TYPE\fP
212
 
213
to be a visible typedef symbol for a pointer to a
214
 
215
node in the subject tree.
216
 
217
The labeller invokes
218
 
219
\f(CWOP_LABEL(p)\fP,
220
 
221
\f(CWLEFT\_CHILD(p)\fP, and
222
 
223
\f(CWRIGHT\_CHILD(p)\fP
224
 
225
to read the operator and children from the node pointed to by \f(CWp\fP.
226
 
227
If the configuration section defines these operations as macros, they are implemented in-line;
228
 
229
otherwise, they must be implemented as functions.
230
 
231
.PP
232
 
233
The matcher
234
 
235
computes and stores a single integral state in each node of the subject tree.
236
 
237
The configuration section must define a macro
238
 
239
\f(CWSTATE_LABEL(p)\fP
240
 
241
to access the state field of the node pointed to
242
 
243
by \f(CWp\fP. It must be large enough to hold a pointer, and
244
 
245
a macro is required because it is used as an lvalue.
246
 
247
.PP
248
 
249
.SH OPTIONS
250
 
251
.TP
252
 
253
.BI \-p \ prefix
254
 
255
.br
256
 
257
.ns
258
 
259
.TP
260
 
261
.BI \-p prefix
262
 
263
Use
264
 
265
.I prefix
266
 
267
as the disambiquating prefix for visible names and fields.
268
 
269
The default is `\f(CW_\fP'.
270
 
271
.TP
272
 
273
.B \-T
274
 
275
Arrange for
276
 
277
.sp
278
 
279
.nf
280
 
281
.ft CW
282
 
283
    void _trace(NODEPTR_TYPE p, int eruleno,
284
 
285
                    int cost, int bestcost);
286
 
287
.sp
288
 
289
.fi
290
 
291
.ft R
292
 
293
to be called at each successful match.
294
 
295
\f(CWp\fP
296
 
297
identifies the node and
298
 
299
\f(CWeruleno\fP
300
 
301
identifies the matching rule; the rules are numbered
302
 
303
beginning at 1 in the order they appear in the input.
304
 
305
\f(CWcost\fP
306
 
307
is the cost of the match and
308
 
309
\f(CWbestcost\fP
310
 
311
is the cost of the best previous match. The current match
312
 
313
wins only if
314
 
315
\f(CWcost\fP
316
 
317
is less than \f(CWbestcost\fP.
318
 
319
32767 represents the infinite cost of no previous match.
320
 
321
\f(CW_trace\fP must be declared in the configuration section.
322
 
323
.SH "SEE ALSO"
324
 
325
.IR lcc (1)
326
 
327
.PP
328
 
329
C. W. Fraser and D. R. Hanson,
330
 
331
.IR A Retargetable C Compiler: Design and Implementation ,
332
 
333
Benjamin/Cummings, Redwood City, CA, 1995,
334
 
335
ISBN 0-8053-1670-1. Chapter 14.
336
 
337
.PP
338
 
339
C. W. Fraser, D. R. Hanson and T. A. Proebsting,
340
 
341
`Engineering a simple, efficient code generator generator,'
342
 
343
.I
344
 
345
ACM Letters on Programming Languages and Systems
346
 
347
.BR 1 ,
348
 
349
3 (Sep. 1992), 213-226.
350
 
351
.br
352
 
353
.SH BUGS
354
 
355
Mail bug reports along with the shortest input
356
 
357
that exposes them to drh@cs.princeton.edu.
358
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.