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

CppCon · 14K views · 2015 · 1:00:50

Open on YouTube

C, C++, Rust, Go & systems languagesCompilers, interpreters & program analysistalk

Why Stack Overflow recommends it

Stack Overflow users link it as the main walkthrough for learning Boost Spirit X3, and to show the talk's code when asking about X3 compile errors and grammar problems.

Recommended by 1 people across 1 different months, 2015 to 2022.

What it is

A CppCon 2015 tutorial by Michael Caisse on writing parsers with Boost Spirit X3, the declarative PEG/EBNF-style parsing library embedded in C++. It covers attribute parsing and tips for efficient, maintainable parsers, building a JSON parser as the worked example.

What people said

Recommends Jaime Ivan Cervantes · 2017-07 · Stack Overflow · on “Getting started guide for Boost.Spirit?”

If you want to learn about the new Boost Spirit X3, I would recommend this video [this video] . The powerpoint slides are found here [LINK] .

Cites John Estess · 2015-12 · Stack Overflow · on “Compile errors C++ Spirit X3 No viable overloaded =, No matching function for call to move_to”

Michael Caisse gave a talk on Spirit X3: [this video] . I've tried to transcribe the presentation to working code, but I have compilation errors that include "No viable overloaded '='" and "No matching function call to 'move_to.' Is my phrase_parse (last line) defined correctly? Are there any obvious errors? #include <boost/config/warning_disable.hpp> #include <boost/spirit/home/x3.hpp> #include <boost/spirit/home/x3/support/ast/variant.hpp> #include <boost/fusion/include/adapt_struct.hpp> #include <boost/fusion/include/std_pair.hpp> #include <boost/fusion/include/io.hpp> #include <boost/container/stable_vector.hpp> #include <iostream> #include <iterator> #include <fstream> #include <string> #inc

Cites sigbjornlo · 2017-04 · Stack Overflow · on “X3 parser segfaults with debug output (BOOST_SPIRIT_X3_DEBUG)”

Update This question touches on two issues (as shown by the accepted answer [LINK] ), both of which are present in the version of Boost Spirit X3 that ships with Boost 1.64, but both of which are now fixed (or at least detected at compile time) in develop branch at the time of writing (2017-04-30). I have updated the mcve project [LINK] to reflect the changes that I made to use the develop branch instead of the latest boost release, in the hopes that it might help out others who face a similar issues. The original question I am trying to learn how to break up Spirit X3 parsers into separate reusable grammars, as encouraged by the example code [LINK] (rexpr_full and calc in particular) and th

Cites WaterFox · 2022-11 · Stack Overflow · on “Grammar fails parsing tree with Boost Spirit X3”

I am playing with parsing a Newick tree format using Boost Spirit x3, and I fail at parsing a complete tree. Minimal reproducible example This is my attempted solution: namespace quetzal::newick::parser { namespace x3 = boost::spirit::x3; using x3::alpha; using x3::alnum; using x3::double_; using x3::rule; using x3::lit; rule<struct branch> branch{"branch"}; auto name = alpha >> *alnum; // to be improved later auto length = ':' >> double_; auto leaf = -name; auto internal= '(' >> (branch % ',') >> ')' >> -name; auto subtree = leaf | internal; auto tree = subtree >> ';'; auto const branch_def = subtree >> -length; BOOST_SPIRIT_DEFINE(branch); } The tests for parsing the internal grammar seems