Questions tagged [boost-spirit-qi]

a practical, scalable parsing library for C++

Spirit.Qi is designed to be a practical parsing tool. The ability to generate a fully-working parser from a formal EBNF specification inlined in C++ significantly reduces development time.

Programmers typically approach parsing using ad hoc hacks with primitive tools such as scanf. Even regular-expression libraries (such as boost regex) or scanners (such as boost tokenizer) do not scale well when we need to write more elaborate parsers. Attempting to write even a moderately-complex parser using these tools leads to code that is hard to understand and maintain.

One prime objective is to make the tool easy to use. When one thinks of a parser generator, the usual reaction is “it must be big and complex with a steep learning curve.” Not so. Spirit is designed to be fully scalable. The library is structured in layers. This permits learning on an as-needed basis, after only learning the minimal core and basic concepts.

For development simplicity and ease in deployment, the entire library consists of only header files, with no libraries to link against or build. Just put the Spirit distribution in your include path, compile and run. Code size is very tight, essentially comparable to hand-written recursive descent code.

Have fun!

Further Reading

687 questions
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

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
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
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
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…
0
votes
1 answer

boost::spirit and grammars

I'm trying to parse this simply and consise xml-minded structure with Boost::Spirit, One{ Two{ Three{ } } } And the code is organized as follows: Struct definition to keep the spirit-stuff: struct config; typedef…
Tomaz Canabrava
  • 2,320
  • 15
  • 20
0
votes
1 answer

use Boost.Spirit.Qi to parse into vector

I am quite new to Spirit. I am trying to use Qi to parse the argument for a CMD command in my embedded Tcl interpreter. As some arguments may used multiple times, I will need a vector to store all arguments of the same sort. This is a simplified…
Wei Song
  • 545
  • 3
  • 11
0
votes
1 answer

Boost.Spirit semantic action to parse a string does not work

I try to write a Boost.Spirit parser that parses a string that should represent a simple command like "print foo.txt". Each time the input fulfills the grammar a semantic action should be called. Here is the code: template struct…
Franz
  • 93
  • 6
-1
votes
1 answer

Mixed usage of the sequence parser and the expectation parser

> qi::double_ v.s. >> qi::double_ I want to parse the following string "***: @a_-091 , *** 1" to a struct defined as using type = boost::fusion::vector; When the parser *qi::omit[qi::char_ - '@'] >> '@' >>…
cqdjyy01234
  • 1,180
  • 10
  • 20
-2
votes
1 answer

Boost Spirit Qi - C++ Grammar for string parsing

C++ Spirit Experts, I am looking for generic parser for the below use case. Any help will be greatly appreciated KEY = alphanumeric value Value = alphanumeric value Array of values alphanumeric separated by () List of Array – 2D ex: Key1…
-4
votes
1 answer

Boost::Spirit. Parse string excluding substrings

How to parse a string using boost::spirit excluding defined substrings? For example, a string must not contain $lf, $pt, $kf
alexander.sivak
  • 4,352
  • 3
  • 18
  • 27
1 2 3
45
46