CppCon 2015: Michael Caisse “Using Spirit X3 to Write Parsers”

preview_player
Показать описание


Parsing is a common problem in many domains. The complexity of using a library often pushes developers to ad-hoc solutions utilizing std::string manipulations, regular expressions, or nested if/switch statements. Most “quick hack” implementations are unmaintainable.

Spirit provides a Domain Specific Embedded Language (DSEL) that allows grammars to be described in a natural and declarative manner just like writing PEG or EBNF directly in your C++ code. X3 is the third major release of the Spirit library and improves both compile and run times while simplifying the much of the library.

In this tutorial session you will be introduced to Spirit X3, attribute parsing, and variety of tips to writing efficient and maintainable parsers. We will build a JSON parser during the session to illustrate techniques and usage of the library. This session is applicable toward anyone needing to parse data.

Michael Caisse has been crafting code in C++ for nearly 25-years. He is a regular speaker at various conferences and is passionate about teaching and training. Michael is the owner of Ciere Consulting which provides software consulting and contracting services, C++ training, and Project Recovery for failing multidisciplinary engineering projects.



*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

Thank you for this great talk. Previously after reading documentation I failed to understand how to practically use spirit, now I actually understand what to do.

mishagolub
Автор

This is so much better than the black magic behind Lex & Yacc

xl
Автор

Wonderful talk. Just a word of advice for anyone trying to compile the code in the videos: Don't forget to #include This is apparently necessary for spirit to know how intuitively convert a boost::fusion::tuple into a std::pair.

nicobako
Автор

I'm glad you found the talk useful Misha.

MichaelCaisse_ciere
Автор

This is a great talk! I am sure we are ready for a new format for data. And with spirit we might be able to find a good starting point.

raghureddy
Автор

Is it possible to get debugging information with spirit x3?

allopeth
Автор

Spirit was first released with Boost 1.30 in 2003. Like any good, well-maintained project we continually look at new language features and mechanism to simplify Spirit's usage and improve performance.

MichaelCaisse_ciere
Автор

+Ziggi Mon
They did not, this is just Spirit v2 with cruft removed and more optimization, if anything this 'AXE' thing has duplicated Spirit, and if so then why did they? I was helping on Spirit V2 almost a decade ago, it is definitely not new, but it is very fast, concise, and powerful. Also as I recall X3 was just being released as life took me from focusing on Boost, which was pre-2011.

Overminddl
Автор

Presentation is great but using CPP rules for patterns is sadness.

johnjoyce
Автор

"BOOST_FUSION_ADAPT_STRUCT - you just give a reference to your type and bam! It fills it in.". Yea. Eclipse lets me browse all **1561** macro expansion steps. Quite a code from one ___VA_ARGS___

Xeverous