LL parser framework represents parsers directly as EBNF grammars in inlined C++14
Questions tagged [boost-spirit-x3]
281 questions
3
votes
1 answer
Spirit X3 : Can't compile any example on Ubuntu 16.04
Can't compile any example
on Ubuntu 16.04
$ g++ -std=c++14 main.cpp
In file included from /usr/include/boost/spirit/home/x3/nonterminal.hpp:14:0,
from /usr/include/boost/spirit/home/x3.hpp:20,
from…
user7029947
3
votes
1 answer
X3 parser segfaults with debug output (BOOST_SPIRIT_X3_DEBUG)
Update
This question touches on two issues (as shown by the accepted answer), both of which are present in the version of Boost Spirit X3 that ships with Boost 1.64, but both of which are now fixed (or at least detected at compile time) in develop…

sigbjornlo
- 1,033
- 8
- 20
3
votes
1 answer
spirit x3: locally defined rule definition must have an attribute attached?
Simple x3 code cannot compile because nothing is attached to the 2nd ruleTest or the whole parser. Even if we put x3::omit[ruleTest] around the second ruleTest it still cannot compile.
void Test(std::string const& str) {
auto const ruleTest =…

wanghan02
- 1,227
- 7
- 14
3
votes
1 answer
How to rewrite qi parsers with qi::_1/qi::_N in x3?
Let's say we want to parse an inner product expression and get the result.
"SUM({1, 2, 3} .* {4, 5, 6})"
qi::_1 and qi::_2 are very convenient to reference the ith attributes in the parser.
void Test(std::string const& input) {
…

wanghan02
- 1,227
- 7
- 14
3
votes
1 answer
spirit x3 rule cannot synthesize attribute of type boost::iterator_range in a sequence parser
In a simple parser test Live On Coliru,
std::string str("x123x");
boost::iterator_range::type> attr;
if( x3::parse( boost::begin(str), boost::end(str), x3::lit('x') >> x3::raw[+x3::digit] >> x3::lit('x'), attr…

wanghan02
- 1,227
- 7
- 14
3
votes
2 answers
Strange semantic behaviour of boost spirit x3 after splitting
I came across a strange behaviour of boost spirit x3, after I splittet my grammar up into the recommended parser.hpp, parser_def.hpp, parser.cpp files.
My example gramar parses some kind of easy enums:
enum = "enum" > identifier > "{" > identifier…

Exagon
- 4,798
- 6
- 25
- 53
3
votes
1 answer
Parsing a comma separated 0 or more list using boost spirit x3
I often need to parse a comma separated 0 or more list in boost spirit x3.
I know the %-operator which parses a 1 or more list into an std::vector.
When I need a 0 or more list I currently do it like this -(element_parser % separator), which does…

Exagon
- 4,798
- 6
- 25
- 53
3
votes
2 answers
linking errors while separate parser using boost spirit x3
I am currentyl trying to separate my boost spirit x3 parser into different _def and .cpp files using BOOST_SPIRIT_DEFINE/DECLARE/INSTANTIATE, but I keep getting a linking error.
HERE is my parser which is separated.
The linker error…

Exagon
- 4,798
- 6
- 25
- 53
3
votes
2 answers
Parser rule dependent on parameter
I was trying to define a parser where the rules are not fully pre-defined, i.e. they contain a variable part. This was no problem with Spirit Qi, but I was not able to implement it due to the static nature of X3. I tried the with directive, which is…

sapi
- 111
- 5
3
votes
2 answers
Internal compiler error, while using boost spirit x3
I am currently implementing expressions and the operator hierarchy for my DSL, using boost spirit X3.
I think my parser is semanticaly correct, but when I try to compile it, while compiling, gcc and clang having HUGE memory footprint, compiles for…

Exagon
- 4,798
- 6
- 25
- 53
3
votes
1 answer
problems parsing into recursive variant using boost spirit x3
I am currently trying to parse into a x3::variant, using boost spirit x3.
the variant looks like:
typedef x3::variant<
nil,
x3::forward_ast,
x3::forward_ast
> Type
where LambdaType and ClassType are looking…

Exagon
- 4,798
- 6
- 25
- 53
3
votes
0 answers
boost spirit x3 error handling error
I am trying to add error handling to one of my basic parsers.
The parsers are the following:
struct string_literal_id : error_handler_base, annotation_base{};
struct regex_literal_id : error_handler_base, annotation_base{};
struct bool_literal_id :…

Exagon
- 4,798
- 6
- 25
- 53
3
votes
1 answer
Parsing into structs with containers
How can use boost.spirit x3 to parse into structs like:
struct person{
std::string name;
std::vector friends;
}
Coming from boost.spirit v2 I would use a grammar but since X3 doesnt support grammars I have no idea how to do…

Exagon
- 4,798
- 6
- 25
- 53
3
votes
1 answer
boost::spirit::x3 attribute compatibility rules, intuition or code?
Is there a document somewhere which describes how various spirit::x3 rule definition operations affect attribute compatibility?
I was surprised when:
x3::lexeme[ x3::alpha > *(x3::alnum | x3::char_('_')) ]
could not be moved into a fusion-adapted…

experquisite
- 879
- 5
- 14
3
votes
1 answer
Efficiently parse trivial files with boost spirit X3
I am a novice with C++ and Boost Spirit X3. For my project I parse a geo-social graph from two files with the following structure with boost spirit X3 into a boost graph.
I have a working implementation. As I don't have any prior experience with the…

leezu
- 512
- 3
- 17