boost-spirit-x3

Spirit X3, How to get attribute type to match rule type?

為{幸葍}努か 提交于 2021-02-18 17:50:53
问题 For the development of Spirit X3 parser I want to use semantic actions(footnote 1). It is important for me to be in control of how to store attributes into STL containers. This question is about how to control that the parser attribute: _attr( ctx ) match the rule type: _val( ctx ) so that it can be assigned properly. Maybe this question boils down to how to apply the undocumented transform_attribute feature. But please read with me to see if that is actually the thing that solves it for me

BOOST_SPIRIT_DEFINE not understand

我们两清 提交于 2021-02-10 18:21:41
问题 I'm trying to write an expression parser with boost spirit x3. I based my new code on old code that I written years ago (and worked well) with Spirit 2.x (qi). The core of my code is: //Make new rule(s) for expression auto term = factor >> *(('*' >> factor) | ('/' >> factor)); auto expression = term >> *(('+' >> term) | ('-' >> term)); auto group = '(' >> expression >> ')'; auto factor = lexeme["double_"] | group; string s="12.4 + 3.2"; auto first = s.begin(); auto last = s.end(); bool r = x3

BOOST_SPIRIT_DEFINE not understand

戏子无情 提交于 2021-02-10 18:20:42
问题 I'm trying to write an expression parser with boost spirit x3. I based my new code on old code that I written years ago (and worked well) with Spirit 2.x (qi). The core of my code is: //Make new rule(s) for expression auto term = factor >> *(('*' >> factor) | ('/' >> factor)); auto expression = term >> *(('+' >> term) | ('-' >> term)); auto group = '(' >> expression >> ')'; auto factor = lexeme["double_"] | group; string s="12.4 + 3.2"; auto first = s.begin(); auto last = s.end(); bool r = x3

Is this the correct way of defining a set of recursive rules?

China☆狼群 提交于 2021-02-10 14:44:45
问题 PREFACE: I am asking this question because for some reason I can not get my code to compile. I just want to know whether an incorrect understanding of spirit::x3 is the cause or not Hello, I'd just like to verify something; is the following the correct way (at least technically) of defining rules for a large set of heavily recursive parsers? So for each parser, I do the following operations: // This is for reference only, it greatly simplifies the process of defining attributes. template

Boost Spirit x3 conditional (ternary) operator parser

我只是一个虾纸丫 提交于 2021-02-10 05:37:34
问题 I need to build an abstract syntax tree from mathematical expression that I later need to link domain specific objects together as a calculation tree. I found the expression parser library https://github.com/hmenke/boost_matheval as an excellent starting point. In my use case I need to have support for ternary conditional expressions condition ? true_exp : false_exp . As of now the parser is able to parse expressions such as 1 + (2 + abs(x)) or min(x,1+y) . However I would need to have syntax

Creating a boost::spirit::x3 parser for quoted strings with escape sequence handling

a 夏天 提交于 2021-02-10 05:27:32
问题 I need to create a parser for quoted strings for my custom language that will also properly handle escape sequences, which includes allowing escaped quotes within the string. This is my current string parser: x3::lexeme[quote > *(x3::char_ - quote) > quote] where quote is just a constant expression for '"' . It does no escape sequence handling whatsoever. I know about boost::spirit::classic::lex_escape_ch_p , but I've no idea how to use that with the boost::spirit::x3 tools (or in general).

Customizing the full error message for expectation failures (boost::spirit::x3)

旧时模样 提交于 2021-02-08 09:38:06
问题 The boost::spirit::x3 error handling utilities allow for the user to choose what is shown to the user when an expectation failure occurs. This, however, does not seem to be the case for the line number portion of the message, which is exactly what I'd like to modify. So instead of it printing out In line 1: etc. I would like to print some other message in it's place with the same line number info. Anyone know how I could do that, or if it is even modifiable in the first place? EDIT: Here's

Parsing Selector struct with alternating tokens using Boost Spirit X3

前提是你 提交于 2021-02-05 08:30:09
问题 I am trying to parse the following struct: struct Selector { std::string element; std::string id; std::vector<std::string> classes; }; This struct is used to parse selectors in the form element#id.class1.class2.classn . These selectors always start with 1 or no elements, could contain 1 or no ids, and could contain 0 to n classes. This gets even more complicated though, because classes and id can appear in any order, so the following selectors are all valid: element#id.class1 , .class1#id

Parsing Selector struct with alternating tokens using Boost Spirit X3

故事扮演 提交于 2021-02-05 08:28:06
问题 I am trying to parse the following struct: struct Selector { std::string element; std::string id; std::vector<std::string> classes; }; This struct is used to parse selectors in the form element#id.class1.class2.classn . These selectors always start with 1 or no elements, could contain 1 or no ids, and could contain 0 to n classes. This gets even more complicated though, because classes and id can appear in any order, so the following selectors are all valid: element#id.class1 , .class1#id

Issue with X3 and MS VS2017

三世轮回 提交于 2021-01-29 10:30:46
问题 I am having a weird problem with boost spirit X3 (v1.69) in combination with MS VS2017. I am getting compiling errors in well formed structures. When I use the same code block in gcc and clang through Coliru or Wandbox, the source compiles and everything goes right. But when I use that same code in VS 2017, compiling errors appears until I comment an 'omit' sentence. Please, any help with this? #include <vector> #include <iostream> #include <boost/spirit/home/x3.hpp> #include <boost/fusion