LL parser framework represents parsers directly as EBNF grammars in inlined C++14
Questions tagged [boost-spirit-x3]
281 questions
1
vote
1 answer
Parsing ipv4 address with Boost Spirit X3
X3 newbie here. Two questions:
Why the result contains repeated "1,1,1"s, like so: [[1, 9, 2, ., 1, 6, 8, ., 1, 1, 1, ., 1, 1, 1], [8, 0]] , when I expect something like this [[1, 9, 2, ., 1, 6, 8, ., 1, ., 1],…

psb
- 342
- 3
- 12
1
vote
1 answer
Mixing non-terminal rules from separeted translation unit
Introduction
I am trying to use two non-terminal rules while they are not defined in the same translation unit. A minimal example reproducing the issue is provided below, and is also available live on Coliru
TEST0
Re-using a rule directly (without…

Heyji
- 1,113
- 8
- 26
1
vote
1 answer
Transitioning Boost Spirit parser from boost::variant to std::variant 2
I am trying to have an x3 parser work with std::variant instead of boost::variant, without success.
I followed the post on this subject: transitioning boost spirit parser from boost::variant to std::variant but the required boiler plate to have it…

Heyji
- 1,113
- 8
- 26
1
vote
1 answer
Can't compile a boost::spirit::x3 parser with lambda parameters
Based on an answer here, I wrote the following parser:
#include
#include
#include
#include
#include
namespace x3 = boost::spirit::x3;
int…

Bobo Feugo
- 162
- 1
- 10
1
vote
1 answer
Boost Spirit X3: How to recover both matched and unmatched results of a rule
Consider the following sample text line:
"Hello : World 2020 :tag1:tag2:tag3"
I want to design a spirit X3 parser that can extract:
Content := "Hello : world 2020 "
Tags := { tag1,tag2,tag3 }
The problem: Content is defined as leftover char…

Aaron
- 11
- 2
1
vote
1 answer
Is this the correct way of defining a set of recursive rules?
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…
user13501676
1
vote
1 answer
Customizing the full error message for expectation failures (boost::spirit::x3)
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…
user13501676
1
vote
2 answers
Parsing Selector struct with alternating tokens using Boost Spirit X3
I am trying to parse the following struct:
struct Selector {
std::string element;
std::string id;
std::vector classes;
};
This struct is used to parse selectors in the form element#id.class1.class2.classn. These selectors…

Jaime Ivan Cervantes
- 3,579
- 1
- 40
- 38
1
vote
1 answer
Synthesize to smart pointers with Boost Spirit X3
I need to parse a complex AST, and it would be impossible to allocate this AST on heap memory, and the AST nodes must support polymorphism. One solution would be to allocate the AST nodes using smart pointers.
To simplify the question, how would I…

Jaime Ivan Cervantes
- 3,579
- 1
- 40
- 38
1
vote
1 answer
Boost Spirit x3 conditional (ternary) operator parser (follow up question)
This question is a follow up question for the one in
Boost Spirit x3 conditional (ternary) operator parser
The original question context did not show (my bad!) the ast attributes and the answer therefore could not take all the moving parts into…

Lauri
- 73
- 8
1
vote
1 answer
Splitting Boost.Spirit.X3 parsers into several TUs
I'm struggling with Boost.Spirit.X3 again.
I have several logical groups of parsers (statements, expressions, etc.), each of which is represented by several files:
group.hpp - contains typedefs, BOOST_SPIRIT_DECLARE and extern variable declaration…

GooRoo
- 661
- 3
- 9
1
vote
1 answer
Apply to_upper when parsing unquoted strings
In a foo_def.hpp file for a Boost.Spirit X3 project, I have parsers:
auto const identifier_component_unrestricted =
lexeme[(alpha | '_') >> *(alnum | '_')];
auto const identifier_component_def =
((identifier_component_unrestricted -…

Matt
- 20,108
- 1
- 57
- 70
1
vote
1 answer
Parse IRC Message with Boost Spirit
I can get a basic parse to run with Boost.Spirit but have trouble getting the message tags (IRCv3) to fully parse. I want the tags to at least parse individually into a vector<> but would love to have them parse into a map<>.
#include…

Robert M
- 71
- 1
- 7
1
vote
1 answer
Expecting sequences and alternations of char_ parsers to synthesize a string
In the following test case, the alternation of one alpha and a sequence bombs with a long error dump basically saying static assertion failed: The parser expects tuple-like attribute type. Intuitively, I expected the entire rule to produce a string…

Engineerist
- 367
- 2
- 13
1
vote
1 answer
Boost spirit x3 tuple member in fusion-adapted struct
The following test case is a reduction of a larger, multi-file parser, hence the slightly odd order of declarations and definitions. It does not compile and my understanding is that the std::tuple trips it. From the docs it seems to me that the…

Engineerist
- 367
- 2
- 13