blob: 1fc6c0e315d6e5caeeff5ab3e3b98da8f73dc685 (
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
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- D I A G N O S T I C S . J S O N _ U T I L S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2024, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT 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 distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package Diagnostics.JSON_Utils is
JSON_FORMATTING : constant Boolean := True;
-- Adds newlines and indentation to the output JSON.
--
-- NOTE: This flag could be associated with the gcc switch:
-- '-fno-diagnostics-json-formatting'
INDENT_SIZE : constant := 2;
-- The number of spaces to indent each level of the JSON output.
Indent_Level : Natural := 0;
-- The current indentation level.
procedure Begin_Block;
-- Increase the indentation level by one
procedure End_Block;
-- Decrease the indentation level by one
procedure Indent;
-- Print the indentation for the line
procedure NL_And_Indent;
-- Print a new line
procedure Write_Int_Attribute (Name : String; Value : Int);
procedure Write_JSON_Escaped_String (Str : String);
-- Write each character of Str, taking care of preceding each quote and
-- backslash with a backslash. Note that this escaping differs from what
-- GCC does.
--
-- Indeed, the JSON specification mandates encoding wide characters
-- either as their direct UTF-8 representation or as their escaped
-- UTF-16 surrogate pairs representation. GCC seems to prefer escaping -
-- we choose to use the UTF-8 representation instead.
procedure Write_String_Attribute (Name : String; Value : String);
-- Write a JSON attribute with a string value
end Diagnostics.JSON_Utils;
|