2020-02-25 23:11:52 +08:00
|
|
|
//===-- lib/Parser/debug-parser.cpp ---------------------------------------===//
|
2018-05-02 03:50:34 +08:00
|
|
|
//
|
2019-12-21 04: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-02 03:50:34 +08:00
|
|
|
//
|
2020-01-11 04:12:03 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-05-02 03:50:34 +08:00
|
|
|
|
2018-04-21 06:56:19 +08:00
|
|
|
#include "debug-parser.h"
|
2020-02-25 23:11:52 +08:00
|
|
|
#include "flang/Parser/user-state.h"
|
2018-04-21 06:56:19 +08:00
|
|
|
#include <string>
|
|
|
|
|
2018-05-03 04:48:12 +08:00
|
|
|
namespace Fortran::parser {
|
2018-04-21 06:56:19 +08:00
|
|
|
|
|
|
|
std::optional<Success> DebugParser::Parse(ParseState &state) const {
|
2018-07-11 08:09:07 +08:00
|
|
|
if (auto ustate{state.userState()}) {
|
|
|
|
if (auto out{ustate->debugOutput()}) {
|
2018-05-03 03:07:49 +08:00
|
|
|
std::string note{str_, length_};
|
2019-05-07 00:33:45 +08:00
|
|
|
Message message{state.GetLocation(), "parser debug: %s"_en_US, note};
|
2018-05-05 06:03:10 +08:00
|
|
|
message.SetContext(state.context().get());
|
2020-09-01 03:22:24 +08:00
|
|
|
message.Emit(*out, ustate->allCooked(), true);
|
2018-04-21 06:56:19 +08:00
|
|
|
}
|
|
|
|
}
|
2020-09-01 03:22:24 +08:00
|
|
|
return Success{};
|
2018-04-21 06:56:19 +08:00
|
|
|
}
|
2020-03-29 12:00:16 +08:00
|
|
|
} // namespace Fortran::parser
|