mirror of
https://github.com/boostorg/parser.git
synced 2026-01-19 04:22:13 +00:00
bb183cf5ee0a8e30d53b6a5fdffcdbdc53b3bee7
If the parsed string contains tab characters on the failing line, the underlining in the error message pointed to the wrong position. This patch adds as many tab characters to the underlining as there are in the parsed line. So the underlining points to the correct position.
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 doubles separated by commas,
ignoring whitespace:
#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:
Develop status:
Description
Languages
C++
99%
CMake
0.5%
Python
0.3%