boost-spirit

Boost Spirit Implement small one-line DSL on a server application

╄→尐↘猪︶ㄣ 提交于 2019-12-01 09:27:23
问题 Apologies if this question has been answered before. I want to insert a small DSL into a server application I work on. The syntax is very simple and even at this early stage I am stumped. I just can't get my head around how to construct the syntax in spirit. Here is an example of the syntax I want to test for: WHERE [not] <condition> [ and | or <condition> ] <command> [parameters] The WHERE clause will select a number of objects from an internal store by testing named properties on them. The

cannot get boost::spirit parser&lexer working for token types other than std::string or int or double

。_饼干妹妹 提交于 2019-12-01 09:27:07
This does not compile (code below). There was another question here with the same error. But I don't understand the answer. I already tried inserting qi::eps in places -- but without success. I also tried already adding meta functions (boost::spirit::raits::is_container) for the types used -- but this also does not help. I also tried using the same variant containing all types I need to use everywhere. Same problem. Has anybody gotten this working for a lexer returning something else than double or int or string? And for the parser also returning non-trivial objects? I've tried implementing

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.

How to make Boost.Spirit.Lex token value be a substring of matched sequence (preferably by regex matching group)

不羁岁月 提交于 2019-12-01 08:07:47
问题 I'm writing a simple expressions parser. It is build on a Boost.Spirit.Qi grammar based on Boost.Spirit.Lex tokens (Boost in version 1.56). The tokens are defined as follows: using namespace boost::spirit; template< typename lexer_t > struct tokens : lex::lexer<lexer_t> { tokens() : /* ... */, variable("%(\\w+)") { this->self = /* ... */ | variable; } /* ... */ lex::token_def<std::string> variable; }; Now I would like the variable token value to be just the name (the matching group (\\w+) )

Function or functor calling using sprit boost parser library rule to save values in vector c++

放肆的年华 提交于 2019-12-01 08:07:28
I want to parse this line and storing all hex values in functor <005F> <0061> [<00660066> <00660069> <00660066006C>] this values in txt file and m reading this fill line by line like 005F 0061 00660066 00660069 00660066006C all values should be in vector but its not working the spirit rule is to parse this line is rule<> blanks = *blank_p; rule<> parse_int = blanks >> "<" >> int_p [AddEntry] >> ">"; rule<> parse_ints = *parse_int ; rule<> parse_range = *parse_int >>"[" >> blanks >> *parse_int >> "]"; int status = parse (line.c_str(), *( parse_range ) ).full; and my functor is this struct

Is it possible to reuse a Spirit Qi grammar as a Spirit Karma grammar?

做~自己de王妃 提交于 2019-12-01 07:48:49
问题 I have a Qi grammar definition that I use to parse an input. Later I have a Karma generator to output in a way that should be similar to the input. Is this possible at all? It seem that a parser grammar can be transformed into a generator grammar automatically (??). #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/karma.hpp> #include <iostream> int main(){ //test input std::string s = "Xx 1.233 pseudo"; //input variables std:

How to incrementally parse (and act on) a large file with Boost.Spirit.Qi?

十年热恋 提交于 2019-12-01 06:48:42
I've created a Qi parser for a custom text file format. There are tens of thousands of entries to process and each entry usually has between 1-10 subentries. I put a trimmed down working example of my parser here . #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <boost/spirit/include/phoenix_fusion.hpp> #include <boost/spirit/include/phoenix_stl.hpp> #include <boost/spirit/include/phoenix_object.hpp> #include <boost/spirit/include/support_istream

How to verify algebraic statements using boost::spirit?

无人久伴 提交于 2019-12-01 06:42:55
I'm trying to extend the calculator example so that instead of parsing and evaluating an algebraic expression, the parser will determine if an algebraic statement is true or not. By this I mean statements like 1 + 5 * 5 - 10 = 19 - 3 (desired parser result is true ) and 3 - 1 = 9 (desired parser result is false ). I've got to admit I'm new to boost::spirit and it's all kind of overwhelming at the moment. However, I do feel I understand the calculator example good enough to at least make some headway. Using the provided example as a starting point, the grammar looks like this: calculator() :

Internal Boost::Spirit code segfaults when parsing a composite grammar

混江龙づ霸主 提交于 2019-12-01 06:13:55
问题 I'm trying to use Spirit to parse expressions of the form Module1.Module2.value (any number of dot-separated capitalized identifiers, then a dot, then a lowercase OCaml-style identifier). My current definition of the parser looks like this: using namespace boost::spirit::qi; template <typename Iter=std::string::iterator> struct value_path : grammar<Iter, boost::tuple<std::vector<std::string>, std::string>()> { value_path() : value_path::base_type(start) { start = -(module_path<Iter>() >> '.')

Error when adapting a class with BOOST_FUSION_ADAPT_ADT

三世轮回 提交于 2019-12-01 05:29:19
问题 I've the following class: #ifndef WFRACTAL_FRACTAL_METADATA_H_ #define WFRACTAL_FRACTAL_METADATA_H_ #include <string> namespace WFractal { namespace Fractal { class Metadata { public: void setAuthorName(const std::string &name); void setAuthorEMail(const std::string &email); void setBriefDescription(const std::string &brief); void setCompleteDescription(const std::string &description); std::string getAuthorName() const; std::string getAuthorEMail() const; std::string getBriefDescription()