Questions tagged [boost-spirit-x3]

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

281 questions
1
vote
0 answers

Boost Spirit X3: linker error when trying to parse A > Unused > A into adapted struct

I created a parser based on the spirit x3 calc8/calc9 examples. A Linker error (see below ) is the result when using the following definition: const auto statement_def = expression > x3::eps > expression; with the following struct: struct…
Markus
  • 592
  • 3
  • 13
1
vote
1 answer

Using Spirit x3, how to control which parser is called on each different input?

I'm working with boost spirit x3 and am unclear on one point. I have a file that has very different and repetitive lines. The first few lines may be comments. The next 1000 lines may be coordinates, the next thousand lines may be a list of int's,…
Ender
  • 1,652
  • 2
  • 25
  • 50
1
vote
1 answer

using a boolean attribute instead optional in spirit x3

In the grammar I want to implement are some keywords where the enum matters (storing the enum id of the concrete keyword inside ast's node) or even only the existence of the same specific keyword - hence optional in a boolean context. I like to have…
Olx
  • 163
  • 8
1
vote
0 answers

Optimizing the grammar

Also have asked the question at boost spirit mailing list http://boost.2283326.n4.nabble.com/Spirit-X3-Boost-1-59-Compilation-never-finishes-for-a-recursive-grammar-td4693813.html I am working on creating an xpath2.0 parser as per the RFC. It's…
Arunmu
  • 6,837
  • 1
  • 24
  • 46
1
vote
1 answer

boost.spirit x3 move_to and list ast member

the BNF I implement has a funny rule where, depending on operator, the terms can be chained or event not at this production rule. Hence I use the same AST data structure since only the enumeration changes: #include…
Olx
  • 163
  • 8
1
vote
1 answer

How to define a spirit x3 parser that parses a single char from any encoding spaces?

If we ignore the attribute, this test::char_ will do the work. namespace test { struct any_char: x3::char_parser { static bool const has_attribute = false; template bool…
wanghan02
  • 1,227
  • 7
  • 14
1
vote
0 answers

Attribute value for missing optional boost::spirit::x3 rule

I have simple parser with some optional parts. And I've noticed what if I use a custom struct as attribute than omitted values are zero-initialized. struct face_triplet { int v, vt, vn; }; BOOST_FUSION_ADAPT_STRUCT( face_triplet, (int,…
Ryhor Spivak
  • 253
  • 1
  • 8
1
vote
1 answer

Passing a parser to a rule at run-time in X3

In spirit::qi one could pass a parser to a rule as an inherited attribute, and then use it directly: ... >> lazy(_r1) >> ... Is there any work-around for this in X3? I can "inject" the parser to the desired rule context using…
Igor R.
  • 14,716
  • 2
  • 49
  • 83
1
vote
1 answer

Boost spirit x3 parser throws std::logic_error while parsing

I created a grammar using boost spirit x3. While testing my resulting parser, i recognized that there is a case where the parser throws the following exeption: terminate called after throwing an instance of 'std::logic_error' what(): …
Exagon
  • 4,798
  • 6
  • 25
  • 53
1
vote
1 answer

Boost Spirit X3: Extracting Data into x3::variant<...> is always empty

I would like to parse some input as either a long or an std::string if it is quoted. The reasonable solution to this is to use x3::variant to store the data. Here is a sample program: #include #include…
Travis Gockel
  • 26,877
  • 14
  • 89
  • 116
1
vote
0 answers

parsing function calls as expressions using boost spirit x3

I am currently developing a DSL using boost spirit X3. I am using this example, to implementing expressions and the operator hierachy, and avoiding left recursion in the expression parsers. I also would like to implement a .-operator for member…
Exagon
  • 4,798
  • 6
  • 25
  • 53
1
vote
1 answer

boost spirit x3 double parser with restrictions

I am currently parsing doubles using boost spirit x3 with this parser: boost::spirit::x3::real_parser > const strict_double = {}; but it also parses doubles like .356 and 356. I would like to avoid this, and…
Exagon
  • 4,798
  • 6
  • 25
  • 53
1
vote
0 answers

Wrong attribute of sequence parser

I tried the following example from the spirit x3 docs #include #include #include "boost/spirit/home/x3.hpp" namespace x3 = boost::spirit::x3; int main() { std::pair p; std::string input("1.0 2.0"); …
Maikel
  • 1,204
  • 7
  • 19
1
vote
1 answer

Attribute propagation to nested map

I want to parse the following (first Column is Identifier, second Column (date) is unique for each Identifier followed by a tuple of…
Roby
  • 2,011
  • 4
  • 28
  • 55
1
vote
1 answer

How can I add conditional expectation points in spirit X3

I am currentl adding expectation points to my grammar in X3. Now I came accross an rule, which looks like this. auto const id_string = +x3::char("A-Za-z0-9_); auto const nested_identifier_def = x3::lexeme[ *(id_string >>…
Exagon
  • 4,798
  • 6
  • 25
  • 53