2 <head><title>The Scannerless Boolean Parser (SBP)</title>
8 font-family: helvetica, verdana, arial, sans-serif;
13 border-top-width: 2pt;
14 border-top-style: solid;
18 font-family: helvetica, verdana, arial, sans-serif;
25 font-family: helvetica, verdana, arial, sans-serif;
31 font-family: helvetica, verdana, arial, sans-serif;
36 LI { margin-top: 5px; }
41 <center><table><tr><td width=600>
44 <font style='font-size:24pt; font-family:helvetica, verdana, arial, sans-serif'>
45 <b>SBP: the Scannerless Boolean Parser</b></font>
50 16-Aug: A new snapshot is <a href=../../edu.berkeley.sbp.tgz>here</a>.
56 <table width=500 style='background: #daa; padding: 10px'><tr><td>
57 <p style='padding: 5px; color:white; background: red; width:100%'><b>Update:</b> [29-July-2006]</font></p>
60 <a href=../../images/error.png>
61 <img align=right src=../../images/error.png width=200>
63 Error handling has been massively improved. Here's an example parsing
64 from a substantial portion of the <a href=../tests/java15.g>Java 1.5
65 grammar</a>. The <a href=../tests/java15.test>input</a> is missing a
66 closing angle-bracket on a generic type definition. Click on the
67 image to view <a href=../../images/error.png>full size</a>. Type
68 <tt>make java15</tt> after a checkout to try it yourself.
76 <table width=400><tr><td>
77 <font color=gray><b>Update:</b> [22-July-2006]<br><br>
79 The <a href=api/edu/berkeley/sbp/package-summary.html>API has been finalized</a> and includes a <a href=api/edu/berkeley/sbp/package-summary.html#package_description>decent example/mini-tutorial</a>.
86 <table width=400><tr><td>
87 <font color=red><b>Update:</b></font> [05-July-2006]<br><br>
89 The reflective grammar-to-java bindings are complete, so SBP is now
90 vastly easier to use. You can find example code <a
91 href=../src/edu/berkeley/sbp/misc/Demo.java>here</a>
92 and the companion grammar <a
93 href=../tests/demo.g>here</a>.
94 I will be writing up a tutorial tomorrow (the 7th). -- Adam
101 The Scannerless Boolean Parser (SBP) is a scannerless parser for <a
102 href=http://www.cs.queensu.ca/home/okhotin/boolean/>boolean
103 grammars</a> (a superset of context-free grammars). It is written in
104 Java and emits Java source code.
106 <h1>What is interesting about it?</h1>
108 SBP deliberately sacrifices performance in favor of ease of extensibility.
111 Since it is an implementation of the (modified) <a
112 href=http://www.program-transformation.org/Sdf/GeneralizedLR>Lang-Tomita
113 GLR algorithm</a>, SBP supports all context-free languages.
117 href=http://en.wikipedia.org/wiki/Lexerless_parsing>scannerless</a>
118 (does not require a lexer). This allows it to easily handle languages
119 which have non-regular lexical structure or lack a clear lexer-parser
120 distinction, such as TeX, XML, RFC1738 (URLs), ASN.1, SMTP headers,
124 In addition to the juxtaposition and union operators provided in
125 context-free languages, SBP supports grammars which use the
126 intersection operator (<a
127 href=http://www.cs.queensu.ca/home/okhotin/conjunctive/>conjunctive
128 grammars</a>) and the complement operator (<a
129 href=http://www.cs.queensu.ca/home/okhotin/boolean/>boolean
132 <h1>What features does it have?</h1>
134 Features fully implemented are in <font color=green>green</font>;
135 those partially implemented are in <font color=orange>orange</font>;
136 those unimplemented (but planned) are in <font color=red>red</font>.
138 <ul> <li> <b>An implementation of the Lang-Tomita GLR parsing algorithm</b>
140 <li> Including <font color=green>Johnstone & Scott's RNGLR algorithm</font> for epsilon-productions</a>
142 <li> <a href=http://citeseer.ist.psu.edu/vandenbrand02disambiguation.html><font color=green>Visser's</font> extensions</a>
143 for <font color=green>scannerless parsing</font>
144 <ul> <li> <font color=green>Follow</font>, <font color=green>Avoid, Prefer</font>, <font color=green>Reject</font> constraints
145 <li> <font color=green>Character ranges</font>
146 <li> Automatic insertion of <font color=green>whitespace/comments</font>
149 <li> <font color=green>Any topological space</font> can be
150 used as an alphabet (need not be discrete)
151 <ul> <li> <font color=green>Unicode</font>
152 <li> <font color=orange>Trees</font>
155 <li> <font color=green>Associativity constraints</font> on <font color=green><i>n</i>-ary operators</font>
159 <li> <b>Ability to parse a wide variety of grammars in
160 </b> O(n<sup>3</sup>) time:
163 <li> <font color=green>all context-free grammars</font>
165 <li> <font color=green>epsilon productions</font>, <font
166 color=green>included in the parse forest</font>
168 <li> <font color=green>circularities</font>, <font
169 color=red>included in the parse forest</font>.
171 <li> Regular expression operators (
172 <tt><font color=green>*</font></tt>,
173 <tt><font color=green>?</font></tt>,
174 <tt><font color=green>+</font></tt>
177 <li> <font color=green>conjunctive grammars</font>
178 (<font color=green>intersection</font> operator)
180 <li> <font color=orange>boolean grammars</font> (<font
181 color=green>intersection</font>, <font
182 color=green>intersect-with-complement</font>, and
183 <font color=orange>generalized-complement</font>)
187 <li> <b>Facilitates experimenting with grammars</b>
190 <li> <font color=green>Interpreted mode</font>, in which the
191 parse table is interpreted directly, eliminating the
192 need for a compiler and making it easier for grammars
193 to operate on grammars.
195 <li> <font color=green>Simple
196 <a href=api/edu/berkeley/sbp/package-summary.html>API</a></font>
197 makes it easy to generate, analyze, and modify grammars
201 <li> Components of a grammar (nonterminals,
202 productions, etc) <font
203 color=green>represented as objects</font>
204 <li> composite elements implement <font color=green><tt>Iterable<T></tt></font>
207 <li> <font color=red>Compiled mode</font>, in which Java
208 source code is emitted; compiling this code yields a
209 parser. The resulting parser is <i>much</i> faster.
215 <h1>What is it deliberately missing?</h1>
217 <ul> <li> Semantic actions; the only option is to return a parse forest.
219 <li> This keeps the grammar specification language-neutral.
220 <li> A grammar can, however, indicate that certain parts of the parse tree should be dropped.
224 <h1>What features would be nice to have?</h1>
227 <li> <strike>Drop Farshi's algorithm and use <a
228 href=http://doi.ieeecomputersociety.org/10.1109/HICSS.2002.994495>GRMLR</a></strike>.
229 <font color=green>Done!</font>
231 <li> An implementation of the <a
232 href=http://www.cs.berkeley.edu/~smcpeak/elkhound/sources/elkhound/algorithm.html>McPeak-Necula
233 optimization</a> for bounded-depth determinism.
235 <li> Lazy parse trees, to decrease the space requirements from
236 o(n) to o(1) [but still O(n)].
238 <li> Consider implementing <a
239 href=http://www.cs.uvic.ca/~nigelh/Publications/cc99-paper.pdf>
240 Aycock-Horspool</a> unrolling. Improves performance with
241 only highly localized increase in algorithmic complexity.
242 Subsumes many other optimizations.
246 <h1>What are the long term goals?</h1>
248 As we come to a more mature understanding of the pragmatic aspects of
249 boolean grammars, a long-term goal is to migrate support for these
250 features to existing high-performance GLR implementations (<a
251 href=http://www.cs.berkeley.edu/~smcpeak/elkhound/>Elkhound</a>, <a
252 href=http://www.delorie.com/gnu/docs/bison/bison_90.html>bison-glr</a>).
254 <h1>Where can I read more about it?</h1>
256 <ul> <li> The <a href=../README>README</a> file is the best place to start
257 <li> After that, be sure to read <a href=jargon.txt>jargon.txt</a>
259 href=api/edu/berkeley/sbp/package-summary.html>javadoc</a>
260 is the best description of the API
261 <li> There's a <a href=../tests/meta.g>tentative metagrammar</a>,
263 <li> You can also get <a href=osq.lunch.talk.pdf>slides</a>
264 from my talk at the OSQ Lunch on 02-Nov-2005, though some of
265 the stuff (specifically what SBP can and cannot do) is
267 <li> A <a href=preprint.pdf>preprint</a> of one of my conference
271 <h1>Where can I get it?</h1>
273 The color coding above accurately reflects the state of the
274 implementation (<font color=green>11-Dec-2005</font>). However, in its current state it is a
275 bit messy, and may require a bit of fiddling to get it to do what you
276 want. This situation should improve in the next few weeks as I am
277 done adding features (for now) and am currently focusing on
278 reliability, cleanliness, and performance.
281 SBP is available under the BSD license.
284 You can download a snapshot (<font color=green>11-Dec-2005</font>) <a
285 href=../../edu.berkeley.sbp.tgz>here</a>. The parser-generator
286 requires Java 1.5 or later; the Java code it emits <font
287 color=orange>should run on any Java 1.1+ JVM</font>. After unpacking
288 the archive, simply type <tt>make</tt> to compile SBP and run the
293 </td></tr></table></center>