2002-05-24 Martin Baulig <martin@gnome.org>
[mono.git] / mono / monoburg / monoburg.1
1 .\" 
2 .\" monoburg manual page.
3 .\" (C) Ximian, Inc. 
4 .\" Author:
5 .\"   Dietmar Maurer (dietmar@ximian.com)
6 .\"
7 .TH Mono "Mono 1.0"
8 .SH NAME
9 monoburg \- code generator generator
10 .SH SYNOPSIS
11 .PP
12 .B monoburg
13 [\-h]  
14 [\-d HEADER]
15 FILE
16 .SH DESCRIPTION
17 The \fImonoburg\fP program is used to generate tree pattern matchers 
18 from BURG specifications. \fImonoburg\fP accepts the following EBNF grammar.
19 .PP
20 .nf
21 .RS
22 .ft CW
23 spec:      ccode `%%' { dcl } [`%%' ccode]
24
25 dcl:       `%start' nonterm
26            `%term' { identifier [`=' integer] }
27            nonterm `:' tree [cost] [ `{' ccode `}' ] [costfunc]
28
29 tree:      term `(' tree `,' tree `)'
30            term `(' tree `)'
31            term
32            nonterm
33
34 cost:      `"' string '"'
35            integer
36
37 costfunc: `cost' `{' ccode `}'
38 .RE
39 .fi
40 .PP
41 Where \fIccode\fP is arbitrary C code. \fIcost\fP and \fIcostfunc\fP are
42 used mutually exclusive, you can't use both in one rule. \fIcost\fP must be a C
43 expression, whereas \fIccode\fP inside \fIcostfunc\fP is the body of a C 
44 function. Here are some example rules:
45 .PP
46 .nf
47 .RS
48 .ft CW
49 # define some terminal
50 %term Fetch Four Mul Plus
51
52 # this rule uses fixed costs
53 addr: Plus (con, Mul (Four, reg)) 2 
54 {
55         printf ("Emit your code here.");
56
57
58 # this one computes costs inside a function
59 reg:  Fetch (addr)  
60 {
61         printf ("Tree address is %p", tree);
62
63 } cost {
64         int c;
65
66         c = 1; /* calculate the costs here */
67
68         return c;
69 }
70 .RE
71 .fi
72 .PP
73
74 .SH OPTIONS
75 The following options are supported:
76 .TP
77 .I "-h"
78 Displays usage instructions.
79 .TP
80 .I "-d HEADER"
81 Writes a separate header file which contains all monoburg definitions.
82 .PP
83 .SH AUTHOR
84 monoburg was written by Dietmar Maurer. It is based on the papers from 
85 Christopher W.\ Fraser, Robert R.\ Henry and Todd A.\ Proebsting:
86 "BURG - Fast Optimal Instruction Selection and Tree Parsing" and
87 "Engineering a Simple, Efficient Code Generator Generator".
88 .SH SEE ALSO
89 .BR monodis(1)
90 .BR pedump(1)