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/.

1331 questions
80
votes
1 answer

more spirit madness - parser-types (rules vs int_parser<>) and meta-programming techniques

The question is in bold at the bottom, the problem is also summarized by the distillation code fragment towards the end. I am trying to unify my type system (the type system does to and from from type to string) into a single component(as defined by…
Hassan Syed
  • 19,054
  • 9
  • 76
  • 156
51
votes
2 answers

What is the name of this unusual C++ template feature used by Boost.Spirit?

The code below is from the Boost.Spirit x3 documentation. It uses an interesting C++ syntax that I've never seen before, which is nearly impossible to describe in a search query without knowing the proper terminology. Is this shorthand for the…
Barrett Adair
  • 1,251
  • 10
  • 24
51
votes
1 answer

boost spirit semantic action parameters

in this article about boost spirit semantic actions it is mentioned that There are actually 2 more arguments being passed: the parser context and a reference to a boolean ‘hit’ parameter. The parser context is meaningful only if the…
lurscher
  • 23,085
  • 26
  • 113
  • 178
42
votes
5 answers

What are the disadvantages of the Spirit parser-generator framework from boost.org?

In several questions I've seen recommendations for the Spirit parser-generator framework from boost.org, but then in the comments there is grumbling from people using Spirit who are not happy. Will those people please stand forth and explain to the…
Norman Ramsey
  • 188,173
  • 57
  • 343
  • 523
36
votes
8 answers

How to parse space-separated floats in C++ quickly?

I have a file with millions of lines, each line has 3 floats separated by spaces. It takes a lot of time to read the file, so I tried to read them using memory mapped files only to find out that the problem is not with the speed of IO but with the…
OopsUser
  • 4,258
  • 6
  • 37
  • 59
34
votes
6 answers

Boolean expression (grammar) parser in c++

I want to parse a boolean expression (in C++). Input form: a and b xor (c and d or a and b); I just want to parse this expression into a tree, knowing the precedence rule (not,and,xor,or). So the above expression should look something like: (a and…
A Gore
  • 1,780
  • 2
  • 14
  • 26
34
votes
5 answers

Getting started guide for Boost.Spirit?

I've been looking recently at Boost.Spirit (the version included in Boost 1.39), however I'm quite confused from the docs alone. What I'm looking for is for an example of a toy language implemented with Boost.Spirit -- something along the lines of a…
Anteru
  • 18,283
  • 10
  • 72
  • 117
28
votes
1 answer

Boost Spirit Qi - Duplicate last letter with stream-based parsing

This may be very obvious, but why does the stream-based parsing in boost duplicate the last letter? I must be doing something wrong: #include #include #include namespace qi =…
kloffy
  • 2,878
  • 1
  • 23
  • 32
26
votes
2 answers

Minimizing boost::spirit compile times

Any ideas for reducing boost::spirit compile time? I have just ported a flex parser to boost::spirit. The EBNF has about 25 rules. The result runs well and the runtime performance is fine. The problem is that compile takes for ever! It takes about…
ravenspoint
  • 15,243
  • 4
  • 52
  • 87
22
votes
1 answer

Is it possible to re-use boost::spirit::qi grammar in another grammar definition?

Is it possible to reuse boost::spirit:qi grammar in another grammar (as a rule for example)? For example if I define a grammar to parse line of text into a structure holding street address. template< typename iter > struct address_grammar…
stefanB
  • 69,149
  • 26
  • 113
  • 140
21
votes
1 answer

Boost Spirit: "Semantic actions are evil"?

Reading and watching this presentation: http://boost-spirit.com/home/2011/06/12/ast-construction-with-the-universal-tree/ I've discovered this statement -- basically we are suggested not to use semantic actions. I must admit, that I've already felt…
Kostya
  • 1,034
  • 10
  • 23
20
votes
3 answers

Can Boost.Spirit be theoretically/practically used to parse C++(0x) (or any other language)?

Is it theoretically up to the task? Can it be done practically and would the resulting parser be used with sufficient performance and output (say, LLVM IR or GCC's gimple) to be integrated in a competing compiler?
rubenvb
  • 69,525
  • 30
  • 173
  • 306
18
votes
1 answer

Custom Skip Parser with Boost::Spirit

The standard ascii::space_type skipper does of course not skip my comments. The docs mention you can make your own skip parser but there is no example of actually how to do it. I'd just need an example code or anything, I've been googling for 2…
Lanbo
  • 13,437
  • 14
  • 67
  • 141
15
votes
1 answer

Dynamically combine Boost.Spirit.Qi rules at runtime (arbitrary number of alternatives)

I was wondering whether there is a way in Boost.Spirit.Qi to dynamically combine an arbitrary number of rules at runtime. The inner workings of Boost.Spirit are still a bit of a mystery to me, but since rules are implemented as objects it seems…
kloffy
  • 2,878
  • 1
  • 23
  • 32
15
votes
1 answer

How to benchmark Boost Spirit Parser?

I'm working on a compiler and I would like to improve its performances. I found that about 50% of the time is spent parsing the source files. As the source file are quite small and I do quite a lot of transformations after that, it seems to me that…
1
2 3
88 89