1 //===-- lib/Parser/debug-parser.cpp ---------------------------------------===//
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 #include "debug-parser.h"
10 #include "flang/Parser/user-state.h"
13 namespace Fortran::parser
{
15 std::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);
26 } // namespace Fortran::parser