Questions tagged [boost-spirit-x3]

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

281 questions
2
votes
2 answers

Spirit X3, How to get attribute type to match rule type?

For the development of Spirit X3 parser I want to use semantic actions(footnote 1). It is important for me to be in control of how to store attributes into STL containers. This question is about how to control that the parser attribute: _attr( ctx )…
Zeyneb
  • 115
  • 1
  • 8
2
votes
2 answers

Parsing float followed by string containing "e" character

I'm trying to parse this type of string 1.2e3ex 1.2e3 ex And have set up x3::float_ >> "ex" Unfortunately, this fails to parse 1ex Full example code: #include #include namespace x3 = boost::spirit::x3; const…
rubenvb
  • 74,642
  • 33
  • 187
  • 332
2
votes
1 answer

X3 rule for parsing `int_` then repeated doubles equal to that `int_`

Kind of a hard-to-word title but I wanna parse something like this: int_ >> repeat(N)[double_] But I'd like N to be equal to whatever int_ parses out to How does one do this using Boost.Spirit.X3?
ExBigBoss
  • 43
  • 6
2
votes
1 answer

Spirit X3: parser with internal state

I want to efficiently parse large CSV-like files, whose order of columns I get at runtime. With Spirit Qi, I would parse each field with a lazy auxiliary parser that would select at runtime which column-specific parser to apply to each column. But…
liori
  • 40,917
  • 13
  • 78
  • 105
2
votes
1 answer

Segmentation fault for nested boost::variant

The following program has been reduced from the original. I get a segmentation fault when it runs. If I remove line 24 with ArithmeticUnaryExpression then the program no longer crashes. How do I get rid of the segmentation fault? #include…
senevoldsen
  • 337
  • 3
  • 8
2
votes
1 answer

Boost.spirit (x3, boost 1.64): how to implement this recursive rule correctly, is it possible?

The question is easy to formulate. I have a recursive rule, I do not know the synthesized attribute type for the rule, but I also have a few more questions about the inner workings. It looks to me that the return type is…
Germán Diago
  • 7,473
  • 1
  • 36
  • 59
2
votes
1 answer

Boost Spirit X3 eol unexpected behaviour

This question in strictly related to boost-spirit-x3-parse-into-structs I have this grammar #include //#define BOOST_SPIRIT_X3_DEBUG #include #include #include…
Filippo
  • 361
  • 1
  • 5
  • 16
2
votes
1 answer

X3: Is this parser, *(char - eol), consuming any and all lines?

I'm basing my app off this example and getting the exact same results. For some reason, the contents of the input string are all parsed into the fusion struct 'comments', and nothing is parsed into the fusion struct 'numbers'. So not sure where I'm…
Ender
  • 1,652
  • 2
  • 25
  • 50
2
votes
1 answer

Statefulness of Spirit V2 and X3

What is the intent of Spirit X3 being so much 'stateless'? Bad aspects of 'states' in Spirit V2 Looking back to Spirit V2, the "grammar" was, say, conceptually stateful - in many ways. This is because the grammar was a class instance. Basically,…
saki7
  • 664
  • 6
  • 14
2
votes
1 answer

Spirit: Not able to use x3::skip(skipper)[some recursive rule] in its rule definition

Let's say we want to parse a recursive block like this. When "skip_comments_tag" is prefixed to the block, we skip all comments(/*...*/) within this block recursively. { {} { skip_comments_tag{ {} /*comments*/ …
wanghan02
  • 1,227
  • 7
  • 14
2
votes
2 answers

X3, what is attr_gen?

I end up getting these move errors a lot and am not quite sure why other than having something to do with the way I'm parsing strings. Remove everything having to do with 'dummy' and the errors come back. Someone mentioned using attr_gen (couldn't…
Ender
  • 1,652
  • 2
  • 25
  • 50
2
votes
1 answer

X3, how to populate a more complex AST?

Trying to generate an AST like the employee example that has more than just the employee. In my current mindset, the RExpressions example isn't helping me. The example I have doesn't compile, but I went as far as I understood in adding teams,…
Ender
  • 1,652
  • 2
  • 25
  • 50
2
votes
1 answer

How to write binary operator with two post operands syntax with Boost Spirit x3?

I am following this example: https://github.com/boostorg/spirit/blob/develop/example/x3/calc/calc9/expression_def.hpp What I am trying to accomplish is to write a rule that parses and generates like min{x}{y}. Mostly the code is using expression…
Syed Alam Abbas
  • 521
  • 6
  • 21
2
votes
1 answer

Recursive x3 parser with results passing around

(1) Say we want to parse a simple recursive block surrounded by {}. { Some text. { { Some more text. } Some Text again. {} } } This recursive parser is quite simple. x3::rule
wanghan02
  • 1,227
  • 7
  • 14
2
votes
1 answer

x3 linker error with separate TU

As my parser grows I separated some rules into different translation units (TU) and the linker problem rises. After weeks of several try&errors without success I reduced my ~50 rules to the (hopefully) minimal example presented here. I've read the…
Olx
  • 163
  • 8