LL parser framework represents parsers directly as EBNF grammars in inlined C++14
Questions tagged [boost-spirit-x3]
281 questions
1
vote
0 answers
Parsing an indentation based grammar with Spirit X3
I have to parse an indentation based language (like python, yaml or coffee), and thinking about using spirit X3.
I know I can use Spirit Lex or some other lexer library for generating indent/dedent tokens.
Does X3 provide another way to accomplish…

Dutow
- 5,638
- 1
- 30
- 40
1
vote
1 answer
When exactly can I use the expectation operator?
I am working on a parser with boost spirit x3. I finished the grammar and the parser parses as expected. Now I want to add error handling, so I have to add expectation points to my grammar.
My question is when exactly can I use the expectation…

Exagon
- 4,798
- 6
- 25
- 53
1
vote
1 answer
parser doesn't fail, skipper doesn't skip
I have problem's with my grammar. I'm not sure why the date get parsed and why i doesn't need the lexeme parser.
Full Example
Live On Coliru
#define BOOST_SPIRIT_X3_DEBUG
#include
#include
#include…

Roby
- 2,011
- 4
- 28
- 55
1
vote
1 answer
Will I get a faster parser using spirit X3 when I use the expect operator
In spirit X3 I can build a parser like this:
const auto p = ("Number:" >> x3::_int)
| ("String:" >> +x3::alpha);
If I know after the string Number comes a int and after String a string all the time I can use the > to say after Number…

Exagon
- 4,798
- 6
- 25
- 53
1
vote
1 answer
Starting with Spirit X3
I've just started using Spirit X3 and I have a little question related with my first test. Do you know why this function is returning "false"?
bool parse()
{
std::string rc = "a 6 literal 8";
auto iter_begin = rc.begin();
auto iter_end…

Sen
- 29
- 5
1
vote
2 answers
How to get around greedy rd?
I want to parse a string that can contain a '-', but not start nor end with it.
I expected this parser to work:
auto const parser = alnum >> -(*(alnum | char_('-')) >> alnum);
But in my test input "something" it only parses the "so" and doesn't eat…

matiu
- 7,469
- 4
- 44
- 48
1
vote
1 answer
Parsing a number into a string with boost spirit x3
I would like to parse various numbers with spirit x3 into a string. I tried to do it like this, but it doesnt work.
typedef x3::rule int_parser_type;
const int_parser_type int_parser = "int_parser";
auto const…

Exagon
- 4,798
- 6
- 25
- 53
1
vote
1 answer
eps parser that can fail for a "post-initialization" that could fail
I'm reading the Boost X3 Quick Start tutorial and noticed the line
eps is a special spirit parser that consumes no input but is always successful. We use it to initialize the rule's synthesized attribute, to zero before anything else. [...] Using…

rubenvb
- 74,642
- 33
- 187
- 332
1
vote
1 answer
Empty strings in vector returned from boost spirit x3 parser
I want to check a file for all enums(this is just an MCVE so nothing complicated) and the name of the enums should be stored in an std::vector I build my parsers like this:
auto const any = x3::rule{"any"}
…

Exagon
- 4,798
- 6
- 25
- 53
1
vote
1 answer
Spirit X3 with boost::string_ref construction from semantic action
im confused with boost Spirit X3 and string_ref class. How to construct a string_ref object. The console prints somethink like this :
N5boost16basic_string_refIcSt11char_traitsIcEEE /…

Roby
- 2,011
- 4
- 28
- 55
1
vote
1 answer
Spirit X3 Compile Error "a template declaration cannot appear at block scope"
im trying a small example to get startet with Spirit X3.
template
bool parser(Iterator& first, Iterator const& last)
{
using namespace x3;
x3::rule const quote = "quote";
auto quote_def =…

Roby
- 2,011
- 4
- 28
- 55
1
vote
1 answer
Boost Spirit X3 local variables and getting the synthesized attribute
I'm trying to port a parser from Spirit V2 to X3. The overall experience is quite good but there are two problems.
The first one is that local variables are gone, which is quite inconvenient to me since I used them quite often to keep track of…

LChris314
- 75
- 5
1
vote
1 answer
Parse 64bit hex numbers
I am using spirit X-3 and want to parse RAM addresses that are represented in hex, like "00ff0af0".
For 64 bit systems the addresses would have a size of 64 bit.
Unfortunately boost::spirit::x3::hex uses unsigned.
What can I do to parse 64 bit hex…

mfuchs
- 2,190
- 12
- 20
0
votes
0 answers
How to compile from ast to a program that can support line step execution?
I'm using boost.spirit.x3 to parse a simple script-like context to an ast(Abstract Syntax Tree). and as a complete novice in this parser & compiler area, i am starting from a boost's example which called calc9, this example demonstrate how context…

Alfred Li
- 25
- 1
- 4
0
votes
1 answer
Boost spirit X3: Unable to create an AST that has a optional list
I am trying to parse a optional list of things followed by a semicolon (this is a simplified example). Below is a example program:
#include
#include
#include…

user3716072
- 187
- 1
- 2
- 14