1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
# parser
This is a parser combinator library for C++. As a quick example of use, here
is a complete program that parses one or more `double`s separated by commas,
ignoring whitespace:
```c++
#include <boost/parser/parser.hpp>
#include <iostream>
#include <string>
namespace bp = boost::parser;
int main()
{
std::cout << "Enter a list of doubles, separated by commas. No pressure. ";
std::string input;
std::getline(std::cin, input);
auto const result = bp::parse(
input, bp::double_ >> *(',' >> bp::double_), bp::ws);
if (result) {
std::cout << "Great! It looks like you entered:\n";
for (double x : *result) {
std::cout << x << "\n";
}
} else {
std::cout
<< "Good job! Please proceed to the recovery annex for cake.\n";
}
}
```
This library is header-only, and has no Boost dependencies by default.
Features:
- Parsers that parse a variety of things.
- Combining operations that make complex parsers out of simpler ones.
- Multiple ways of getting data out of the parse, including via callbacks.
- Sentinel- and range-friendly.
- Very Unicode friendliness.
- Excellent error reporting, via diagnostics like those produced by GCC and Clang.
- Trace support for debugging your parsers.
- Clever hacks to make compile time errors easier to deal with. (These are totally optional.)
This library first appeared in Boost 1.87.0
Master status:
[](https://github.com/tzlaine/parser/actions/workflows/ubuntu.yml)
[](https://github.com/tzlaine/parser/actions/workflows/fedora.yml)
[](https://github.com/tzlaine/parser/actions/workflows/windows.yml)
[](https://github.com/tzlaine/parser/actions/workflows/macos-13.yml)
Develop status:
[](https://github.com/tzlaine/parser/actions/workflows/ubuntu.yml)
[](https://github.com/tzlaine/parser/actions/workflows/fedora.yml)
[](https://github.com/tzlaine/parser/actions/workflows/windows.yml)
[](https://github.com/tzlaine/parser/actions/workflows/macos-13.yml)
[](LICENSE_1_0.txt)
|