blob: 8e6897ce25ff08e4c97a81e0ff9ee1b6a6017d03 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/* Copyright (C) 2024 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_PRETTY_PRINT_MARKUP_H
#define GCC_PRETTY_PRINT_MARKUP_H
#include "diagnostic-color.h"
class pp_token_list;
namespace pp_markup {
class context
{
public:
context (pretty_printer &pp,
bool "ed,
pp_token_list *formatted_token_list)
: m_pp (pp),
m_buf (*pp_buffer (&pp)),
m_quoted (quoted),
m_formatted_token_list (formatted_token_list)
{
}
void begin_quote ();
void end_quote ();
void begin_highlight_color (const char *color_name);
void end_highlight_color ();
void push_back_any_text ();
pretty_printer &m_pp;
output_buffer &m_buf;
bool &m_quoted;
pp_token_list *m_formatted_token_list;
};
/* Abstract base class for use in pp_format for handling "%e".
This can add arbitrary content to the buffer being constructed, and
isolates the non-typesafe part of the formatting call in one place. */
class element
{
public:
virtual ~element () {}
virtual void add_to_phase_2 (context &ctxt) = 0;
protected:
element () {}
private:
DISABLE_COPY_AND_ASSIGN (element);
};
/* Concrete subclass: handle "%e" by printing a comma-separated list
of quoted strings. */
class comma_separated_quoted_strings : public element
{
public:
comma_separated_quoted_strings (const auto_vec<const char *> &strings)
: m_strings (strings)
{
}
void add_to_phase_2 (context &ctxt) final override;
private:
const auto_vec<const char *> &m_strings;
};
} // namespace pp_markup
#endif /* GCC_PRETTY_PRINT_MARKUP_H */
|