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