2020-02-25 15:11:52 +00:00
|
|
|
//===-- lib/Parser/debug-parser.cpp ---------------------------------------===//
|
2018-05-01 12:50:34 -07:00
|
|
|
//
|
2019-12-20 12:52:07 -08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-05-01 12:50:34 -07:00
|
|
|
//
|
2020-01-10 12:12:03 -08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-05-01 12:50:34 -07:00
|
|
|
|
2018-04-20 15:56:19 -07:00
|
|
|
#include "debug-parser.h"
|
2020-02-25 15:11:52 +00:00
|
|
|
#include "flang/Parser/user-state.h"
|
2018-04-20 15:56:19 -07:00
|
|
|
#include <string>
|
|
|
|
|
|
2018-05-02 13:48:12 -07:00
|
|
|
namespace Fortran::parser {
|
2018-04-20 15:56:19 -07:00
|
|
|
|
|
|
|
|
std::optional<Success> DebugParser::Parse(ParseState &state) const {
|
2018-07-10 17:09:07 -07:00
|
|
|
if (auto ustate{state.userState()}) {
|
|
|
|
|
if (auto out{ustate->debugOutput()}) {
|
2018-05-02 12:07:49 -07:00
|
|
|
std::string note{str_, length_};
|
2019-05-06 09:33:45 -07:00
|
|
|
Message message{state.GetLocation(), "parser debug: %s"_en_US, note};
|
2018-05-04 15:03:10 -07:00
|
|
|
message.SetContext(state.context().get());
|
2020-08-31 12:22:24 -07:00
|
|
|
message.Emit(*out, ustate->allCooked(), true);
|
2018-04-20 15:56:19 -07:00
|
|
|
}
|
|
|
|
|
}
|
2020-08-31 12:22:24 -07:00
|
|
|
return Success{};
|
2018-04-20 15:56:19 -07:00
|
|
|
}
|
2020-03-28 21:00:16 -07:00
|
|
|
} // namespace Fortran::parser
|