URL
https://opencores.org/ocsvn/eco32/eco32/trunk
Subversion Repositories eco32
[/] [eco32/] [trunk/] [lcc/] [lburg/] [lburg.1] - Rev 4
Compare with Previous | Blame | View Log
.TH LBURG 1 "local \- 11/30/94".\" $Id: lburg.1,v 2.1 1994/11/30 21:53:18 drh Exp $.SH NAMElburg \- lcc's code-generator generator.SH SYNOPSIS.B lburg[.I option]...[ [.I input].I output].br.SH DESCRIPTION.PP.I lburgreads an lcc-style BURG specification from.I inputand writes a pattern-matching code generator to.IR output .If.I inputis `\-' or is omitted,.I lburgreads the standard input;If.I outputis `\-' or is omitted,.I lburgwrites to the standard output..PP.I lburgaccepts specifications that conform to the following EBNF grammar.Terminals are enclosed in single quotes or aregiven in uppercase, all other symbols are nonterminals or English phrases,{X} denotes zero or more instances of X, and [X] denotes an optional X..PP.nf.RS.ft CWspec: `%{' configuration `%}' { dcl } `%%' { rule }[ `%%' C code ]dcl: `%start' nonterm`%term' { ID `=' INT }rule: nonterm `:' tree template [ C expression ]tree: term `(' tree `,' tree `)'term `(' tree `)'termnontermnonterm: IDtemplate: `"' { any character except double quote } `"'.RE.fi.PPSpecifications are structurally similar to.IR yacc 's.Text between`\f(CW%{\fP'and`\f(CW%}\fP'is called the configuration section; there may be several such segments.All are concatenated and copied verbatim into the head of the output.Text after the second`\f(CW%%\fP',if any, is also copied verbatim into the output, at the end..PPSpecifications consist of declarations, a`\f(CW%%\fP'separator, and rules.Input is line-oriented; each declaration and rule must appear on a separate line,and declarations must begin in column 1.Declarations declare terminals \(em the operators in subjecttrees \(em and associate a unique, positive external symbolnumber with each one.Nonterminals are declared by their presenceon the left side of rules. The\f(CW%start\fPdeclaration optionally declares a nonterminal as the start symbol.In the grammar above,\f(CWterm\fPand\f(CWnonterm\fPdenote identifiers that are terminals and nonterminals..PPRules define tree patterns in a fully parenthesized prefixform. Every nonterminal denotes a tree.Each operator has a fixedarity, which is inferred from the rules in which it is used.A chain rule is a rule whose pattern is another nonterminal.If no start symbol is declared, the nonterminal defined by the first rule is used..PPEach rule ends with an expression that computes the cost of matchingthat rule; omitted costsdefault to zero. Costs of chain rules must be constants..PPThe configuration section configures the outputfor the trees being parsed and the client's environment.As shown, this section must define\f(CWNODEPTR_TYPE\fPto be a visible typedef symbol for a pointer to anode in the subject tree.The labeller invokes\f(CWOP_LABEL(p)\fP,\f(CWLEFT\_CHILD(p)\fP, and\f(CWRIGHT\_CHILD(p)\fPto read the operator and children from the node pointed to by \f(CWp\fP.If the configuration section defines these operations as macros, they are implemented in-line;otherwise, they must be implemented as functions..PPThe matchercomputes and stores a single integral state in each node of the subject tree.The configuration section must define a macro\f(CWSTATE_LABEL(p)\fPto access the state field of the node pointed toby \f(CWp\fP. It must be large enough to hold a pointer, anda macro is required because it is used as an lvalue..PP.SH OPTIONS.TP.BI \-p \ prefix.br.ns.TP.BI \-p prefixUse.I prefixas the disambiquating prefix for visible names and fields.The default is `\f(CW_\fP'..TP.B \-TArrange for.sp.nf.ft CWvoid _trace(NODEPTR_TYPE p, int eruleno,int cost, int bestcost);.sp.fi.ft Rto be called at each successful match.\f(CWp\fPidentifies the node and\f(CWeruleno\fPidentifies the matching rule; the rules are numberedbeginning at 1 in the order they appear in the input.\f(CWcost\fPis the cost of the match and\f(CWbestcost\fPis the cost of the best previous match. The current matchwins only if\f(CWcost\fPis less than \f(CWbestcost\fP.32767 represents the infinite cost of no previous match.\f(CW_trace\fP must be declared in the configuration section..SH "SEE ALSO".IR lcc (1).PPC. W. Fraser and D. R. Hanson,.IR A Retargetable C Compiler: Design and Implementation ,Benjamin/Cummings, Redwood City, CA, 1995,ISBN 0-8053-1670-1. Chapter 14..PPC. W. Fraser, D. R. Hanson and T. A. Proebsting,`Engineering a simple, efficient code generator generator,'.IACM Letters on Programming Languages and Systems.BR 1 ,3 (Sep. 1992), 213-226..br.SH BUGSMail bug reports along with the shortest inputthat exposes them to drh@cs.princeton.edu.
