2
0
mirror of https://github.com/boostorg/parser.git synced 2026-01-26 18:52:23 +00:00
Zach Laine c02d68ff45 Introduce BOOST_PARSER_CONSTEXPR, which is defined to be constexpr, except on
MSVC before VS2022.  This works around a bug in constexpr in VS2017.
2023-12-01 22:34:09 -06:00
2022-07-23 13:41:48 -05:00
2023-11-25 17:25:18 -06:00
2019-10-27 15:36:41 -05:00
2020-09-20 18:32:24 -05:00
2020-09-10 01:13:05 -05: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";
    }
}

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 targets submission to Boost.

Online docs: https://tzlaine.github.io/parser

Build Status Build Status License

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