Spirit V2.1 has been released only a couple of weeks ago. The first feedback we have gotten so far was overwhelming! Many people seem to quickly understand the concepts of the new library, being able to apply its power to their needs. We try to follow people’s comments and watch for reported problems. There is one theme recurring over and over again: attributes. This new (for Spirit) concept turns out to be the most difficult idea to understand, especially for somebody starting to work with the library.
Porting Spirit 2.0 (beta) to Spirit 2.1
Spirit 2 has undergone lots of revisions from its inception to what you are seeing now. An early beta release, dubbed Spirit 2 beta, was included as part of Boost 1.39. The adventurous among you started using it as soon as it was released. Spirit 2.1 is essentially the same as Spirit2 beta apart from some cosmetic differences and QOI changes. For the sake of those who started using Spirit from 2.0 beta, here’s what’s changed:
Rating Enabled on Articles and Comments
We are trying to get the best possible content to you by regularly publishing articles about different aspects of the new Spirit V2.1 library (released with Boost 1.41). Now we need your feedback! Sure, you already can leave comments, but we thought it might be cool to add the possibility to rate the quality of the articles. So just click the stars at the end of a post to tell us what you think. Moreover, we added thumbs up/down rating for comments. That’s an easy way for you to agree or disagree with other user’s opinions. Use it!
And, by the way, it would be helpful if you rated the older articles as well.
Creating Your Own Generator Component for Spirit.Karma
In the good tradition of highlighting Spirits both major sub-libraries based on similar use cases I will talk about Karma today. In a previous installment (see Creating Your Own Parser Component for Spirit.Qi) I presented the steps needed to create a parser terminal. Our topic here is the creation of a new generator directive allowing to group output elements in columns.
Build a Compiler
I am considering writing a series of articles on compiler development using Spirit-2. It will be based on the series of BoostCon talks from 07 to 09. From the humblest calculator to a full blown programming language. Details are still sketchy at this point. All I can ascertain is that the final language shall use LLVM as a back-end. There are lots of questions I need to ask in order to get the bases covered. I’d like to solicit feedback and comments. Will it be an imperative language like C or a functional language like Scheme? I love the line oriented syntax of Python, but is a free format syntax with the all too familiar braces or begin/end blocks be better? Will it be statically typed like C++ or dynamically typed like Python or LISP? Will it be OOP? How complex or simple should it be? Remember, this is meant for instruction. Is a toy language good enough? How about basing it on a simple ISO-standard language like Pascal? Or fun languages like Javascript? How about features? Type inference? Lambda? Operator overloading? Etc., etc., etc.
Let me know what you think…
Generate Escaped String Output Using Spirit.Karma
This is another article in the series of “How To’s” providing you with shrink wrapped grammars directly usable in any project. I’m going to describe a Karma grammar you can use to generate output for quoted strings, where all contained special characters are properly escaped.
Spirit V2.1 Compiler Compatibility
We started to collect the information about what compilers and platforms can be used to compile applications based on Spirit V2.1. Please add any compiler and platform you have been using successfully to compile your Spirit applications.
Who Is Using Spirit
On this new page we collect projects and products using Boost.Spirit. This list is not exhaustive as we certainly don’t know about every use. Spirit is a Boost library making it readily available to a large number of developers. If you want your product, in house use, or open source project to be included in this list, please send a note to the Spirit Mailing List or simply add a comment below and we’ll gladly add the info.
See the full list here.
Creating Your Own Parser Component for Spirit.Qi
Several people have been asking the question of how it would be possible to access the current iterator position from a semantic action. Different solutions have been proposed, all of them somehow abusing the predefined Qi directive raw[] which normally exposes as its attribute the pair of iterators pointing to the range in the input stream matched by the embedded parser. I thought this to be a nice incentive to write about how you can create your own parser components.
PDF Documentation now available
A PDF build of the documentation for Boost-1.41 (from John Maddock) is now available here:
- https://sourceforge.net/projects/boost/files/boost-docs/1.41.0/boost_pdf_1_41_0.tar.gz/download (23Mb)
- https://sourceforge.net/projects/boost/files/boost-docs/1.41.0/boost_pdf_1_41_0.zip/download (22.5Mb)
- https://sourceforge.net/projects/boost/files/boost-docs/1.41.0/boost_pdf_1_41_0.tar.bz2/download (22.2Mb)
- https://sourceforge.net/projects/boost/files/boost-docs/1.41.0/boost_pdf_1_41_0.7z/download (21Mb)
Thank you, John!
I extracted and uploaded the Spirit 2.1 documentation here: http://boost-spirit.com/dl_docs/spirit2_1.pdf
Have fun!
P.S. Don’t forget to visit this site every once in a while. We are posting tips, tutorials and addendum. Check out the Articles section.
Debugging Support (Doc Addendum)
Somehow, this did not make it into the 2.1 documentation. This important piece of information shouldn’t languish too far into the abyss. So here it is…
The Spirit2 Advantage
Why would you want to upgrade to Spirit2 from “Classic” Spirit?
Here’s a teaser:
Spirit 1.x [ straight pattern matching (no actions) ]
real 0m0.359s
user 0m0.332s
sys 0m0.012sSpirit 1.x [ parse tree generation ]
real 0m9.305s
user 0m9.209s
sys 0m0.076sSpirit 2.1 [ AST with variant nodes generation ]
real 0m0.459s
user 0m0.432s
sys 0m0.028s
Spirit 2.1 Released!!!
The much-awaited Spirit 2.1 is now released after more than 2 years in beta (Spirit 2.0). Boost release 1.41.0 includes Spirit 2.1. This is the official release of the new Spirit 2.1, a completely new library for parsing, lexing, and output generation.
Boost release 1.41.0 is now available!
This release contains one new library and numerous bug fixes for existing libraries. For details, including download links, see
http://www.boost.org/users/news/version_1_41_0
The release can also be downloaded directly from SourceForge. See
http://sourceforge.net/projects/boost/files/
To install this release on your system, see
http://www.boost.org/doc/libs/1_41_0/more/getting_started/index.html
Thanks,
–The Boost release team
Output Generation from a List of Key-Value Pairs Using Spirit.Karma
Even if it feels a bit like cheating I decided to get back to the example highlighting lists of key/value pairs I initially wrote about here. On the other hand looking at this very same problem from the standpoint of generating output allows me to highlight a couple a interesting facilities Spirit provides you with.
Zero to 60 MPH in 2 seconds!
Wanna make a blazingly fast rule? Use BOOST_AUTO! Check it out here. The code defines a named rule using C++0x auto when available and falls back to some template wizardry on older compilers.
Recent Comments