brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 266b78d Raw
36 lines · c
1//===-- lib/Parser/type-parser-implementation.h -----------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// Macros for implementing per-type parsers10 11#ifndef FORTRAN_PARSER_TYPE_PARSER_IMPLEMENTATION_H_12#define FORTRAN_PARSER_TYPE_PARSER_IMPLEMENTATION_H_13 14#include "type-parsers.h"15 16#undef TYPE_PARSER17#undef TYPE_CONTEXT_PARSER18 19// The result type of a parser combinator expression is determined20// here via "decltype(attempt(pexpr))" to work around a g++ bug that21// causes it to crash on "decltype(pexpr)" when pexpr's top-level22// operator is an overridden || of parsing alternatives.23#define TYPE_PARSER(pexpr) \24  template <> \25  auto Parser<typename decltype(attempt(pexpr))::resultType>::Parse( \26      ParseState &state) \27      ->std::optional<resultType> { \28    static constexpr auto parser{(pexpr)}; \29    return parser.Parse(state); \30  }31 32#define TYPE_CONTEXT_PARSER(contextText, pexpr) \33  TYPE_PARSER(CONTEXT_PARSER((contextText), (pexpr)))34 35#endif36