boost-spirit-x3

Boost Spirit X3: “Attribute does not have the expected size,” but why does it care?

半腔热情 提交于 2019-12-10 14:23:04
问题 I am trying to write a parser with Spirit X3, but I haven't gotten very far because I'm running into a compilation error that I can't figure out. I think I know what the compiler is complaining about, but what I don't understand is why it cares. The following code compiles (clang 3.9, Boost 1.62.0) and works. (I realize it's structured poorly and that there are built-in parsers for constants; I'm just trying to demonstrate the issue.) #define BOOST_SPIRIT_X3_DEBUG #include <iostream> #include

eps parser that can fail for a “post-initialization” that could fail

只谈情不闲聊 提交于 2019-12-10 11:44:58
问题 I'm reading the Boost X3 Quick Start tutorial and noticed the line eps is a special spirit parser that consumes no input but is always successful. We use it to initialize the rule's synthesized attribute, to zero before anything else. [...] Using eps this way is good for doing pre and post initializations. Now I can't help but wonder if an eps_that_might_fail would be useful to do some sort of semantic/post analysis on a part of the parsed input, which could fail, to have some sort of

Can spirit X3 work with BOOST_FUSION_ADAPT_ADT?

╄→гoц情女王★ 提交于 2019-12-10 10:14:54
问题 Change my codes from QI to X3, and get some compile error with BOOST_FUSION_ADAPT_ADT . I tried boost 1.64 and 1.67, neither of them work. I modified the spirit X3 example rexpr_min , adding getter and setter to struct rexpr , changing the BOOST_FUSION_ADAPT_STRUCT to BOOST_FUSION_ADAPT_ADT , and compile it fail, too. Enviroment: ubuntu 16.04 G++ 5.4, with -std=c++17 flag boost 1.67 Error message: boost/spirit/home/x3/core/detail/parse_into_container.hpp:142:35: error: invalid initialization

Eleminating left recursion in parser rule of spirit x3

梦想与她 提交于 2019-12-09 02:38:27
问题 I am currently stuck with a rule I am trying to parse using boost spirit x3. Here is te EBNF(using the % operator from spirit for lists) for what I am trying to parse: type ::= class_type | lambda_type lambda_type ::= more_arg_lambda | one_arg_lambda more_arg_lambda ::= "(", type%",", ")", "=>", type one_arg_lambda ::= type, "=>", type <- here is the left recursion class_type ::= identifier%"::", ["<", type%",", ">"] usng boost spirit x3, I am trying to parse into the following struct/variant

Simple sematic action destroys the result in Spirit X3

为君一笑 提交于 2019-12-08 12:45:53
问题 I have this Spirit X3 parser auto xyz_def = x3::omit[x3::int_] >> x3::eol >> (x3::lexeme[+(x3::char_ - x3::eol)]) >> x3::eol >> (*(chemical::parser::atom >> x3::eol) ; Which parses, with no problem something like this 2 Comment H 1.2 3.2 4.5 C 1.1 9.1 8.5 Now I want to use (instead of completely ignoring) the first integer as a hint to help build the vector (from the Kleen*). To do that I do: auto xyz_def = x3::omit[x3::int_[([](auto& ctx){x3::_val(ctx).reserve(x3::_attr(ctx));})]] >> x3::eol

Boost spirit x3 example calculator (calc8, calc9) linker error

若如初见. 提交于 2019-12-08 08:28:23
问题 I'm very new with boost spirit (and with boost). Its very interesting library. I use qtcreator + MinGW 5.3. I simply add every source file from git_hub_calc8 into new project and add some boost library, but i got the following error trying to build (All other examples work fine) C:\Program Files\boost\boost\boost\spirit\home\x3\nonterminal\rule.hpp:113: ошибка: undefined reference to `bool client::parser::parse_rule<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char,

Recursive x3 parser with results passing around

流过昼夜 提交于 2019-12-08 02:23:47
问题 (1) Say we want to parse a simple recursive block surrounded by {} . { Some text. { { Some more text. } Some Text again. {} } } This recursive parser is quite simple. x3::rule<struct idBlock1> const ruleBlock1{"Block1"}; auto const ruleBlock1_def = x3::lit('{') >> *( ruleBlock1 | (x3::char_ - x3::lit('}')) ) >> x3::lit('}'); BOOST_SPIRIT_DEFINE(ruleBlock1) (2) Then the block becomes more complex. It could also be surrounded by [] . { Some text. [ { Some more text. } Some Text again. [] ] } We

X3, how to populate a more complex AST?

别来无恙 提交于 2019-12-08 02:20:05
问题 Trying to generate an AST like the employee example that has more than just the employee. In my current mindset, the RExpressions example isn't helping me. The example I have doesn't compile, but I went as far as I understood in adding teams, departments, and corporations to the employee example. My problem is in understanding how to add the different structs into a variant and add the variant to phrase_parse, if that's the idea. In this example, there can be several of the same lines

Boost Spirit X3 AST not working with semantic actions when using separate rule definition and instantiation

谁说我不能喝 提交于 2019-12-07 04:44:16
问题 I am trying to use Boost Spirit X3 with semantic actions while parsing the structure to an AST. If I use a rule without separate definition and instantiation it works just fine, for example: #include <vector> #include <string> #include <iostream> #include <boost/fusion/include/adapt_struct.hpp> #include <boost/spirit/home/x3.hpp> namespace ast { struct ast_struct { int number; std::vector<int> numbers; }; } BOOST_FUSION_ADAPT_STRUCT( ast::ast_struct, (int, number) (std::vector<int>, numbers)

Boost spirit x3 example calculator (calc8, calc9) linker error

蹲街弑〆低调 提交于 2019-12-06 16:45:38
I'm very new with boost spirit (and with boost). Its very interesting library. I use qtcreator + MinGW 5.3. I simply add every source file from git_hub_calc8 into new project and add some boost library, but i got the following error trying to build (All other examples work fine) C:\Program Files\boost\boost\boost\spirit\home\x3\nonterminal\rule.hpp:113: ошибка: undefined reference to `bool client::parser::parse_rule<__gnu_cxx::__normal_iterator<char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, boost::spirit::x3::context<boost::spirit::x3::error