Questions tagged [boost-spirit-x3]

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

281 questions
3
votes
1 answer

Boost Spirit x3 parser has attribute of type std::vector> instead of std::string

Context I am using Boost Spirit X3 to generate HTML from Markdown files like this: // simplified code structure auto str = x3::lexeme[+(x3::char_ - x3::eol)]; auto h1_action = [&](auto& ctx) { /* generate output */ }; auto h1 = ("# " >…
melina
  • 68
  • 5
3
votes
3 answers

Spirit X3: Custom number parser yield unexpected leading zero in the result

I'm writing a long number parser, which identify a valid number (maybe not representable in builtin integer type) and store the string as-is. But the result included an unexpected leading '0'. The parser simply identify numbers in the form like…
Suen
  • 73
  • 6
3
votes
2 answers

Cannot parse an empty C++ struct with Boost Spirit X3

I'm trying to parse a C++ struct defined in a header file. I'm starting to define the grammar but I've a problem. This is my code: #include int main() { namespace x3 = boost::spirit::x3; // Parse "#if !defined…
Jepessen
  • 11,744
  • 14
  • 82
  • 149
3
votes
0 answers

Chaining semantic actions

I'm having trouble chaining semantic actions. I want to parse a percentage (X% with X a real number) and return its value as a float between 0 and 1. I also want to fail if the percentage is higher than 100%. What I have currently is a two almost…
rubenvb
  • 74,642
  • 33
  • 187
  • 332
3
votes
1 answer

Passing each element of a parsed sequence to a function that returns a rule's attribute type

I want to parse CSS color functions (for simplicity, all of the arguments are numbers between 0 and 255) rgb(r,g,b) rgba(r,g,b,a) hsl(h,s,l) hsla(h,s,l,a) into struct color { color(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a)…
rubenvb
  • 74,642
  • 33
  • 187
  • 332
3
votes
1 answer

Getting into boost spirit; Qi or X3?

I was making an interpreter for a small personal project with a friend; we started implementing all the classes and general structure in which the code would be translated to then execute just to postpone the actual parsing code into these…
Barnack
  • 921
  • 1
  • 8
  • 20
3
votes
1 answer

Can spirit X3 work with BOOST_FUSION_ADAPT_ADT?

Change my codes from QI to X3, and get some compile error with BOOST_FUSION_ADAPT_ADT. I tried boost 1.64 and 1.67, neither of them work. I modified the spirit X3 example rexpr_min, adding getter and setter to struct rexpr, changing the…
He Ming
  • 88
  • 6
3
votes
1 answer

Boost spirit x3 parser doesn't work with multiple attribute

The Spirit X3 parser function works well using 1 attribut. When I try to compile the code from the documentation with multiple attribute, it doesn't work. #include #include using namespace std; using namespace…
DrIDK
  • 7,642
  • 2
  • 14
  • 14
3
votes
1 answer

X3 parse rule doesn't compile

I'm learning Boost Spirit by writing a parser that parses two variants of hex number used by NAMS: Hex number with either suffix of 0x/0h or prefix of h/x. Hex number with prefix of $ and must be followed by a decimal digit. Here is what I have…
Yman Yen
  • 33
  • 2
3
votes
1 answer

Boost-Spirit (X3) parsing without default constructors

I'm trying to use Spirit X3 from Boost 1.65.1 to make a parser. I have reduced my problem to the following smaller example with simpler structures: #include #include #include…
senevoldsen
  • 337
  • 3
  • 8
3
votes
1 answer

X3: How to create parser to read in sets?

How would one create a rule for reading integers in sets of 3. I.e., ... 1 2 3 OK, 1 set of 3 ints 1 2 3 4 5 6 OK, 2 sets of 3 ints 1 2 3 4 5 ERROR, 1 set of 3 ints, 1 short for 2nd 1 2 3 4 5 6 7 8 9 …
Ender
  • 1,652
  • 2
  • 25
  • 50
3
votes
1 answer

Recursive rule in Spirit.X3

I want to parse a recursive grammar with Boost.Spirit x3, but it fails with a template instantiation depth problem. The grammar looks like : value: int | float | char | tuple int: "int: " int_ float: "float: " real_ char: "char: " char_ tuple:…
Jean-Michaël Celerier
  • 7,412
  • 3
  • 54
  • 75
3
votes
1 answer

How do I properly specify anchoring conditions in Spirit X3?

I am new to writing parsers. I am attempting to create a parser which can extract US zip codes from input text. I have created the following parser patterns, which do most of what I want. I am able to match 5 digit zip codes, or 9 digit zip codes…
Joe A
  • 33
  • 2
3
votes
1 answer

How future-safe is it to write a parser with Boost Spirit X3?

I'm considering writing what is essentially my first parser since forever (= since the compiler class at Uni which I've forgotten mostly). Since I use C++, I was thinking of using Boost Spirit. Then I noticed there's the "regular" 2.5.2 and there's…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
3
votes
1 answer

Parsing list of variants with boost spirit X3

I try to parse a simple list of float or int into a vector of variant. I'm using boost 1.64 on Windows (mingw 64bit). Here is a minimal example: #include #include…
Mike M
  • 2,263
  • 3
  • 17
  • 31
1 2
3
18 19