checkpoint
[sbp.git] / doc / sbp.html
1 <html>
2 <head><title>The Scannerless Boolean Parser (SBP)</title>
3 <style>
4
5     H1 {
6         margin-left: -20px;
7         margin-top: 30px;
8         font-family: helvetica, verdana, arial, sans-serif;
9         font-size: 14pt;
10         font-weight: bold;
11         text-align: left;
12         width : 100%;
13         border-top-width: 2pt;
14         border-top-style: solid;
15     } 
16     
17     H2 {
18         font-family: helvetica, verdana, arial, sans-serif;
19         font-size: 12pt;
20         font-weight: bold;
21     } 
22
23     H3 {
24         margin-left: -10px;
25         font-family: helvetica, verdana, arial, sans-serif;
26         font-size: 12pt;
27         font-weight: bold;
28     } 
29
30     TH, TD, P, LI {
31         font-family: helvetica, verdana, arial, sans-serif;
32         font-size: 13px;  
33         text-decoration:none; 
34     }
35     
36     LI { margin-top: 5px; }
37
38 </style>
39 </head>
40 <body>
41 <center><table><tr><td width=600>
42
43 <center>
44 <font style='font-size:24pt; font-family:helvetica, verdana, arial, sans-serif'>
45 <b>SBP: the Scannerless Boolean Parser</b></font>
46 </center>
47
48 <br><br>
49 <center>
50 <table width=400><tr><td>
51 <font color=red><b>Update:</b></font> [05-July-2006]<br><br>
52
53 The reflective grammar-to-java bindings are complete, so SBP is now
54 vastly easier to use.  You can find example code <a
55 href=../src/edu/berkeley/sbp/misc/Demo.java>here</a>
56 and the companion grammar <a
57 href=../tests/demo.g>here</a>.
58 I will be writing up a tutorial tomorrow (the 7th). -- Adam
59
60 </td></tr></table>
61 </center>
62
63 <h1>What is it?</h1>
64
65 The Scannerless Boolean Parser (SBP) is a scannerless parser for <a
66 href=http://www.cs.queensu.ca/home/okhotin/boolean/>boolean
67 grammars</a> (a superset of context-free grammars).  It is written in
68 Java and emits Java source code.
69
70 <h1>What is interesting about it?</h1>
71
72 SBP deliberately sacrifices performance in favor of ease of extensibility.
73 <p>
74
75 Since it is an implementation of the (modified) <a
76 href=http://www.program-transformation.org/Sdf/GeneralizedLR>Lang-Tomita
77 GLR algorithm</a>, SBP supports all context-free languages.
78 <p>
79
80 It is <a
81 href=http://en.wikipedia.org/wiki/Lexerless_parsing>scannerless</a>
82 (does not require a lexer).  This allows it to easily handle languages
83 which have non-regular lexical structure or lack a clear lexer-parser
84 distinction, such as TeX, XML, RFC1738 (URLs), ASN.1, SMTP headers,
85 and Wiki markup.
86 <p>
87
88 In addition to the juxtaposition and union operators provided in
89 context-free languages, SBP supports grammars which use the
90 intersection operator (<a
91 href=http://www.cs.queensu.ca/home/okhotin/conjunctive/>conjunctive
92 grammars</a>) and the complement operator (<a
93 href=http://www.cs.queensu.ca/home/okhotin/boolean/>boolean
94 grammars</a>).
95
96 <h1>What features does it have?</h1>
97
98 Features fully implemented are in <font color=green>green</font>;
99 those partially implemented are in <font color=orange>orange</font>;
100 those unimplemented (but planned) are in <font color=red>red</font>.
101
102 <ul> <li> <b>An implementation of the Lang-Tomita GLR parsing algorithm</b>
103      <ul>
104           <li> Including <font color=green>Johnstone &amp; Scott's RNGLR algorithm</font> for epsilon-productions</a>
105
106           <li> <a href=http://citeseer.ist.psu.edu/vandenbrand02disambiguation.html><font color=green>Visser's</font> extensions</a>
107                for <font color=green>scannerless parsing</font>
108                <ul> <li> <font color=green>Follow</font>, <font color=green>Avoid, Prefer</font>, <font color=green>Reject</font> constraints
109                     <li> <font color=green>Character ranges</font>
110                     <li> Automatic insertion of <font color=green>whitespace/comments</font>
111                </ul>
112
113           <li> <font color=green>Any topological space</font> can be
114                used as an alphabet (need not be discrete)
115           <ul> <li> <font color=green>Unicode</font>
116                <li> <font color=orange>Trees</font>
117           </ul>
118
119           <li> <font color=green>Associativity constraints</font> on <font color=green><i>n</i>-ary operators</font>
120
121      </ul>
122
123      <li> <b>Ability to parse a wide variety of grammars in
124           </b> O(n<sup>3</sup>) time:
125
126      <ul>
127           <li> <font color=green>all context-free grammars</font>
128
129           <li> <font color=green>epsilon productions</font>, <font
130                color=green>included in the parse forest</font>
131
132           <li> <font color=green>circularities</font>, <font
133          color=red>included in the parse forest</font>.
134
135           <li> Regular expression operators (
136                <tt><font color=green>*</font></tt>,
137                <tt><font color=green>?</font></tt>,
138                <tt><font color=green>+</font></tt>
139                )
140
141           <li> <font color=green>conjunctive grammars</font>
142                (<font color=green>intersection</font> operator)
143
144           <li> <font color=orange>boolean grammars</font> (<font
145                color=green>intersection</font>, <font
146                color=green>intersect-with-complement</font>, and
147                <font color=orange>generalized-complement</font>)
148      </ul>
149
150                
151      <li> <b>Facilitates experimenting with grammars</b>
152
153      <ul>
154           <li> <font color=green>Interpreted mode</font>, in which the
155                parse table is interpreted directly, eliminating the
156                need for a compiler and making it easier for grammars
157                to operate on grammars.
158
159           <li> <font color=green>Simple
160                <a href=api/edu/berkeley/sbp/package-summary.html>API</a></font>
161                makes it easy to generate, analyze, and modify grammars
162                programmatically.
163
164           <ul> 
165               <li> Components of a grammar (nonterminals,
166                    productions, etc) <font
167                    color=green>represented as objects</font>
168                <li> composite elements implement <font color=green><tt>Iterable&lt;T&gt;</tt></font>
169           </ul>
170
171           <li> <font color=red>Compiled mode</font>, in which Java
172                source code is emitted; compiling this code yields a
173                parser.  The resulting parser is <i>much</i> faster.
174      </ul>
175                
176
177 </ul>
178
179 <h1>What is it deliberately missing?</h1>
180
181 <ul> <li> Semantic actions; the only option is to return a parse forest.
182      <ul> 
183            <li> This keeps the grammar specification language-neutral.
184            <li> A grammar can, however, indicate that certain parts of the parse tree should be dropped.
185      </ul>
186 </ul>
187
188 <h1>What features would be nice to have?</h1>
189
190 <ul>
191     <li> <strike>Drop Farshi's algorithm and use <a
192          href=http://doi.ieeecomputersociety.org/10.1109/HICSS.2002.994495>GRMLR</a></strike>.
193          <font color=green>Done!</font>
194
195     <li> An implementation of the <a
196          href=http://www.cs.berkeley.edu/~smcpeak/elkhound/sources/elkhound/algorithm.html>McPeak-Necula
197          optimization</a> for bounded-depth determinism.
198
199     <li> Lazy parse trees, to decrease the space requirements from
200          o(n) to o(1) [but still O(n)].
201
202     <li> Consider implementing <a
203          href=http://www.cs.uvic.ca/~nigelh/Publications/cc99-paper.pdf>
204          Aycock-Horspool</a> unrolling.  Improves performance with
205          only highly localized increase in algorithmic complexity.
206          Subsumes many other optimizations.
207
208 </ul>
209
210 <h1>What are the long term goals?</h1>
211
212 As we come to a more mature understanding of the pragmatic aspects of
213 boolean grammars, a long-term goal is to migrate support for these
214 features to existing high-performance GLR implementations (<a
215 href=http://www.cs.berkeley.edu/~smcpeak/elkhound/>Elkhound</a>, <a
216 href=http://www.delorie.com/gnu/docs/bison/bison_90.html>bison-glr</a>).
217
218 <h1>Where can I read more about it?</h1>
219
220 <ul> <li> The <a href=../README>README</a> file is the best place to start
221      <li> After that, be sure to read <a href=jargon.txt>jargon.txt</a>
222      <li> The <a
223           href=api/edu/berkeley/sbp/package-summary.html>javadoc</a>
224           is the best description of the API
225      <li> There's a <a href=../tests/meta.g>tentative metagrammar</a>,
226           written in itself.
227      <li> You can also get <a href=osq.lunch.talk.pdf>slides</a>
228           from my talk at the OSQ Lunch on 02-Nov-2005, though some of
229           the stuff (specifically what SBP can and cannot do) is
230           outdated.
231      <li> A <a href=preprint.pdf>preprint</a> of one of my conference
232           submissions.
233 </ul>
234
235 <h1>Where can I get it?</h1>
236
237 The color coding above accurately reflects the state of the
238 implementation (<font color=green>11-Dec-2005</font>).  However, in its current state it is a
239 bit messy, and may require a bit of fiddling to get it to do what you
240 want.  This situation should improve in the next few weeks as I am
241 done adding features (for now) and am currently focusing on
242 reliability, cleanliness, and performance.
243 <p>
244
245 SBP is available under the BSD license.
246 <p>
247
248 You can download a snapshot (<font color=green>11-Dec-2005</font>) <a
249 href=../../sbp/edu.berkeley.sbp.tar.gz>here</a>.  The parser-generator
250 requires Java 1.5 or later; the Java code it emits <font
251 color=orange>should run on any Java 1.1+ JVM</font>.  After unpacking
252 the archive, simply type <tt>make</tt> to compile SBP and run the
253 regression tests.
254
255 </td></tr></table></center>
256 </body>
257 </html>