1//===-- lib/Parser/debug-parser.cpp ---------------------------------------===//
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//===----------------------------------------------------------------------===//
8
9#include "debug-parser.h"
10#include "flang/Parser/user-state.h"
11#include <string>
12
13namespace Fortran::parser {
14
15std::optional<Success> DebugParser::Parse(ParseState &state) const {
16 if (auto ustate{state.userState()}) {
17 if (auto out{ustate->debugOutput()}) {
18 std::string note{str_, length_};
19 Message message{state.GetLocation(), "parser debug: %s"_en_US, note};
20 message.SetContext(state.context().get());
21 message.Emit(*out, ustate->allCooked(), true);
22 }
23 }
24 return Success{};
25}
26} // namespace Fortran::parser
27

source code of flang/lib/Parser/debug-parser.cpp