2
0
mirror of https://github.com/boostorg/parser.git synced 2026-01-19 04:22:13 +00:00
Andreas Buhr bfa3e33372 Reduce compilation time by using SkipParser when determining attribute type.
When using a large parser, the whole tree of parsers in instantiated with the
skip (whitespace) parser used. Then, it was instantiated again without a skip
parser, just to determine the attribute type.
This patch changes the code so the attribute type is determined *with* the
skip parser. That way, the number of template instantiations
required are halved for some use cases.

With gcc 14.2, the instantiations without the skip parser even ended up in the
binary. In that case, this patch reduces binary size.
This is most likely a compiler bug, as the usage is in decltype().
2025-10-12 21:31:32 -05:00
2024-03-25 20:19:30 -05:00
2025-10-12 21:04:26 -05:00
2025-10-12 21:00:47 -05:00
2019-10-27 15:36:41 -05:00
2024-11-27 20:10:11 -06:00
2024-12-20 20:02:44 -06:00

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:

Ubuntu

Fedora

Windows MSVC

macos-13 - Clang 14

Develop status:

Ubuntu

Fedora

Windows MSVC

macos-13 - Clang 14

License

Description
Mirrored via gitea-mirror
Readme 13 MiB
Languages
C++ 99%
CMake 0.5%
Python 0.3%