//===- lib/DebugInfo/Symbolize/Markup.cpp ------------------------------===// // // 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 // //===----------------------------------------------------------------------===// /// /// \file /// This file defines the log symbolizer markup data model and parser. /// //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/Symbolize/Markup.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" namespace llvm { namespace symbolize { // Matches the following: // "\033[0m" // "\033[1m" // "\033[30m" -- "\033[37m" static const char SGRSyntaxStr[] = …; MarkupParser::MarkupParser(StringSet<> MultilineTags) : … { … } static StringRef takeTo(StringRef Str, StringRef::iterator Pos) { … } static void advanceTo(StringRef &Str, StringRef::iterator Pos) { … } void MarkupParser::parseLine(StringRef Line) { … } std::optional<MarkupNode> MarkupParser::nextNode() { … } void MarkupParser::flush() { … } // Finds and returns the next valid markup element in the given line. Returns // std::nullopt if the line contains no valid elements. std::optional<MarkupNode> MarkupParser::parseElement(StringRef Line) { … } static MarkupNode textNode(StringRef Text) { … } // Parses a region of text known to be outside any markup elements. Such text // may still contain SGR control codes, so the region is further subdivided into // control codes and true text regions. void MarkupParser::parseTextOutsideMarkup(StringRef Text) { … } // Given that a line doesn't contain any valid markup, see if it ends with the // start of a multi-line element. If so, returns the beginning. std::optional<StringRef> MarkupParser::parseMultiLineBegin(StringRef Line) { … } // See if the line begins with the ending of an in-progress multi-line element. // If so, return the ending. std::optional<StringRef> MarkupParser::parseMultiLineEnd(StringRef Line) { … } } // end namespace symbolize } // end namespace llvm