New test.
[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 [\-e]  
15 [\-p]
16 [\-c VALUE]    
17 [\-d HEADER]
18 [\-DVALUE]
19 [FILE...]
20 .SH DESCRIPTION
21 The \fImonoburg\fP program is used to generate tree pattern matchers 
22 from BURG specifications. \fImonoburg\fP accepts the following EBNF grammar.
23 .PP
24 .nf
25 .RS
26 .ft CW
27 spec:      ccode `%%' { dcl } [`%%' ccode]
28
29 dcl:       `%start' nonterm
30            `%term' { identifier [`=' integer] }
31            `%termprefix' { identifier }
32            nonterm `:' tree [cost] [ `{' ccode `}' ] [costfunc]
33
34 tree:      term `(' tree `,' tree `)'
35            term `(' tree `)'
36            term
37            nonterm
38
39 cost:      `"' string '"'
40            integer
41
42 costfunc: `cost' `{' ccode `}'
43 .RE
44 .fi
45 .PP
46 Where \fIccode\fP is arbitrary C code. \fIcost\fP and \fIcostfunc\fP are
47 used mutually exclusive, you can't use both in one rule. \fIcost\fP must be a C
48 expression, whereas \fIccode\fP inside \fIcostfunc\fP is the body of a C 
49 function. Here are some example rules:
50 .PP
51 .nf
52 .RS
53 .ft CW
54 # define some terminal
55 %term Fetch Four Mul Plus
56
57 # this rule uses fixed costs
58 addr: Plus (con, Mul (Four, reg)) 2 
59 {
60         printf ("Emit your code here.");
61
62
63 # this one computes costs inside a function
64 reg:  Fetch (addr)  
65 {
66         printf ("Tree address is %p", tree);
67
68 } cost {
69         int c;
70
71         c = 1; /* calculate the costs here */
72
73         return c;
74 }
75 .RE
76 .fi
77 .PP
78 A simple pre-processor is included, consisting of: %ifdef, %else and
79 %endif.  %ifdef operates on definitions from the command line.
80 .SH OPTIONS
81 The following options are supported:
82 .TP
83 .I "-h"
84 Displays usage instructions.
85 .TP
86 .I "-d HEADER"
87 Writes a separate header file which contains all monoburg definitions.
88 .TP
89 .I "-p"
90 Assume termainals are already defined. Its possible to omit the %term
91 definitions in this mode if you use the %termprefix command. All symbols
92 starting with a prefix specified in %termprefix are considered to be terminals.
93 .TP
94 .I "-e"
95 Extended mode. Enables monoburg to work with DAGs.
96 .TP
97 .I "-c VALUE"
98 Set the default costs to VALUE
99 .TP
100 .I "-Dvar"
101 Defines the variable "var" as true.  This is used with %ifdef, %else
102 and %endif in the source files to perform conditional compilation.
103 .PP
104 .SH AUTHOR
105 monoburg was written by Dietmar Maurer. It is based on the papers from 
106 Christopher W.\ Fraser, Robert R.\ Henry and Todd A.\ Proebsting:
107 "BURG - Fast Optimal Instruction Selection and Tree Parsing" and
108 "Engineering a Simple, Efficient Code Generator Generator".
109 .SH SEE ALSO
110 .BR monodis(1)
111 .BR pedump(1)