Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / lib / Parser / type-parser-implementation.h
blob266b78dc2f1e82c1efdd966e3a30057f9346036e
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // Macros for implementing per-type parsers
11 #ifndef FORTRAN_PARSER_TYPE_PARSER_IMPLEMENTATION_H_
12 #define FORTRAN_PARSER_TYPE_PARSER_IMPLEMENTATION_H_
14 #include "type-parsers.h"
16 #undef TYPE_PARSER
17 #undef TYPE_CONTEXT_PARSER
19 // The result type of a parser combinator expression is determined
20 // here via "decltype(attempt(pexpr))" to work around a g++ bug that
21 // causes it to crash on "decltype(pexpr)" when pexpr's top-level
22 // 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); \
32 #define TYPE_CONTEXT_PARSER(contextText, pexpr) \
33 TYPE_PARSER(CONTEXT_PARSER((contextText), (pexpr)))
35 #endif