boost-spirit-x3

Ambiguous variant and boost spirit x3

血红的双手。 提交于 2019-12-04 18:22:43
问题 Trying to tweak the boost spirit x3 calc example to parse functions that can take functions as arguments. However it does not compile. namespace client{ namespace ast{ struct ts; struct fnc; typedef boost::variant< ts, boost::recursive_wrapper<fnc> > node; struct ts{ unsigned int id; }; struct fnc{ std::vector<char> id; std::vector<node> args; }; }} BOOST_FUSION_ADAPT_STRUCT( client::ast::ts, (unsigned int, id) ) BOOST_FUSION_ADAPT_STRUCT( client::ast::fnc, (std::vector<char>, id) (std:

how to improve performance of boost::spirit::x3 key-value parser

允我心安 提交于 2019-12-04 17:10:55
I am parsing key value pairs (similar to HTTP headers) using boost::spirit::x3 . When comparing the performance to my handwritten parser, boost::spirit::x3 is around 10% slower than that. I am using boost 1.61 and GCC 6.1: $ g++ -std=c++14 -O3 -I/tmp/boost_1_61_0/boost/ main.cpp && ./a.out phrase_parse 1.97432 microseconds parseHeader 1.75742 microseconds How can I improve the performance of the boost::spirit::x3 based parser? #include <iostream> #include <string> #include <map> #include <chrono> #include <boost/spirit/home/x3.hpp> #include <boost/fusion/adapted/std_pair.hpp> using header_map

Strange semantic behaviour of boost spirit x3 after splitting

这一生的挚爱 提交于 2019-12-04 14:04:38
I came across a strange behaviour of boost spirit x3, after I splittet my grammar up into the recommended parser.hpp , parser_def.hpp , parser.cpp files. My example gramar parses some kind of easy enums: enum = "enum" > identifier > "{" > identifier % "," > "} this is my enum grammar. When I don't split the enum and identifier parser into the recommended files, everything works fine, especially the string "enum {foo, bar}" throws an expectation failure, as expected. This example can be found here: unsplitted working example But when I split the exactly same grammar up into the different files,

How future-safe is it to write a parser with Boost Spirit X3?

别来无恙 提交于 2019-12-04 01:42:38
问题 I'm considering writing what is essentially my first parser since forever (= since the compiler class at Uni which I've forgotten mostly). Since I use C++, I was thinking of using Boost Spirit. Then I noticed there's the "regular" 2.5.2 and there's something magical subset of the code named Spirit X3. I' also ve noticed that Boost Spirit X3 was announced/discussed/pre-released already 2 years ago, yet Boost Spirit's official version is 2.5.2. Finally, I read: Where is boost-spirit 3? Is it

Spirit X3, Is this error handling approach useful?

自作多情 提交于 2019-12-03 23:17:45
问题 After reading the the Spirit X3 tutorial on error handling and some experimentation. I was drawn to a conclusion. I believe there is some room for improvement on the topic of error handing in X3. An important goal from my perspective is to provide a meaningful error message. First and foremost adding a semantic action that will set the _pass(ctx) member to false wouldn’t do it because X3 will try to match something else. Only throwing an x3::expectation_failure will quit the parse function

X3 parse rule doesn't compile

白昼怎懂夜的黑 提交于 2019-12-03 21:14:36
I'm learning Boost Spirit by writing a parser that parses two variants of hex number used by NAMS: Hex number with either suffix of 0x / 0h or prefix of h / x . Hex number with prefix of $ and must be followed by a decimal digit. Here is what I have come up so far and with Coliru Session : //#define BOOST_SPIRIT_X3_DEBUG #include <iostream> #include <boost/spirit/home/x3.hpp> #include <boost/spirit/home/x3/support/ast/variant.hpp> #include <boost/spirit/include/support_extended_variant.hpp> namespace x3 = boost::spirit::x3; namespace ast { struct hex_data : std::string {}; struct pascal_hex

Combining rules at runtime and returning rules

一曲冷凌霜 提交于 2019-12-02 03:37:22
问题 I am trying to write some complex parser made on top of Spirit-X3, so I need to know some things: ♦ How to combine rules at runtime. (with Nabialek's trick) ♦ Is it ok to return rules like this: x3::rule<char> SomeFunction(std::string &str) { x3::rule<char> foo; auto bar = baz; BOOST_SPIRIT_DEFINE(foo, bar); return foo; } PS: SomeFunction won't have a fixed return, so I can't use just a x3::sequence 回答1: Yes, x3 makes it a lot easier to compose rules. Mainly because parser expressions don't

Where is boost-spirit 3? Is it abandoned?

烂漫一生 提交于 2019-12-01 15:59:54
I can't find any download for boost spirit 3. Seems like the official website stopped talking about it at the end of December? Where did it go? The source code is available on Github . Documentation is here . Quoting from the Blog : C++ Now 2015. Today is the official release of Spirit X3, aka Spirit 3.0.0. X3 will be in beta, coexisting side by side with Qi, Karma, Lex and Classic. According to Sehe (see comments), X3 was included in the Boost release at least as far back as November 2015. Since it's header only though, I figure you could just as easily download Spirit from Github. If you

Where is boost-spirit 3? Is it abandoned?

非 Y 不嫁゛ 提交于 2019-12-01 14:39:18
问题 I can't find any download for boost spirit 3. Seems like the official website stopped talking about it at the end of December? Where did it go? 回答1: The source code is available on Github. Documentation is here. Quoting from the Blog: C++ Now 2015. Today is the official release of Spirit X3, aka Spirit 3.0.0. X3 will be in beta, coexisting side by side with Qi, Karma, Lex and Classic. According to Sehe (see comments), X3 was included in the Boost release at least as far back as November 2015.

How future-safe is it to write a parser with Boost Spirit X3?

随声附和 提交于 2019-12-01 09:20:43
I'm considering writing what is essentially my first parser since forever (= since the compiler class at Uni which I've forgotten mostly). Since I use C++, I was thinking of using Boost Spirit. Then I noticed there's the "regular" 2.5.2 and there's something magical subset of the code named Spirit X3. I' also ve noticed that Boost Spirit X3 was announced/discussed/pre-released already 2 years ago, yet Boost Spirit's official version is 2.5.2. Finally, I read: Where is boost-spirit 3? Is it abandoned? So I "know" that it's not an abandoned project - but not a very actively maintained project.