LL parser framework represents parsers directly as EBNF grammars in inlined C++14
Questions tagged [boost-spirit-x3]
281 questions
1
vote
1 answer
Alternative attribute synthesis and AST design
In the grammar below, when I add the alternative (| property) to the start rule, I get this error
'boost::spirit::x3::traits::detail::move_to': none of the 3 overloads
could convert all the argument types
…

Brian
- 305
- 1
- 11
1
vote
1 answer
Unhelpful compiler errors in x3 grammar
The following Spirit x3 grammar for a simple robot command language generates compiler errors in Windows Visual Studio 17. For this project, I am required to compile with the warning level to 4 (/W4) and treat warnings as errors (/WX).
Warning …

Brian
- 305
- 1
- 11
1
vote
1 answer
Boost.X3: char_ >> char_ discards the characters and behaves like lit
I would like to parse strings with escaping rules similar to that of C. I want to keep the escapes, not decode them and recode afterwards. So I thought that *(char_('\\') >> char_ | char_ - '"') would do what I want, but it does not: it behaves as…

akim
- 8,255
- 3
- 44
- 60
1
vote
0 answers
Boost.X3: does not compile with std::optional
The following parser does not compile when I use std::optional for values of a -lexeme[+alpha] rule: something breaks in the attribute management.
The grammar works fine if instead of std::string I use int as a base type, it also works…

akim
- 8,255
- 3
- 44
- 60
1
vote
1 answer
Parse SQL like query with boost spirit x3
I'm trying to parse a simple SQL like query using boost spirit x3.
There were a similar post for the previous version of spirit. But With spirit x3, we don't need grammar.
So here is my attempt:
// SELECT chr, pos FROM table
// Select chr, pos FROM…

DrIDK
- 7,642
- 2
- 14
- 14
1
vote
1 answer
Idiomatic complete matching with post skipping
What is the most idiomatic way to do post-skipping? More specific I want to ensure there is no "non-skippable" (garbage) characters in my input after matching my top rule.
auto const blankOrComment
= ascii::space
| x3::lexeme ['#' >>…

senevoldsen
- 337
- 3
- 8
1
vote
1 answer
Spirit X3 not throwing expectation failure
From the documentation, it said says that when I use the expect operator, I should get an expectation_failure when the operator fails to match. I want to catch the exception to instruct the user where the erroneous input is. But it seems I get some…

senevoldsen
- 337
- 3
- 8
1
vote
0 answers
Boost apply_visitor and Sprit x3::forward_ast
I am having trouble making a visitor for the following reduced program:
#include
#include
#include
#include…

senevoldsen
- 337
- 3
- 8
1
vote
0 answers
forward_as_tuple being non-const
I was trying to pass a tuple of two different vectors as the attribute to a Spirit X3 rule. One sensible way to do this seemed to be to wrap these in a forward_as_tuple, since I only want to pass the references. That worked out nicely, but I had to…

cnettel
- 1,024
- 5
- 7
1
vote
1 answer
Boost.Spirit X3 compile time explodes with recursive rule
The following program takes 10s to compile. When I change the parenProcess rule below to '(' >> process >> ')' the compiler spends CPU but does not seem to finish. (I tried making a smaller reproducible program -- by removing rules between the…

senevoldsen
- 337
- 3
- 8
1
vote
1 answer
Synthesized attributes of partial matches from alternatives
When I remove x3::eps in the below rule, the string result from the first partial match is still in the second match, resulting in a string with duplicated content.
If I add another case in between I still only get 1 duplicate instead of two.
Why…

senevoldsen
- 337
- 3
- 8
1
vote
1 answer
Dependency injection of parsers using X3
Sometimes I have tight coupling / circular dependencies between parsers. I might have something like this:
parser.hpp
#pragma once
namespace parser {
using a_type = x3::rule;
a_type const a = "a";
using b_type =…

Justin
- 24,288
- 12
- 92
- 142
1
vote
2 answers
'parse': is not a member of boost::spirit::x3::unused_type
I'm trying to implement a HTTP header parser using Boost Spirit, however I've become stuck on a basic subtask: extracting the HTTP version number from the first line.
Simplified code:
#include
#include…

Paul Belanger
- 2,354
- 14
- 23
1
vote
1 answer
Using Spirit, how to populate vector within a struct of the AST?
I tried to adjust this example to make use of a variable number of elements using a group vector instead of hard coding 3 ints (n1, n2, n3), but to no avail.
Here is the example I've tried to modify.…

Ender
- 1,652
- 2
- 25
- 50
1
vote
1 answer
spirit x3 how to add a vector to an AST
I'm trying to parse a file and have the data copied into a vector within a class object. I've taken the employee example and modified it to what I'm trying to do. The file being parsed looks like this (but more lines) ...
1 0.2 0.3 0.4
I've added a…

Ender
- 1,652
- 2
- 25
- 50