Questions tagged [boost-spirit-x3]

LL parser framework represents parsers directly as EBNF grammars in inlined C++14

281 questions
2
votes
1 answer

Boost Spirit X3: skip parser that would do nothing

I'm getting myself familiarized with boost spirit v3. The question I want to ask is how to state the fact that you don't want to use skip parser in any way. Consider a simple example of parsing comma-separated sequence of integers: #include…
Yurii A
  • 369
  • 2
  • 10
2
votes
2 answers

Unintelligible compilation error for a simple X3 grammar

I have a quite simple grammar I try to implement using boost spirit x3, without success. It does not compile, and due to all the templates and complex concepts used in the library (I know, it is rather a "header"), the compilation error message is…
Heyji
  • 1,113
  • 8
  • 26
2
votes
2 answers

Type safety of Boost Qi/X3 parse

Consider this code using Boost Spirit X3 (conceptually same goes for Boost Spirit Qi): string command; string value; x3::parse(command.begin(), command.end(), "float:" >> x3::double_, value); Why is this code not generating any error during…
Tomasz Grobelny
  • 2,666
  • 3
  • 33
  • 43
2
votes
1 answer

Parsing variant of struct with a single member using Boost Spirit X3 and Fusion

I am trying to parse a std::Variant with a fusion-adapted Struct type that contains a single member. After several hours of trying to figure out the problem, I was able to reproduce the issue with this code: struct TestStruct { float…
Jaime Ivan Cervantes
  • 3,579
  • 1
  • 40
  • 38
2
votes
2 answers

Spirit X3, referring to a previously matched value

I'm writing a parser in Spirit X3 in order to get familiar with it, and even though I'm pretty familiar Qi I'm still hitting some stumbling blocks in X3. For example, the Qi examples include a basic XML parser that should you how to match a…
Addy
  • 2,414
  • 1
  • 23
  • 43
2
votes
1 answer

How to capture the value parsed by a boost::spirit::x3 parser to be used within the body of a semantic action?

I have a parser for string literals, and I'd like to attach a semantic action to the parser that will manipulate the parsed value. It seems that boost::spirit::x3::_val() returns a reference to the parsed value when given the context, but for some…
user13501676
2
votes
1 answer

Creating a boost::spirit::x3 parser for quoted strings with escape sequence handling

I need to create a parser for quoted strings for my custom language that will also properly handle escape sequences, which includes allowing escaped quotes within the string. This is my current string parser: x3::lexeme[quote > *(x3::char_ - quote)…
user13501676
2
votes
2 answers

Boost.Spirit.X3 how to prevent token from being parsed by previous rule?

given this grammar : const auto grammar_def = x3::lit("start") > x3::lit("{") > (*(char_("a-zA-Z0-9\".{}=_~"))) > x3::lit("}") > x3::lit(";"); the last x3::lit("}") is being…
2
votes
1 answer

Boost Spirit, obtain iterator inside semantic action

within a semantic action I want to get the iterator, preferably the entire iterator range from the first to last parsed character. When using the raw directive I could simply get it with _attr(context). I guessed that _where(context) does this, but…
The Techel
  • 918
  • 8
  • 13
2
votes
1 answer

How do you implement a custom parser object with boost spirit x3 such that it plays nice with a skipper?

I know I can implement a custom parser by making an object with the appropriate "parse" member function template, but I don't know what I need to do to make it use the skipper in the Context, which it seems to need to do. That is, below I expected…
jwezorek
  • 8,592
  • 1
  • 29
  • 46
2
votes
1 answer

Boost Spirit x3 conditional (ternary) operator parser

I need to build an abstract syntax tree from mathematical expression that I later need to link domain specific objects together as a calculation tree. I found the expression parser library https://github.com/hmenke/boost_matheval as an excellent…
Lauri
  • 73
  • 8
2
votes
1 answer

How do you get a string out of a Boost Spirit X3 lexeme parser?

What is the simplest way to make a semantic action that extracts a string from a typical identifier parser based on boost::spirit::x3::lexeme? I thought it might be possible to bypass needing to unpack the attribute and just use iterators into the…
jwezorek
  • 8,592
  • 1
  • 29
  • 46
2
votes
1 answer

Skippers in Boost.Spirit.X3

I'm trying to write a parser for the language with a little bit weird syntax and stumbled upon a problem with skippers which makes me think that I do not fully understand how they work in Boost.Spirit.X3. The problem is that for some rules EOLs are…
GooRoo
  • 661
  • 3
  • 9
2
votes
1 answer

How can I resolve mismatched alternative parsers and their attributes

I'm trying to parse into something of the form enum class shape { ellipse, circle }; enum class other_shape { square, rectangle }; enum class position { top, left, right, bottom, center, bottom }; struct result { std::variant
rubenvb
  • 74,642
  • 33
  • 187
  • 332
2
votes
2 answers

Spirit X3, Is this error handling approach useful?

After reading the the Spirit X3 tutorial on error handling and some experimentation. I was drawn to a conclusion. I believe there is some room for improvement on the topic of error handing in X3. An important goal from my perspective is to provide a…
Zeyneb
  • 115
  • 1
  • 8