LL parser framework represents parsers directly as EBNF grammars in inlined C++14
Questions tagged [boost-spirit-x3]
281 questions
0
votes
1 answer
X3: Linker Error (unresolved external symbol "parse_rule") on nonterminal parser
First of all I am using MSVC 2017 (latest version).
Here is my code for the nonterminal parser:
player.hpp
namespace parse
{
namespace impl
{
namespace x3 = boost::spirit::x3;
struct _tag;
using player_type =…

NotMe
- 97
- 7
0
votes
1 answer
Templating Spirit X3 parser
In Boost Spirit QI it was easy to template the parser so that it could be instantiated for various attribute types. It is unclear to me how to do this with X3. Consider this stripped down version of the roman numerals parser example:
#include…

Henri Menke
- 10,705
- 1
- 24
- 42
0
votes
1 answer
Spirit: discarding attribute during backtracking
I don't understand the behaviour of x3 in the following example (taken from a larger grammar).
The grammar is a bit weird, granted, but roughly it implements (lal)?()?. When the second group is not present, it defaults to . I don't…

akim
- 8,255
- 3
- 44
- 60
0
votes
1 answer
Boost.Spirit: porting string pairs from Qi to X3
I have the following working Qi code:
struct query_grammar
: public boost::spirit::qi::grammar()>
{
query_grammar() : query_grammar::base_type(query)
{
query = pair >> *(boost::spirit::qi::lit('&') >>…

Jean-Michaël Celerier
- 7,412
- 3
- 54
- 75
0
votes
2 answers
How to allow ok spaces and ban bad ones with boost spirit
Motivating examples
good:
SELECT a, b, c d,e FROM t1
bad:
SE L ECT a, b, c d,e FR OM t1
SELECTa, b, c d,eFROMt1
So as you can see problem here is that some spaces are ok(between SELECT and a,b,c for example) and some are bad(SE L…

NoSenseEtAl
- 28,205
- 28
- 128
- 277
0
votes
1 answer
Parsing length dependent data structure using spirit x3
i’m trying to parse a binary data using spirit x3 and i’ve come across a problem, that I could not find a way to parse length dependent data structure, something like [uint32-counter][counter-length data].
Is it possible to pass attribute from one…

Igor G
- 1
0
votes
1 answer
parsing a single value into an ast node with a container
My problem is the following. I have an ast node which is defined as like the following:
struct foo_node{
std::vector value;
}
and I have a parser like this for parsing into the struct, which works fine:
typedef x3::rule

Exagon
- 4,798
- 6
- 25
- 53
0
votes
1 answer
Semantic checks with boost spirit x3
I am currently trying to write a compiler using boost spirit x3.
I finished the parser (without semantic actions and error handling right now, just parsing into ast).
Since I want to implement the language to support scopes and function calls, I ask…

Exagon
- 4,798
- 6
- 25
- 53
0
votes
1 answer
Boost Spirit X3 and std::unordered_map
I want to parse into a std::unordered_map.
Example Code:
struct Base
{
int item1;
int item2;
};
BOOST_FUSION_ADAPT_STRUCT(Base, item1, item2)
namespace grammar
{
using namespace boost::spirit::x3;
auto base_ = rule

Roby
- 2,011
- 4
- 28
- 55
0
votes
1 answer
AST arrangement during annotation and after
Tagged AST nodes can be visited during parsing in X3 using annotation_base::on_success.
Can I get their addresses (and store as well as another info, like corresponding input range iterator pair) and rely on its immutability (for all, but maybe…

Tomilov Anatoliy
- 15,657
- 10
- 64
- 169
-1
votes
1 answer
Parsing file input with spirit
I played around with boost::spirit recently and wanted to use it to parse file input. What i got is this: defining some semantic actions:
data = ifstream("herpderp", ios::in);
std::string line;
auto pri = [&](auto &ctx){cout << "got this" <<…

drinker
- 41
- 7