1 //===-- lib/Parser/debug-parser.h -------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef FORTRAN_PARSER_DEBUG_PARSER_H_
10 #define FORTRAN_PARSER_DEBUG_PARSER_H_
12 // Implements the parser with syntax "(YOUR MESSAGE HERE)"_debug for use
13 // in temporary modifications to the grammar intended for tracing the
14 // flow of the parsers. Not to be used in production.
16 #include "basic-parsers.h"
17 #include "flang/Parser/parse-state.h"
21 namespace Fortran::parser
{
25 using resultType
= Success
;
26 constexpr DebugParser(const DebugParser
&) = default;
27 constexpr DebugParser(const char *str
, std::size_t n
)
28 : str_
{str
}, length_
{n
} {}
29 std::optional
<Success
> Parse(ParseState
&) const;
32 const char *const str_
;
33 const std::size_t length_
;
36 constexpr DebugParser
operator""_debug(const char str
[], std::size_t n
) {
37 return DebugParser
{str
, n
};
39 } // namespace Fortran::parser
40 #endif // FORTRAN_PARSER_DEBUG_PARSER_H_