LL parser framework represents parsers directly as EBNF grammars in inlined C++14
Questions tagged [boost-spirit-x3]
281 questions
2
votes
1 answer
How to rewrite qi parsers with inherited attributes in x3?
If the inherited attributes are used in semantic actions, we can use x3::with directive.
What if we want to use the attributes as part of the parser? For example a simple parser matches 1 or more alphabet characters except the character is from a…

wanghan02
- 1,227
- 7
- 14
2
votes
1 answer
spirit x3 cannot propagate attributes of type optional
A simple parser as on Coliru. The parser -(+x3::alpha) should be able to propagate an attribute of type boost::optional as Qi does. But it does not compile.
std::string const input = "abc";
boost::optional…

wanghan02
- 1,227
- 7
- 14
2
votes
0 answers
Boost optional with spirit X3
I have below simple grammar:
namespace parser {
using x3::lexeme;
using x3::lit;
using x3::ascii::char_;
using my_attr = std::pair, std::string>;
x3::rule ncname =…

Arunmu
- 6,837
- 1
- 24
- 46
2
votes
1 answer
Spirit X3: Basic example for compound components does not compile
This code, taken verbatim from the x3 documentation, does not compile
#include
#include
#include
namespace x3 = boost::spirit::x3;
int main(int argc, char* argv[]) {
std::string input("(1.0,…

dvd
- 1,014
- 6
- 12
2
votes
2 answers
boost spirit x3 (A | A) attribute type is variant instead of A
I'm trying to create a simple parser that takes one of two possible characters using boost::spirit::x3. The problem is that x3::char_('#') | x3::char_('.') seems to have an attribute of type boost::variant. This means I have to use…

aeubanks
- 1,261
- 1
- 12
- 12
2
votes
1 answer
Encapsulate Spirit X3 parser in class
I tried to encapsulate a X3 parser in a class, where the rules (and their definitions) are members, i.e. similar to the structure of a Qi parser where one had to derive from boost::spirit::qi::grammar.
What would be the advantages of this…

sapi
- 111
- 5
2
votes
0 answers
Semantic action seems to break attribute compatiblity
It seems that adding a semantic action can break attribute compatibility.
The following simple example works and compiles as expected:
auto pair_rule = x3::rule>()
= x3::alnum >> '=' >>…

haphi
- 74
- 4
2
votes
1 answer
How to do no_case in Spirit x3
I have a problem that IDK how to do no_case in spirit X3.
There is no_case in Spirit, but when I use it I get:
// If you get an error no matching function for call to 'as_parser'
// here, for either p or s, then p or s is not a parser or…

NoSenseEtAl
- 28,205
- 28
- 128
- 277
2
votes
1 answer
Parsing pair of strings fails. Bad spirit x3 grammar
I would like to parse key-value pairs, mapping strings to strings. Since i want to support blocks of { ... } for right hand sides i came up with a simple grammar to start with
#include
#include…

Maikel
- 1,204
- 7
- 19
2
votes
0 answers
Is it possible to deduce the type of (expected) attribute of a Spirit X3 grammar?
I have this typical Spirit code.
#include
#include
#include
using std::cout;
int main(){
namespace x3 = boost::spirit::x3;
boost::fusion::vector p;
…

alfC
- 14,261
- 4
- 67
- 118
2
votes
1 answer
Spirit-X3 parsers stored in variable template specializations not working on Clang
I have a working Spirit-X3 parser, that can parse two closely related grammars for setting up draughts and checkers positions. I define two variable templates specializations as parsers for the two dialects of the grammar:
// general variable…

TemplateRex
- 69,038
- 19
- 164
- 304
2
votes
1 answer
parsing from std::string into a boost::string_view using boost::spirit::x3
In my my previous question it was suggested that the performance of my boost::spirit::x3 parser could be improved by parsing into a boost::string_view using the raw directive.
However, I have difficulties getting it to compile.
This is what I found…

m.s.
- 16,063
- 7
- 53
- 88
2
votes
2 answers
how to improve performance of boost::spirit::x3 key-value parser
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…

m.s.
- 16,063
- 7
- 53
- 88
2
votes
3 answers
Why does this Boost.Spirit x3 rule parse correctly with angle brackets, but incorrectly with quotes?
The program below tries to parse C++ header include strings, such as "my/file.hpp" and . For reasons I don't understand, my code fails to parse the " headers. Is this a bug in Spirit, or am I missing something obvious?
#include…

Barrett Adair
- 1,306
- 10
- 24
2
votes
1 answer
repeat to std::tuple with known N at compile time
i want to parse a at compile time specified number of elements. I've tried the repeat()[] directive. The following code shows my case:
using namespace x3;
std::tuple tup;
std::string str{"0.3 0.2 0.1"};
auto ret =…

Roby
- 2,011
- 4
- 28
- 55