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
0
votes
0 answers

boost spirit parsing GLSL varyings

Boost::spirit seems to contain so much template magic that I can't understand the docs.. I would like to parse GLSL (OpenGL Shader source) and extract in and out attribute names and their types from the source. I'm restricting GL API version to GL…
JATothrim
  • 842
  • 1
  • 8
  • 24
0
votes
1 answer

Spirit Qi: Completely ignoring output of some rules

I'm parsing some input that is vaguely structured like C-ish code. Like this: Name0 { Name1 { //A COMMENT!! Param0 *= 2 Param2 = "lol" } } Part of that is comments, which I want to totally ignore (and it's not working). I consider two…
user173342
  • 1,820
  • 1
  • 19
  • 45
0
votes
2 answers

Boost Spirit code, compilable with msvc, but compilation erros with gcc

Some time ago I wrote spirit parsing code in windows, which just worked fine. Now I am trying to build it on Ubuntu, but c++ (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) fails with some error messages, and I don't have the slightest bit of a…
user1882245
  • 101
  • 1
  • 4
0
votes
2 answers

Parsing a string with optional separator using boost spirit

I'm trying to parse a URL query string with special rules. So far it works with one exclusion described below URL is parsed as set of key-value pairs using following: const qi::rule key =…
kreuzerkrieg
  • 3,009
  • 3
  • 28
  • 59
0
votes
0 answers

No viable conversion error from boost::spirit::unused_type

I'm getting this error: include/boost/spirit/home/phoenix/bind/detail/member_function_ptr.hpp:109:35: No viable conversion from 'boost::spirit::unused_type' to 'const std::__1::basic_string' #define BOOST_SPIRIT_USE_PHOENIX_V3 #define spirit…
statguy
  • 1,627
  • 3
  • 13
  • 22
0
votes
1 answer

json-spirit - adding content to an object in an arry

Background: I want to represent a deep hierarchy using JSON. I.e A Job has nodes, nodes have CPUs, CPUs have device loops and loops have devices. My data is on a database. I am using the visitor pattern to call back VisitJob, VisitNode, VisitCPU as…
BryanT
  • 412
  • 3
  • 12
0
votes
0 answers

Simple boolean expression parser in Spirit

I've come up with following boolean expression parser after reading the Spirit tutorials: expression = bool_ [_val = _1] >> *( ("&&" >> expression [_val && _1]) | ("||" >>…
Boris
  • 8,551
  • 25
  • 67
  • 120
0
votes
1 answer

C++ How does boost spirit parantheses work

In boost spirit there are parantheses which can be used to indicate that a part of grammar is going to be repeated A>>(B>>C)* I want to use this concept to write a generic scenario controller but I have no idea how they implemented that the…
Martin Kosicky
  • 471
  • 4
  • 12
0
votes
1 answer

boost-sprit-lex unifying multiple tokens into a single token in lex differentiated by the id

edit : I have ripped out the lexer as it does not cleanly integrate with Qi and just obfuscates grammars (see answer below). My lexer looks as follows : template struct tokens : lex::lexer { tokens() :…
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
0
votes
1 answer

boost-spirit-lex built in way for giving tokens a string name?

edit : I have ripped out the lexer as it does not cleanly integrate with Qi and just obfuscates grammars (see here). I need to give token types a name that I can use in on_error handler in qi. At the moment the _4 (qi::on_error<..>(...,std::cout <<…
Hassan Syed
  • 20,075
  • 11
  • 87
  • 171
0
votes
1 answer

Boost Spirit.Lex re-lexing altered lines using state from previous line

I'm considering writing some simple lexers with Boost's Spirit.Lex, but I can't seem to find any examples of what I'd like to do. More or less, I'd like to lex an entire text file (this is easy). But, once the entire file has been processed, I would…
CmdrMoozy
  • 3,870
  • 3
  • 19
  • 31
0
votes
0 answers

Delete Node of BOOST Spirit AST Tree

I have a question concerning Abstract Syntax Trees generated with Boost Spirit Library. I've found many informations about deleting nodes and subtrees in a Binary Search Tree, but I cannot find the same information for ASTs. I have a node in an…
user2791904
  • 139
  • 1
  • 9
0
votes
0 answers

how to derive abstract source tree in terms of boost::spririt?

What additional data structures should be organized in order to take the first derivative of an abstract source tree (for string math expression)? Let's say, we have a tree for the string expression, which was built using boost::spirit. I.e each…
Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169
0
votes
0 answers

Boost Spirit: Split Grammar into multiple compile units

So I have successfully used the calculator example to speed a compilation of a relatively simple grammar up by about 50% (?). The calculator example can be found here. However, there was one thing in the example, which I didn't really grasp, namely…
FRob
  • 3,883
  • 2
  • 27
  • 40
0
votes
1 answer

How do i change the grammar from this example to parse "AND ( (OR (a b c)) (NOT (d)))

Boolean expression (grammar) parser in c++ I'm trying to modify the grammar from the above example provided by "sehe" to parse the following expression. "AND ( (OR (a b c)) (NOT (d)))". There are three operators AND/OR/NOT, NOT is unary but AND…