"Examples of designs that meet most of the criteria for "goodness" (easy to understand, flexible, efficient) are a recursive descent parser, which is traditional procedural code. Another example is the STL, which is a generic library of containers and algorithms depending crucially on both traditional procedural code and on parametric polymorphism."

--Bjarne Stroustrup

Welcome to Spirit

Spirit is an object oriented recursive descent parser framework implemented using template meta-programming [1] techniques. Expression templates [2] allow us to approximate the syntax of Extended Backus Normal Form [3] (EBNF) completely in C++. Parser objects are composed through operator overloading and the result is a backtracking, top down parser that is capable of parsing rather ambiguous grammars.

The Spirit framework enables a target grammar to be written exclusively in C++. Inline EBNF grammar specifications can mix freely with other C++ code and, thanks to the generative power of C++ templates, are immediately executable.

Spirit is part of Boost Libraries, a peer-reviewed, open collaborative development effort.

 

News

November 2, 2009.

New Website

Boost 1.41 release is coming vey soon, along with it, the much awaited Spirit version 2.1. It's about time we have a major website makeover. Check out the new site for Spirit 2.1 (in beta).

  • Finally settled on WordPress. It does the job wonderfully, with minimum fuss, and it has great support.
  • The new docs are uploaded. The search box should be available once Google starts to index the new site (I already submitted a sitemap) for the Google Custom Search

September 25, 2009.

Spirit 2.1 Release Coming Very Soon

After a long time in beta (more than 2 years with Spirit 2.0), Spirit 2.1 will finally be released with the upcoming Boost 1.41 release. The code is very stable now and is ready for production code. We are working hard on finishing the documentation in time for Boost 1.41. You can peek at the current state of the documentation here. Currently, you can find the code and documentation in the Boost SVN trunk. If you have a new project involving Spirit, we highly recommend starting with Spirit 2.1 now. Allow me to quote OvermindDL's post from the Spirit mailing list:

I may start to sound like a bot with how often I say this, but Spirit.Classic is ancient, you should switch to Spirit2.1, it can do everything you did above a GREAT deal easier, a lot less code, and it executes faster.  For example, Spirit2.1 can build your entire AST inline, no weird overriding, no need to build things up afterwards, etc..., all as one nice and fast step.  You really need to update. See the other posts from the past day for links to docs and such for Spirit2.1. Spirit2.1 is currently in Boost Trunk, but will be formally released with Boost 1.41, but is otherwise complete.

October 20, 2008.

IMPORTANT!!! PLEASE READ!!!

Regarding the evil post-skip (see news Post-skips (Important for Boost 1.34 and above users) below), here's an ***IMPORTANT UPDATE***: I just found out that g >> eps_p is wrong. eps_p does not do a pre-skip, so the code will do nothing. The correct code is:

parse ( str , g >> !end_p , skipper );

October 19, 2008.

Phoenix

Phoenix has been accepted into Boost!!! There are 15 votes, 11 of which vote for acceptance and 4 vote for conditional acceptance.

All reviewers stated that the outstanding quality of the library and its documentation fully merit immediate acceptance. There is no direct concern with regard to the library itself. Phoenix V2 is already in the Boost distribution as a Spirit sub-library and has matured for a long time, proving its stability and usability. On the other hand, Phoenix provides functionality already covered by Boost.Bind and Boost.Lambda. It is the general intention to use Phoenix as the development ground for a new unified Boost library in this area. The review discussions revealed quite some details and certain problems which have to be resolved for this merger to happen. Joel has a full list of these details and promised to address all of them before adding Phoenix to the Boost SVN.

--Hartmut Kaiser, Review Manager

August 17, 2008.

Spirit2 and Boost 1.36.0

Boost 1.36.0 has been released. Along with it, comes Spirit 1.8.7, integrated with Spirit V2, "The New Generation". Even if the directory structure has changed (the Spirit Classic headers are now moved to the '$BOOST_ROOT/boost/spirit/home/classic' directory), we created forwarding headers allowing to compile existing applications without any change. These forwarding headers are deprecated, though, which will result in corresponding warnings generated for each of the headers. The forwarding headers are expected to be removed in the future. The recommended way of using Spirit Classic is now to include header files from the directory '$BOOST_ROOT/boost/spirit/include'. All files of Spirit Classic have now a 'classic_' prefixed to their name. For example the include

   #include <boost/spirit/core/core.hpp>

now should be written as:

   #include <boost/spirit/include/classic_core.hpp>

To avoid namespace conflicts with the new Spirit V2 library we moved Spirit Classic into the namespace boost::spirit::classic . This change will be automatically deactivated whenever the deprecated include files are being used. This ensures full backwards compatibility for existing applications. For more details about this change please consult the documentation.

Spirit2 is in beta. For the adventurous only. The interface is stable (and has been for almost 2 years now). The documentation is still sparse, but there are tons of examples in there. Also, don't complain about compile times. We haven't optimized on compile times yet. There's lots of room for improvement in that area still.

April 18, 2008.

Spirit2 development

FYI, Spirit2 development has been moved to Boost SVN trunk. We successfully merged with Spirit 1.8.x which is called "classic" Spirit now. Users of "classic" Spirit should not have to do anything; it's fully backward compatible. However, there are changes in the include structure to accommodate different versions under one spirit directory at the same time. While the old includes will still work, they are deprecated with a warning message:

"This header is deprecated. Please use: xxx.hpp"

The new include scheme is easy to use. We have an "include" directory where we place all forwarding headers to the actual files. For classic spirit, the files are prepended with "classic_". For example, what used to be:

"boost/spirit/core/parser.hpp"

is now:

"boost/spirit/include/classic_parser.hpp"

November 28, 2007.

Post-skips (Important for Boost 1.34 and above users)

IMPORTANT!!! PLEASE READ!!!

In boost 1.34, if there is a trailing white space characters in an input sequence, parse returns with info.full set to false, even though parsing was (essentially) full. The skip parser is ignored for the last sequence. In 1.33 parsing succeeds as expected.

The change in behavior was intentional. It was made on the grounds of consistency (parsers shouldn't consume any more output than what they have matched), as well as to avoid a hang when directly parsing stdin: namely, parse() would hang waiting for a non-whitespace character at the end of a match.

You may workaround this change by adding eps_p or end_p after your grammar, as in:

my_grammar g ;
my_skipper skipper ;
parse ( str , g >> eps_p , skipper ); // 1
parse ( str , g >> end_p , skipper ); // 2

The 2nd option requires a full match, while the first one gets you the previous behaviour without making a full match obligatory.

Here's where the change was first announced, for context:

http://thread.gmane.org/gmane.comp.parsers.spirit.general/9839

***IMPORTANT UPDATE***: I just found out that g >> eps_p is wrong. eps_p does not do a pre-skip, so the code will do nothing. The correct code is:

parse ( str , g >> !end_p , skipper );

September 02, 2007.

Spirit 1.8.5 and 1.6.4 released

It is my pleasure to announce the release of Spirit 1.8.5 and 1.6.4 .

Spirit 1.8.5 is a standalone variant of the version that is included in Boost 1.34.1; it doesn't provide new features, but contains all the fixes that were applied since Spirit 1.8.4 . You can download Spirit 1.8.5 here.

Spirit 1.6.4 is the latest in a series of releases that are based on an earlier implementation that is friendlier towards older, less standard compliant compilers. This is a bug fix only release and is likely to be the final 1.6.x version. Spirit 1.6.4 is available here.

Both Spirit 1.8.5 and 1.6.4 are available in the following variants:

  • Library only (the spirit-1.x.y.zip / spirit-1.x.y.tar.gz files) - These contain only Spirit itself and require an existing Boost installation. Both were tested only with Boost 1.34.0 and 1.34.1, but should work with other reasonably recent releases.
  • Miniboost (the spirit-1.x.y-miniboost.zip / spirit-1.x.y-miniboost.tar.gz files) - These contain also the minimal subset of Boost that is needed to use Spirit. This is a new version of the Miniboost that is based on Boost 1.34.1 and has the same directory structure as Boost itself.

Enjoy!

-- Nicola Musatti

April 05, 2007.

BoostCon '07

Have you heard? Boost will be having its inaugural conference. It will be in Aspen, Colorado, May 14-18 2007. Spirit2 will debut at the Boost conference. It will be a complete parsing and output generation system that attempts to cover the whole spectrum from lexing to output generation.

Spirit2 will be ready before the Boost conference where Hartmut and I will give a talk titled "A cookbook approach to parsing and output generation with Spirit2". Dan Marsden and I will also have a talk on Boost.Fusion. Oh yeah, Eric Niebler will also give a talk on Text processing with Boost in general, and the much anticipated Proto library with which Spirit2 is built on.

I invite you all to come:

BoostCon '07

See the sessions here. You'll see people like Kevlin Henney, Scott Meyers, Sean Parent (Adobe ASL), Dave Abrahams, etc -- all these amazing people. It will be an amazing event -- the first ever Boost Conference! Register now to secure your place at BoostCon 2007. Space is limited.

It will be fun to meet up with "Spiritistas" :-) as one of the pioneers, JCAB, puts it. Let's have lods of fun and lotsa pizzas! And of course, not to forget beer!

Spirit 1.8.4 Released

October 29, 2006.

We just released Spirit v1.8.4. The files are available here:

https://sourceforge.net/project/showfiles.php?group_id=28447&release_id=459393

This is mainly a bugfix release.

Spirit 1.8.4 Release candidate + Roadmap

October 1, 2006.

Spirit 1.8.4 will be released in the next few days. You can get a beta snapshot here:

http://spirit.sourceforge.net/dl_more/spirit-1.8.4.beta1.zip
http://spirit.sourceforge.net/dl_more/spirit-1.8.4.beta1.tar.gz

These betas are provided to make sure that all is ok. We appreciate feedback and reporting of problems encountered. We'd like to make sure that the packages are in perfect shape before we do the final release.

Roadmap:

  • Spirit 1.8.4 release
  • Soon after the release of Spirit 1.8.4, Spirit 1.8.5 will follow. Spirit 1.8.5 is the bridge to Spirit-2. Spirit 1.8.5 integrates Fusion2 and Phoenix2. It is already in the final stages of development. Spirit 1.8.5 is not 100% backward compatible to Spirit 1.8.4. We shall provide some documents to make the transition as smooth as possible. The difference is minimal. Hopefully, 1.8.5 (and subsequent releases) will ease the transition to 2.0.
  • Development of Spirit-2 shall proceed parallel to Spirit 1.8.5++.

We welcome comments and feedback.

Fusion

September 16, 2006. Fusion2 was recently accepted into Boost. See this link.

It's been a year. Most of the time was spent on infrastructure development for the planned Spirit2 development. This includes Phoenix2 and Fusion2 plus a documentation tool called Quickbook. These are major developments. Fusion2 will be the core infrastructure on which Spirit2 will be built. Phoenix2 is already built on top of Fusion2.

What is it? Fusion is a library for working with heterogenous collections of data, commonly referred to as tuples. Collectively the containers and views are referred to as sequences, and Fusion has a suite of algorithms that operate upon the various sequence types, using an iterator concept that binds everything together.

Special thanks to Ronald Garcia, and the review manager and to all the people in the boost community who participated in the review: Andreas Pokorny, Andreas Huber, Jeff Flinn, David Abrahams, Pedro Lamarao, Larry Evans, Ryan Gallagher, Andy Little, Gennadiy Rozental, Tobias Schwinger, Joao Abecasis, Eric Niebler, Oleg Abrosimov, Gary Powell, Eric Friedman, Darren Cook, Martin Bonner and Douglas Gregor.

New Web Page

August 26, 2005. What you are looking at now is a completely redesigned web page. Now that Boost has a brand new web page design, so should Spirit.

Spirit 1.8.3 and Spirit 1.6.3 Released

August 20, 2005. Spirit 1.8.3 and 1.6.3 released. You can download the files here and view the change log here. As far as 1.8.3 is concerned, this release contains exactly the same files as the Boost 1.33.0 release.

Boost 1.33.0

August 11, 2005. Boost 1.33.0 has been released. See Boost's Site. Boost 1.33.0 includes Spirit 1.8.3. Go get it. As usual, a stand-alone Spirit package with a Mini-Boost 1.33 (just enough to get Spirit going) will be released here.

Boost.Wave

February 23, 2005. Wave has been accepted into Boost!

With special thanks to Tom Brinkman, who volunteered to be the review manager.

With thanks to:

David Abrahams, Beman Dewes, Reece Dunn, Larry Evans, Doug Gregor, Joel de Guzman, Baptiste Lepilleur, Andy Little, Paul Mensonides, Dan Nuffer, Andreas Pokorny, Vladimir Prus, Gennadiy Rozental, Michiel Salters, Jonathan Turkanis, Chris Uzdavinis, Pavel Vozenilek, Michael Walter.

for bug reports, fixes and hints during the review process.