14 #ifndef PRISM_DIAGNOSTIC_H
15 #define PRISM_DIAGNOSTIC_H
31 PM_ERR_ALIAS_ARGUMENT,
32 PM_ERR_ALIAS_ARGUMENT_NUMBERED_REFERENCE,
33 PM_ERR_AMPAMPEQ_MULTI_ASSIGN,
34 PM_ERR_ARGUMENT_AFTER_BLOCK,
35 PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES,
36 PM_ERR_ARGUMENT_BARE_HASH,
37 PM_ERR_ARGUMENT_BLOCK_FORWARDING,
38 PM_ERR_ARGUMENT_BLOCK_MULTI,
39 PM_ERR_ARGUMENT_CONFLICT_AMPERSAND,
40 PM_ERR_ARGUMENT_CONFLICT_STAR,
41 PM_ERR_ARGUMENT_CONFLICT_STAR_STAR,
42 PM_ERR_ARGUMENT_FORMAL_CLASS,
43 PM_ERR_ARGUMENT_FORMAL_CONSTANT,
44 PM_ERR_ARGUMENT_FORMAL_GLOBAL,
45 PM_ERR_ARGUMENT_FORMAL_IVAR,
46 PM_ERR_ARGUMENT_FORWARDING_UNBOUND,
47 PM_ERR_ARGUMENT_NO_FORWARDING_AMPERSAND,
48 PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES,
49 PM_ERR_ARGUMENT_NO_FORWARDING_STAR,
50 PM_ERR_ARGUMENT_NO_FORWARDING_STAR_STAR,
51 PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT,
52 PM_ERR_ARGUMENT_SPLAT_AFTER_SPLAT,
53 PM_ERR_ARGUMENT_TERM_PAREN,
54 PM_ERR_ARGUMENT_UNEXPECTED_BLOCK,
56 PM_ERR_ARRAY_EXPRESSION,
57 PM_ERR_ARRAY_EXPRESSION_AFTER_STAR,
58 PM_ERR_ARRAY_SEPARATOR,
60 PM_ERR_BEGIN_LONELY_ELSE,
62 PM_ERR_BEGIN_UPCASE_BRACE,
63 PM_ERR_BEGIN_UPCASE_TERM,
64 PM_ERR_BEGIN_UPCASE_TOPLEVEL,
65 PM_ERR_BLOCK_PARAM_LOCAL_VARIABLE,
66 PM_ERR_BLOCK_PARAM_PIPE_TERM,
67 PM_ERR_BLOCK_TERM_BRACE,
68 PM_ERR_BLOCK_TERM_END,
69 PM_ERR_CANNOT_PARSE_EXPRESSION,
70 PM_ERR_CANNOT_PARSE_STRING_PART,
71 PM_ERR_CASE_EXPRESSION_AFTER_CASE,
72 PM_ERR_CASE_EXPRESSION_AFTER_WHEN,
73 PM_ERR_CASE_MATCH_MISSING_PREDICATE,
74 PM_ERR_CASE_MISSING_CONDITIONS,
76 PM_ERR_CLASS_IN_METHOD,
78 PM_ERR_CLASS_SUPERCLASS,
80 PM_ERR_CLASS_UNEXPECTED_END,
81 PM_ERR_CLASS_VARIABLE_BARE,
82 PM_ERR_CONDITIONAL_ELSIF_PREDICATE,
83 PM_ERR_CONDITIONAL_IF_PREDICATE,
84 PM_ERR_CONDITIONAL_PREDICATE_TERM,
85 PM_ERR_CONDITIONAL_TERM,
86 PM_ERR_CONDITIONAL_TERM_ELSE,
87 PM_ERR_CONDITIONAL_UNLESS_PREDICATE,
88 PM_ERR_CONDITIONAL_UNTIL_PREDICATE,
89 PM_ERR_CONDITIONAL_WHILE_PREDICATE,
90 PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT,
92 PM_ERR_DEF_ENDLESS_SETTER,
94 PM_ERR_DEF_PARAMS_TERM,
95 PM_ERR_DEF_PARAMS_TERM_PAREN,
97 PM_ERR_DEF_RECEIVER_TERM,
99 PM_ERR_DEFINED_EXPRESSION,
102 PM_ERR_EMBVAR_INVALID,
103 PM_ERR_END_UPCASE_BRACE,
104 PM_ERR_END_UPCASE_TERM,
105 PM_ERR_ESCAPE_INVALID_CONTROL,
106 PM_ERR_ESCAPE_INVALID_CONTROL_REPEAT,
107 PM_ERR_ESCAPE_INVALID_HEXADECIMAL,
108 PM_ERR_ESCAPE_INVALID_META,
109 PM_ERR_ESCAPE_INVALID_META_REPEAT,
110 PM_ERR_ESCAPE_INVALID_UNICODE,
111 PM_ERR_ESCAPE_INVALID_UNICODE_CM_FLAGS,
112 PM_ERR_ESCAPE_INVALID_UNICODE_LIST,
113 PM_ERR_ESCAPE_INVALID_UNICODE_LITERAL,
114 PM_ERR_ESCAPE_INVALID_UNICODE_LONG,
115 PM_ERR_ESCAPE_INVALID_UNICODE_SHORT,
116 PM_ERR_ESCAPE_INVALID_UNICODE_TERM,
117 PM_ERR_EXPECT_ARGUMENT,
118 PM_ERR_EXPECT_EOL_AFTER_STATEMENT,
119 PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ,
120 PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA,
121 PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL,
122 PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS,
123 PM_ERR_EXPECT_EXPRESSION_AFTER_LPAREN,
124 PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR,
125 PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ,
126 PM_ERR_EXPECT_EXPRESSION_AFTER_QUESTION,
127 PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT,
128 PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH,
129 PM_ERR_EXPECT_EXPRESSION_AFTER_STAR,
130 PM_ERR_EXPECT_FOR_DELIMITER,
131 PM_ERR_EXPECT_IDENT_REQ_PARAMETER,
132 PM_ERR_EXPECT_IN_DELIMITER,
133 PM_ERR_EXPECT_LPAREN_REQ_PARAMETER,
134 PM_ERR_EXPECT_MESSAGE,
135 PM_ERR_EXPECT_RBRACKET,
136 PM_ERR_EXPECT_RPAREN,
137 PM_ERR_EXPECT_RPAREN_AFTER_MULTI,
138 PM_ERR_EXPECT_RPAREN_REQ_PARAMETER,
139 PM_ERR_EXPECT_SINGLETON_CLASS_DELIMITER,
140 PM_ERR_EXPECT_STRING_CONTENT,
141 PM_ERR_EXPECT_WHEN_DELIMITER,
142 PM_ERR_EXPRESSION_BARE_HASH,
143 PM_ERR_EXPRESSION_NOT_WRITABLE,
144 PM_ERR_EXPRESSION_NOT_WRITABLE_ENCODING,
145 PM_ERR_EXPRESSION_NOT_WRITABLE_FALSE,
146 PM_ERR_EXPRESSION_NOT_WRITABLE_FILE,
147 PM_ERR_EXPRESSION_NOT_WRITABLE_LINE,
148 PM_ERR_EXPRESSION_NOT_WRITABLE_NIL,
149 PM_ERR_EXPRESSION_NOT_WRITABLE_NUMBERED,
150 PM_ERR_EXPRESSION_NOT_WRITABLE_SELF,
151 PM_ERR_EXPRESSION_NOT_WRITABLE_TRUE,
153 PM_ERR_FOR_COLLECTION,
157 PM_ERR_GLOBAL_VARIABLE_BARE,
158 PM_ERR_HASH_EXPRESSION_AFTER_LABEL,
163 PM_ERR_HEREDOC_IDENTIFIER,
165 PM_ERR_INCOMPLETE_QUESTION_MARK,
166 PM_ERR_INCOMPLETE_VARIABLE_CLASS,
167 PM_ERR_INCOMPLETE_VARIABLE_CLASS_3_3,
168 PM_ERR_INCOMPLETE_VARIABLE_INSTANCE,
169 PM_ERR_INCOMPLETE_VARIABLE_INSTANCE_3_3,
170 PM_ERR_INSTANCE_VARIABLE_BARE,
171 PM_ERR_INVALID_BLOCK_EXIT,
172 PM_ERR_INVALID_CHARACTER,
173 PM_ERR_INVALID_COMMA,
174 PM_ERR_INVALID_ENCODING_MAGIC_COMMENT,
175 PM_ERR_INVALID_ESCAPE_CHARACTER,
176 PM_ERR_INVALID_FLOAT_EXPONENT,
177 PM_ERR_INVALID_LOCAL_VARIABLE_READ,
178 PM_ERR_INVALID_LOCAL_VARIABLE_WRITE,
179 PM_ERR_INVALID_MULTIBYTE_CHAR,
180 PM_ERR_INVALID_MULTIBYTE_CHARACTER,
181 PM_ERR_INVALID_MULTIBYTE_ESCAPE,
182 PM_ERR_INVALID_NUMBER_BINARY,
183 PM_ERR_INVALID_NUMBER_DECIMAL,
184 PM_ERR_INVALID_NUMBER_FRACTION,
185 PM_ERR_INVALID_NUMBER_HEXADECIMAL,
186 PM_ERR_INVALID_NUMBER_OCTAL,
187 PM_ERR_INVALID_NUMBER_UNDERSCORE_INNER,
188 PM_ERR_INVALID_NUMBER_UNDERSCORE_TRAILING,
189 PM_ERR_INVALID_PERCENT,
190 PM_ERR_INVALID_PERCENT_EOF,
191 PM_ERR_INVALID_PRINTABLE_CHARACTER,
192 PM_ERR_INVALID_RETRY_AFTER_ELSE,
193 PM_ERR_INVALID_RETRY_AFTER_ENSURE,
194 PM_ERR_INVALID_RETRY_WITHOUT_RESCUE,
195 PM_ERR_INVALID_SYMBOL,
196 PM_ERR_INVALID_VARIABLE_GLOBAL,
197 PM_ERR_INVALID_VARIABLE_GLOBAL_3_3,
198 PM_ERR_INVALID_YIELD,
199 PM_ERR_IT_NOT_ALLOWED_NUMBERED,
200 PM_ERR_IT_NOT_ALLOWED_ORDINARY,
202 PM_ERR_LAMBDA_TERM_BRACE,
203 PM_ERR_LAMBDA_TERM_END,
204 PM_ERR_LIST_I_LOWER_ELEMENT,
205 PM_ERR_LIST_I_LOWER_TERM,
206 PM_ERR_LIST_I_UPPER_ELEMENT,
207 PM_ERR_LIST_I_UPPER_TERM,
208 PM_ERR_LIST_W_LOWER_ELEMENT,
209 PM_ERR_LIST_W_LOWER_TERM,
210 PM_ERR_LIST_W_UPPER_ELEMENT,
211 PM_ERR_LIST_W_UPPER_TERM,
212 PM_ERR_MALLOC_FAILED,
213 PM_ERR_MIXED_ENCODING,
214 PM_ERR_MODULE_IN_METHOD,
217 PM_ERR_MULTI_ASSIGN_MULTI_SPLATS,
218 PM_ERR_MULTI_ASSIGN_UNEXPECTED_REST,
219 PM_ERR_NESTING_TOO_DEEP,
220 PM_ERR_NO_LOCAL_VARIABLE,
221 PM_ERR_NON_ASSOCIATIVE_OPERATOR,
222 PM_ERR_NOT_EXPRESSION,
223 PM_ERR_NUMBER_LITERAL_UNDERSCORE,
224 PM_ERR_NUMBERED_PARAMETER_INNER_BLOCK,
225 PM_ERR_NUMBERED_PARAMETER_IT,
226 PM_ERR_NUMBERED_PARAMETER_ORDINARY,
227 PM_ERR_NUMBERED_PARAMETER_OUTER_BLOCK,
228 PM_ERR_OPERATOR_MULTI_ASSIGN,
229 PM_ERR_OPERATOR_WRITE_ARGUMENTS,
230 PM_ERR_OPERATOR_WRITE_BLOCK,
231 PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI,
232 PM_ERR_PARAMETER_BLOCK_MULTI,
233 PM_ERR_PARAMETER_CIRCULAR,
234 PM_ERR_PARAMETER_FORWARDING_AFTER_REST,
235 PM_ERR_PARAMETER_METHOD_NAME,
236 PM_ERR_PARAMETER_NAME_DUPLICATED,
237 PM_ERR_PARAMETER_NO_DEFAULT,
238 PM_ERR_PARAMETER_NO_DEFAULT_KW,
239 PM_ERR_PARAMETER_NUMBERED_RESERVED,
240 PM_ERR_PARAMETER_ORDER,
241 PM_ERR_PARAMETER_SPLAT_MULTI,
242 PM_ERR_PARAMETER_STAR,
243 PM_ERR_PARAMETER_UNEXPECTED_FWD,
244 PM_ERR_PARAMETER_UNEXPECTED_NO_KW,
245 PM_ERR_PARAMETER_WILD_LOOSE_COMMA,
246 PM_ERR_PATTERN_ARRAY_MULTIPLE_RESTS,
247 PM_ERR_PATTERN_CAPTURE_DUPLICATE,
248 PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET,
249 PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA,
250 PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET,
251 PM_ERR_PATTERN_EXPRESSION_AFTER_IN,
252 PM_ERR_PATTERN_EXPRESSION_AFTER_KEY,
253 PM_ERR_PATTERN_EXPRESSION_AFTER_PAREN,
254 PM_ERR_PATTERN_EXPRESSION_AFTER_PIN,
255 PM_ERR_PATTERN_EXPRESSION_AFTER_PIPE,
256 PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE,
257 PM_ERR_PATTERN_EXPRESSION_AFTER_REST,
258 PM_ERR_PATTERN_FIND_MISSING_INNER,
259 PM_ERR_PATTERN_HASH_IMPLICIT,
260 PM_ERR_PATTERN_HASH_KEY,
261 PM_ERR_PATTERN_HASH_KEY_DUPLICATE,
262 PM_ERR_PATTERN_HASH_KEY_INTERPOLATED,
263 PM_ERR_PATTERN_HASH_KEY_LABEL,
264 PM_ERR_PATTERN_HASH_KEY_LOCALS,
265 PM_ERR_PATTERN_IDENT_AFTER_HROCKET,
266 PM_ERR_PATTERN_LABEL_AFTER_COMMA,
268 PM_ERR_PATTERN_TERM_BRACE,
269 PM_ERR_PATTERN_TERM_BRACKET,
270 PM_ERR_PATTERN_TERM_PAREN,
271 PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN,
272 PM_ERR_REGEXP_ENCODING_OPTION_MISMATCH,
273 PM_ERR_REGEXP_INCOMPAT_CHAR_ENCODING,
274 PM_ERR_REGEXP_INVALID_UNICODE_RANGE,
275 PM_ERR_REGEXP_NON_ESCAPED_MBC,
276 PM_ERR_REGEXP_PARSE_ERROR,
278 PM_ERR_REGEXP_UNKNOWN_OPTIONS,
279 PM_ERR_REGEXP_UTF8_CHAR_NON_UTF8_REGEXP,
280 PM_ERR_RESCUE_EXPRESSION,
281 PM_ERR_RESCUE_MODIFIER_VALUE,
283 PM_ERR_RESCUE_VARIABLE,
284 PM_ERR_RETURN_INVALID,
285 PM_ERR_SCRIPT_NOT_FOUND,
286 PM_ERR_SINGLETON_FOR_LITERALS,
287 PM_ERR_STATEMENT_ALIAS,
288 PM_ERR_STATEMENT_POSTEXE_END,
289 PM_ERR_STATEMENT_PREEXE_BEGIN,
290 PM_ERR_STATEMENT_UNDEF,
291 PM_ERR_STRING_CONCATENATION,
292 PM_ERR_STRING_INTERPOLATED_TERM,
293 PM_ERR_STRING_LITERAL_EOF,
294 PM_ERR_STRING_LITERAL_TERM,
295 PM_ERR_SYMBOL_INVALID,
296 PM_ERR_SYMBOL_TERM_DYNAMIC,
297 PM_ERR_SYMBOL_TERM_INTERPOLATED,
298 PM_ERR_TERNARY_COLON,
299 PM_ERR_TERNARY_EXPRESSION_FALSE,
300 PM_ERR_TERNARY_EXPRESSION_TRUE,
301 PM_ERR_UNARY_DISALLOWED,
302 PM_ERR_UNARY_RECEIVER,
303 PM_ERR_UNDEF_ARGUMENT,
304 PM_ERR_UNEXPECTED_BLOCK_ARGUMENT,
305 PM_ERR_UNEXPECTED_INDEX_BLOCK,
306 PM_ERR_UNEXPECTED_INDEX_KEYWORDS,
307 PM_ERR_UNEXPECTED_LABEL,
308 PM_ERR_UNEXPECTED_MULTI_WRITE,
309 PM_ERR_UNEXPECTED_RANGE_OPERATOR,
310 PM_ERR_UNEXPECTED_SAFE_NAVIGATION,
311 PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT,
312 PM_ERR_UNEXPECTED_TOKEN_IGNORE,
314 PM_ERR_VOID_EXPRESSION,
316 PM_ERR_WRITE_TARGET_IN_METHOD,
317 PM_ERR_WRITE_TARGET_READONLY,
318 PM_ERR_WRITE_TARGET_UNEXPECTED,
322 PM_WARN_AMBIGUOUS_BINARY_OPERATOR,
323 PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS,
324 PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS,
325 PM_WARN_AMBIGUOUS_PREFIX_AMPERSAND,
326 PM_WARN_AMBIGUOUS_PREFIX_STAR,
327 PM_WARN_AMBIGUOUS_PREFIX_STAR_STAR,
328 PM_WARN_AMBIGUOUS_SLASH,
329 PM_WARN_COMPARISON_AFTER_COMPARISON,
330 PM_WARN_DOT_DOT_DOT_EOL,
331 PM_WARN_EQUAL_IN_CONDITIONAL,
332 PM_WARN_EQUAL_IN_CONDITIONAL_3_3,
333 PM_WARN_END_IN_METHOD,
334 PM_WARN_DUPLICATED_HASH_KEY,
335 PM_WARN_DUPLICATED_WHEN_CLAUSE,
336 PM_WARN_FLOAT_OUT_OF_RANGE,
337 PM_WARN_IGNORED_FROZEN_STRING_LITERAL,
338 PM_WARN_INDENTATION_MISMATCH,
339 PM_WARN_INTEGER_IN_FLIP_FLOP,
340 PM_WARN_INVALID_CHARACTER,
341 PM_WARN_INVALID_MAGIC_COMMENT_VALUE,
342 PM_WARN_INVALID_NUMBERED_REFERENCE,
344 PM_WARN_LITERAL_IN_CONDITION_DEFAULT,
345 PM_WARN_LITERAL_IN_CONDITION_VERBOSE,
346 PM_WARN_SHAREABLE_CONSTANT_VALUE_LINE,
347 PM_WARN_SHEBANG_CARRIAGE_RETURN,
348 PM_WARN_UNEXPECTED_CARRIAGE_RETURN,
349 PM_WARN_UNREACHABLE_STATEMENT,
350 PM_WARN_UNUSED_LOCAL_VARIABLE,
351 PM_WARN_VOID_STATEMENT,
The abstract syntax tree.
void pm_diagnostic_list_free(pm_list_t *list)
Deallocate the internal state of the given diagnostic list.
bool pm_diagnostic_list_append_format(pm_list_t *list, const uint8_t *start, const uint8_t *end, pm_diagnostic_id_t diag_id,...)
Append a diagnostic to the given list of diagnostics that is using a format string for its message.
pm_diagnostic_id_t
The diagnostic IDs of all of the diagnostics, used to communicate the types of errors between the par...
bool pm_diagnostic_list_append(pm_list_t *list, const uint8_t *start, const uint8_t *end, pm_diagnostic_id_t diag_id)
Append a diagnostic to the given list of diagnostics that is using shared memory for its message.
pm_warning_level_t
The levels of warnings generated during parsing.
@ PM_WARNING_LEVEL_DEFAULT
For warnings which should be emitted if $VERBOSE != nil.
@ PM_WARNING_LEVEL_VERBOSE
For warnings which should be emitted if $VERBOSE == true.
const char * pm_diagnostic_id_human(pm_diagnostic_id_t diag_id)
Get the human-readable name of the given diagnostic ID.
pm_error_level_t
The levels of errors generated during parsing.
@ PM_ERROR_LEVEL_ARGUMENT
For errors that should raise an argument error.
@ PM_ERROR_LEVEL_LOAD
For errors that should raise a load error.
@ PM_ERROR_LEVEL_SYNTAX
For errors that should raise a syntax error.
Macro definitions used throughout the prism library.
This struct represents a diagnostic generated during parsing.
pm_location_t location
The location of the diagnostic in the source.
const char * message
The message associated with the diagnostic.
pm_list_node_t node
The embedded base node.
pm_diagnostic_id_t diag_id
The ID of the diagnostic.
bool owned
Whether or not the memory related to the message of this diagnostic is owned by this diagnostic.
uint8_t level
The level of the diagnostic, see pm_error_level_t and pm_warning_level_t for possible values.
This struct represents an abstract linked list that provides common functionality.
This represents the overall linked list.
This represents a range of bytes in the source string to which a node or token corresponds.