LL parser framework represents parsers directly as EBNF grammars in inlined C++14
Questions tagged [boost-spirit-x3]
281 questions
14
votes
1 answer
Boost Spirit X3 cannot compile repeat directive with variable factor
I am trying to use the Boost Spirit X3 directive repeat with a repetition factor that is variable. The basic idea is that of a header + payload, where the header specifies the size of the payload. A simple example “3 1 2 3” is interpreted as header…

Guilherme Schlinker
- 317
- 2
- 10
11
votes
1 answer
Eleminating left recursion in parser rule of spirit x3
I am currently stuck with a rule I am trying to parse using boost spirit x3.
Here is the 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 |…

Exagon
- 4,798
- 6
- 25
- 53
10
votes
1 answer
Where is boost-spirit 3? Is it abandoned?
I can't find any download for boost spirit 3.
Seems like the official website stopped talking about it at the end of December? Where did it go?

Oliver K
- 295
- 2
- 15
10
votes
1 answer
Ambiguous variant and boost spirit x3
Trying to tweak the boost spirit x3 calc example to parse functions that can take functions as arguments. However it does not compile.
namespace client{ namespace ast{
struct ts;
struct fnc;
typedef boost::variant<
ts,
…

user2515328
- 101
- 3
9
votes
1 answer
Boost.Spirit.x3 avoid collapsing two consecutive attributes of the same type into a vector
I am trying to learn Boost.Spirit, but I have found a difficulty.
I am trying to parse a string into the following structure:
struct employee {
std::string name;
std::string location;
};
And it seems that when two attributes with the same…

Russell Greene
- 2,141
- 17
- 29
8
votes
1 answer
Is Boost Spirit X3 production ready?
I'm migrating a hand-written parser to Boost.Spirit (2.5.4). First impressions are positive, but since I'm using C++17, X3 seems like a very attractive option.
Fortunately, there are many resources available about X3:
many questions about X3 on…

akim
- 8,255
- 3
- 44
- 60
8
votes
2 answers
Spirit X3, semantic action makes compilation fails with: Attribute does not have the expected size
This code does not compiles (gcc 5.3.1 + boost 1.60):
#include
namespace x3 = boost::spirit::x3;
template
void parse(T begin, T end) {
auto dest = x3::lit('[') >> x3::int_ >> ';' >> x3::int_ >> ']';
…

dvd
- 1,014
- 6
- 12
8
votes
3 answers
Compile times with boost spirit x3
I'm trying to get a grip with the new Spirit X3 (boost 1.61.0).
My machine is a MacBook Pro (i7-4750HQ) running Linux.
Having used version 2 of Spirit I was used to large compile times, but this doesn't feel right. For the following first steps of…

Mike M
- 2,263
- 3
- 17
- 31
7
votes
0 answers
How to annotate the AST with position information with boost spirit x3?
So, I've written my grammar and would like to provide some debug information like line numbers in order to be able to step through the generated executable code with my own debugger.
After some googling I found that one can fully define the tag…

UsYer
- 173
- 1
- 8
7
votes
1 answer
Boost Spirit X3 AST not working with semantic actions when using separate rule definition and instantiation
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
#include
#include…

Guilherme Schlinker
- 317
- 2
- 10
6
votes
1 answer
How to do "stream" parsing in Boost Spirit X3?
I am trying to find out the correct way to parse from an istream using x3. Older docs refer to multi_pass stuff, can I still use this? Or is there some other way to buffer streams for X3 so that it can backtrack ?

experquisite
- 879
- 5
- 14
6
votes
1 answer
Parsing comma-separated list of ranges and numbers with semantic actions
Using Boost.Spirit X3, I want to parse a comma-separated list of ranges and individual numbers (e.g. 1-4, 6, 7, 9-12) into a single std::vector. Here's what I've come up with:
namespace ast {
struct range
{
int first_, last_; …

TemplateRex
- 69,038
- 19
- 164
- 304
6
votes
1 answer
Boost Spirit (X3) symbol tables resulting in UTF8 strings
I'm trying to parse LaTeX escape codes (e.g. \alpha) to the Unicode (Mathematical) characters (i.e. U+1D6FC).
Right now this means I am using this symbols parser (rule):
struct greek_lower_case_letters_ : x3::symbols
{
…

rubenvb
- 74,642
- 33
- 187
- 332
6
votes
1 answer
Using std::array as Attribute for boost::spirit::x3
I'm trying to parse a list of numbers into a fixed sized std::array container using boost::spirit's newest release x3 (as included in boost 1.54).
Since std::array has the necessary functions, it is detected as an Container, but it is lacking the…

ithron
- 310
- 3
- 9
5
votes
1 answer
How to make a recursive rule in boost spirit x3 in VS2017
I've written the following recursive rule in boost::spirit::x3 but it only seems to compile in g++/clang, not VS2017 (15.5.3):
#include
#include
namespace lex3
{
namespace x3 = boost::spirit::x3;
…

Borgleader
- 15,826
- 5
- 46
- 62