preface.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <meta content=
  5. "HTML Tidy for Windows (vers 1st February 2003), see www.w3.org"
  6. name="generator">
  7. <title>
  8. Preface
  9. </title>
  10. <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
  11. <link rel="stylesheet" href="theme/style.css" type="text/css">
  12. </head>
  13. <body>
  14. <table width="100%" border="0" background="theme/bkd2.gif" cellspacing="2">
  15. <tr>
  16. <td width="10"></td>
  17. <td width="85%">
  18. <font size="6" face=
  19. "Verdana, Arial, Helvetica, sans-serif"><b>Preface</b></font>
  20. </td>
  21. <td width="112">
  22. <a href="http://spirit.sf.net"><img src="theme/spirit.gif"
  23. width="112" height="48" align="right" border="0"></a>
  24. </td>
  25. </tr>
  26. </table><br>
  27. <table border="0">
  28. <tr>
  29. <td width="10"></td>
  30. <td width="30">
  31. <a href="../index.html"><img src="theme/u_arr.gif" border="0"></a>
  32. </td>
  33. <td width="30">
  34. <img src="theme/l_arr_disabled.gif" width="20" height="19">
  35. </td>
  36. <td width="30">
  37. <a href="introduction.html"><img src="theme/r_arr.gif" border="0">
  38. </a>
  39. </td>
  40. </tr>
  41. </table><br>
  42. <table width="80%" border="0" align="center">
  43. <tr>
  44. <td>
  45. <p>
  46. <i>"Examples of designs that meet most of the criteria for
  47. "goodness" (easy to understand, flexible, efficient) are a
  48. recursive-descent parser, which is traditional procedural code.
  49. Another example is the STL, which is a generic library of
  50. containers and algorithms depending crucially on both traditional
  51. procedural code and on parametric polymorphism."</i>
  52. </p>
  53. <p>
  54. <b><font color="#003366">Bjarne Stroustrup</font></b>
  55. </p>
  56. </td>
  57. </tr>
  58. </table>
  59. <p>
  60. <b>History</b>
  61. </p>
  62. <p>
  63. A decade and a half ago, I wrote my first calculator in Pascal. It is one
  64. of my most unforgettable coding experiences. I was amazed how a mutually
  65. recursive set of functions can model a grammar specification. In time,
  66. the skills I acquired from that academic experience became very
  67. practical. Periodically I was tasked to do some parsing. For instance,
  68. whenever I need to perform any form of I/O, even in binary, I try to
  69. approach the task somewhat formally by writing a grammar using
  70. Pascal-like syntax diagrams and then write a corresponding
  71. recursive-descent parser. This worked very well.
  72. </p>
  73. <p>
  74. The arrival of the Internet and the World Wide Web magnified this
  75. thousand-fold. At one point I had to write an HTML parser for a Web
  76. browser project. I got a recursive-descent HTML parser working based on
  77. the W3C formal specifications easily. I was certainly glad that HTML had
  78. a formal grammar specification. Because of the influence of the Internet,
  79. I then had to do more parsing. RFC specifications were everywhere. SGML,
  80. HTML, XML, even email addresses and those seemingly trivial URLs were all
  81. formally specified using small EBNF-style grammar specifications. This
  82. made me wish for a tool similar to big-time parser generators such as
  83. YACC and <a href="http://www.antlr.org/">ANTLR</a>, where a parser is
  84. built automatically from a grammar specification. Yet, I want it to be
  85. extremely small; small enough to fit in my pocket, yet scalable.
  86. </p>
  87. <p>
  88. It must be able to practically parse simple grammars such as email
  89. addresses to moderately complex grammars such as XML and perhaps some
  90. small to medium-sized scripting languages. Scalability is a prime goal.
  91. You should be able to use it for small tasks such as parsing command
  92. lines without incurring a heavy payload, as you do when you are using
  93. YACC or PCCTS. Even now that it has evolved and matured to become a
  94. multi-module library, true to its original intent, Spirit can still be
  95. used for extreme micro-parsing tasks. You only pay for features that you
  96. need. The power of Spirit comes from its modularity and extensibility.
  97. Instead of giving you a sledgehammer, it gives you the right ingredients
  98. to create a sledgehammer easily. For instance, it does not really have a
  99. lexer, but you have all the raw ingredients to write one, if you need
  100. one.
  101. </p>
  102. <p>
  103. The result was Spirit. Spirit was a personal project that was conceived
  104. when I was doing R&amp;D in Japan. Inspired by the GoF's composite and
  105. interpreter patterns, I realized that I can model a recursive-descent
  106. parser with hierarchical-object composition of primitives (terminals) and
  107. composites (productions). The original version was implemented with
  108. run-time polymorphic classes. A parser is generated at run time by
  109. feeding in production rule strings such as <tt>"prod ::= {&lsquo;A&rsquo;
  110. | &lsquo;B&rsquo;} &lsquo;C&rsquo;;"</tt>A compile function compiled the
  111. parser, dynamically creating a hierarchy of objects and linking semantic
  112. actions on the fly. A very early text can be found <a href=
  113. "http://spirit.sourceforge.net/dl_docs/pre-spirit.htm">here</a>.
  114. </p>
  115. <p>
  116. The version that we have now is a complete rewrite of the original Spirit
  117. parser using expression templates and static polymorphism, inspired by
  118. the works of Todd Veldhuizen (" <a href=
  119. "http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.43.248">
  120. Expression Templates</a>", C++ Report, June 1995). Initially, the
  121. <i><b>static-Spirit</b></i> version was meant only to replace the core of
  122. the original <i><b>dynamic-Spirit</b></i>. Dynamic-spirit needed a parser
  123. to implement itself anyway. The original employed a hand-coded
  124. recursive-descent parser to parse the input grammar specification
  125. strings.
  126. </p>
  127. <p>
  128. After its initial "open-source" debut in May 2001, static-Spirit became a
  129. success. At around November 2001, the Spirit website had an activity
  130. percentile of 98%, making it the number one parser tool at Source Forge
  131. at the time. Not bad for such a niche project such as a parser library.
  132. The "static" portion of Spirit was forgotten and static-Spirit simply
  133. became Spirit. The framework soon evolved to acquire more dynamic
  134. features.
  135. </p>
  136. <p>
  137. <b>How to use this manual</b>
  138. </p>
  139. <p>
  140. The Spirit framework is organized in logical modules starting from the
  141. core. This documentation provides a user's guide and reference for each
  142. module in the framework. A simple and clear code example is worth a
  143. hundred lines of documentation; therefore, the user's guide is presented
  144. with abundant examples annotated and explained in step-wise manner. The
  145. user's guide is based on examples -lots of them.
  146. </p>
  147. <p>
  148. As much as possible, forward information (i.e. citing a specific piece of
  149. information that has not yet been discussed) is avoided in the user's
  150. manual portion of each module. In many cases, though, it is unavoidable
  151. that advanced but related topics are interspersed with the normal flow of
  152. discussion. To alleviate this problem, topics categorized as "advanced"
  153. may be skipped at first reading.
  154. </p>
  155. <p>
  156. Some icons are used to mark certain topics indicative of their relevance.
  157. These icons precede some text to indicate:
  158. </p>
  159. <table width="90%" border="0" align="center">
  160. <tr>
  161. <td>
  162. <table width="100%" border="0">
  163. <tr>
  164. <td colspan="3" class="table_title">
  165. Icons
  166. </td>
  167. </tr>
  168. <tr>
  169. <td width="19" class="table_cells">
  170. <img src="theme/note.gif" width="16" height="16">
  171. </td>
  172. <td width="58" class="table_cells">
  173. <b>Note</b>
  174. </td>
  175. <td width="627" class="table_cells">
  176. Information provided is moderately important and should be
  177. noted by the reader.
  178. </td>
  179. </tr>
  180. <tr>
  181. <td width="19" class="table_cells">
  182. <img src="theme/alert.gif">
  183. </td>
  184. <td width="58" class="table_cells">
  185. <b>Alert</b>
  186. </td>
  187. <td width="627" class="table_cells">
  188. Information provided is of utmost importance.
  189. </td>
  190. </tr>
  191. <tr>
  192. <td width="19" class="table_cells">
  193. <img src="theme/lens.gif" width="15" height="16">
  194. </td>
  195. <td width="58" class="table_cells">
  196. <b>Detail</b>
  197. </td>
  198. <td width="627" class="table_cells">
  199. Information provided is auxiliary but will give the reader a
  200. deeper insight into a specific topic. May be skipped.
  201. </td>
  202. </tr>
  203. <tr>
  204. <td width="19" class="table_cells">
  205. <img src="theme/bulb.gif" width="13" height="18">
  206. </td>
  207. <td width="58" class="table_cells">
  208. <b>Tip</b>
  209. </td>
  210. <td width="627" class="table_cells">
  211. A potentially useful and helpful piece of information.
  212. </td>
  213. </tr>
  214. </table>
  215. </td>
  216. </tr>
  217. </table>
  218. <p>
  219. <b>Support</b>
  220. </p>
  221. <p>
  222. Please direct all questions to Spirit's mailing list. You can subscribe
  223. to the mailing list <a href=
  224. "https://lists.sourceforge.net/lists/listinfo/spirit-general">here</a>.
  225. The mailing list has a searchable archive. A search link to this archive
  226. is provided in <a href="http://spirit.sf.net">Spirit's home page</a>. You
  227. may also read and post messages to the mailing list through an
  228. <a href="http://news.gmane.org/thread.php?group=gmane.comp.parsers.spirit.general">
  229. NNTP news portal</a> (thanks to <a href=
  230. "http://www.gmane.org">www.gmane.org</a>). The news group mirrors the
  231. mailing list. Here are two links to the archives: via <a href=
  232. "http://dir.gmane.org/gmane.comp.parsers.spirit.general">
  233. gmane</a>, via <a href=
  234. "http://sourceforge.net/mailarchive/forum.php?forum_id=1595gmane.org">geocrawler</a>.
  235. </p>
  236. <table width="100%" border="0" align="center">
  237. <tr>
  238. <td>
  239. <div align="center">
  240. <i><b><font size="5">To my dear daughter Phoenix</font></b></i>
  241. </div>
  242. </td>
  243. </tr>
  244. </table>
  245. <table width="100%" border="0">
  246. <tr>
  247. <td width="72%">
  248. &nbsp;
  249. </td>
  250. <td width="28%">
  251. <div align="right">
  252. <p>
  253. <b>Joel de Guzman<br></b> September 2002
  254. </p>
  255. </div>
  256. </td>
  257. </tr>
  258. </table>
  259. <table border="0">
  260. <tr>
  261. <td width="10"></td>
  262. <td width="30">
  263. <a href="../index.html"><img src="theme/u_arr.gif" border="0"></a>
  264. </td>
  265. <td width="30">
  266. <img src="theme/l_arr_disabled.gif" width="20" height="19">
  267. </td>
  268. <td width="30">
  269. <a href="introduction.html"><img src="theme/r_arr.gif" border="0">
  270. </a>
  271. </td>
  272. </tr>
  273. </table><br>
  274. <hr size="1">
  275. <p class="copyright">
  276. Copyright &copy; 1998-2003 Joel de Guzman<br>
  277. <br>
  278. <font size="2">Use, modification and distribution is subject to the
  279. Boost Software License, Version 1.0. (See accompanying file
  280. LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)</font>
  281. </p>
  282. <p>
  283. &nbsp;
  284. </p>
  285. </body>
  286. </html>