This repository was archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdiagnostic.h
More file actions
65 lines (54 loc) · 1.88 KB
/
diagnostic.h
File metadata and controls
65 lines (54 loc) · 1.88 KB
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
#ifndef LIB_RUBY_PARSER_DIAGNOSTIC_H
#define LIB_RUBY_PARSER_DIAGNOSTIC_H
#include <stddef.h>
#include "messages.h"
#include "loc.h"
#include "decoded_input.h"
/// @defgroup diagnostic Diagnostic
/// @brief A set of structs and functions to work with diagnostics
/// @{
/// @}
/// Equivalent of `lib_ruby_parser::ErrorLevel`
/// @ingroup diagnostic
typedef enum
{
LIB_RUBY_PARSER_ERROR_LEVEL_WARNING,
LIB_RUBY_PARSER_ERROR_LEVEL_ERROR
} LIB_RUBY_PARSER_ErrorLevel;
/// Equivalent of `lib_ruby_parser::Diagnostic`
/// @ingroup diagnostic
typedef struct
{
/// Level of the diagnostic (error/warning)
LIB_RUBY_PARSER_ErrorLevel level;
/// Message of the diagnsotic
LIB_RUBY_PARSER_DiagnosticMessage message;
/// Location of the diagnostic
LIB_RUBY_PARSER_Loc loc;
} LIB_RUBY_PARSER_Diagnostic;
/// Render given diagnsostic on a given source input.
/// Equivalent of lib_ruby_parser::Diagnostic::render.
/// Return owned NULL-terminated string.
/// @ingroup diagnostic
char *LIB_RUBY_PARSER_render_diagnostic(
const LIB_RUBY_PARSER_Diagnostic *diagnostic,
const LIB_RUBY_PARSER_DecodedInput *input);
/// Diagnostic destructor.
/// Just like Rust/C++ destructor it performs cleanup of "embedded" resources.
/// i.e. it doesn't call `free` on a given pointer.
/// @ingroup diagnostic
void LIB_RUBY_PARSER_drop_diagnostic(LIB_RUBY_PARSER_Diagnostic *diagnostic);
/// Equivalent of `Vec<lib_ruby_parser::Diagnostic`
/// @ingroup diagnostic
typedef struct
{
size_t capacity;
LIB_RUBY_PARSER_Diagnostic *ptr;
size_t len;
} LIB_RUBY_PARSER_DiagnosticList;
/// DiagnosticList destructor.
/// Just like Rust/C++ destructor it performs cleanup of "embedded" resources.
/// i.e. it doesn't call `free` on a given pointer.
/// @ingroup diagnostic
void LIB_RUBY_PARSER_drop_diagnostic_list(LIB_RUBY_PARSER_DiagnosticList *diagnostic_list);
#endif // LIB_RUBY_PARSER_DIAGNOSTIC_H