Questions tagged [boost-spirit]

Boost.Spirit is a set of C++ libraries for parsing and output generation implemented as Domain Specific Embedded Languages (DSEL) using Expression templates and Template Meta-Programming. The Spirit libraries enable a target grammar to be written exclusively in C++. Inline grammar specifications can mix freely with other C++ code and, thanks to the generative power of C++ templates, are immediately executable.

Boost.Spirit is a set of C++ libraries for parsing and output generation implemented as Domain Specific Embedded Languages (DSEL) using Expression Templates and Template Meta-Programming. The Spirit libraries enable a target grammar to be written exclusively in C++. Inline grammar specifications can mix freely with other C++ code and, thanks to the generative power of C++ templates, are immediately executable.

Spirit is part of Boost Libraries, a peer-reviewed, open collaborative development effort (see: http://www.boost.org).

You can find more information on Spirit's website here: http://boost-spirit.com/home/.

1419 questions
10
votes
4 answers

Too many sections, assembler error, using boost::spirit

I'm in the progress of writing a compiler for a subset of Java, using boost::spirit, for lexing and parsing. During compilation of the lexer/parser phase, the compiler consumes 1.6GB of RAM (g++ (GCC) 4.8.1), this is not an issue however, as there's…
Skeen
  • 4,614
  • 5
  • 41
  • 67
10
votes
1 answer

Ambiguous variant and boost spirit x3

Trying to tweak the boost spirit x3 calc example to parse functions that can take functions as arguments. However it does not compile. namespace client{ namespace ast{ struct ts; struct fnc; typedef boost::variant< ts, …
user2515328
  • 101
  • 3
10
votes
3 answers

How to match unicode characters with boost::spirit?

How can I match utf8 unicode characters using boost::spirit? For example, I want to recognize all characters in this string: $ echo "На берегу пустынных волн" | ./a.out Н а б е р е гу п у с т ы н н ы х в о л н When I try this simple boost::spirit…
Frank
  • 64,140
  • 93
  • 237
  • 324
9
votes
1 answer

Retrieving AST from boost::spirit parser

After I've read the tutorials on boost::spirit, I quite liked it because of the parser combinator syntax. Making a parser is so easy. Unfortunately, the tutorials were not as exact on the matter of getting a complex data structure out of the parser.…
Lanbo
  • 15,118
  • 16
  • 70
  • 147
9
votes
1 answer

Parsing python grammar with boost::spirit - problem

I am trying to write a python parser with boost::spirit library. Here is the code: template class Parser : public qi::grammar { public: Parser() : Parser::base_type(small_stmt) { NEWLINE =…
John
  • 93
  • 3
9
votes
1 answer

Boost.Spirit.x3 avoid collapsing two consecutive attributes of the same type into a vector

I am trying to learn Boost.Spirit, but I have found a difficulty. I am trying to parse a string into the following structure: struct employee { std::string name; std::string location; }; And it seems that when two attributes with the same…
Russell Greene
  • 2,141
  • 17
  • 29
9
votes
1 answer

Parsing a grammar with Boost Spirit

I am trying to parse a C-function like tree expressions like the following (using the Spirit Parser Framework): F( A() , B( GREAT( SOME , NOT ) ) , C( YES ) ) For this I am trying to use the three rules on the following grammar: template< typename…
lurscher
  • 25,930
  • 29
  • 122
  • 185
9
votes
1 answer

How do I parse end-of-line with boost::spirit::qi?

Shouldn't a simple eol do the trick? #include #include #include #include using boost::spirit::ascii::space; using boost::spirit::lit; using boost::spirit::qi::eol; using…
Greg Bacon
  • 134,834
  • 32
  • 188
  • 245
9
votes
1 answer

Spirit Qi attribute propagation issue with single-member struct

I have an compilation issue with Spirit Qi where it complains that value_type is not a member of identifier. For some reason, Qi's attribute system considers identifier to be a container type, and tries to enumerate it's value type. This is a…
namezero
  • 2,203
  • 3
  • 24
  • 37
9
votes
2 answers

How does boost::spirit::hold_any work?

Evidently hold_any has better performance than boost::any. How does it manage to do this? Edit: Thanks to Mat's comment, I found an answer by hkaiser about hold_any at another question but it lacks details. A more detailed answer would be welcome.
amit kumar
  • 20,438
  • 23
  • 90
  • 126
9
votes
1 answer

Parse int or double using boost spirit (longest_d)

I'm looking for a way to parse a string as an int or a double, the parser should try both alternatives and choose the one matching the longest portion of the input stream. There is a deprecated directive (longest_d) that does exactly what I'm…
Hugo Corrá
  • 14,546
  • 3
  • 27
  • 39
9
votes
1 answer

How can I use the skipper ascii::space WITHOUT skipping eol?

I have to use boost::spirit for parsing, and I want use phrase_parse function : qi::phrase_parse(str.begin(), str.end(), grammar, ascii::space - qi::eol); But the fourth term (ascii::space - qi::eol), isnt allowed by my compiler. How can I use the…
Henri Sylvain
  • 93
  • 1
  • 4
8
votes
1 answer

Change attribute type when parsing binary with boost::spirit

I have been successfully using boost::spirit::qi to to parse a stream consisting of the built-in parsers (e.g. byte_, little_word, etc). However, I now need to parse data that doesn't neatly fall into one of these categories. For example, I would…
Michael Koval
  • 8,207
  • 5
  • 42
  • 53
8
votes
1 answer

Boost spirit is too greedy

I'm in between a deep admiration about boost::spirit and eternal frustration not to understand it ;) I have problems with strings that are too greedy and therefore it doesn't match. Below a minimal example that doesn't parse as the txt rule eats up…
Tristram Gräbener
  • 9,601
  • 3
  • 34
  • 50
8
votes
1 answer

Boost Spirit Qi Re-Establish Skipping with custom skip grammar

I have a grammar that has, up until now, been using the standard boost::spirit::ascii::space/boost::spirit::ascii::space_type skipper. I have some rules that use the skipper and some that don't, like qi::rule(),…
jtolds
  • 3,341
  • 3
  • 17
  • 14
1 2
3
94 95