prism 1.9.0 → 2.0.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +88 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/LICENSE.md +1 -1
- data/Makefile +41 -12
- data/README.md +35 -97
- data/config.yml +174 -161
- data/docs/build_system.md +2 -2
- data/docs/configuration.md +5 -4
- data/docs/encoding.md +2 -2
- data/docs/fuzzing.md +4 -11
- data/docs/javascript.md +19 -4
- data/docs/mapping.md +1 -1
- data/docs/releasing.md +77 -5
- data/docs/relocation.md +2 -4
- data/docs/serialization.md +22 -24
- data/docs/testing.md +46 -29
- data/ext/prism/api_node.c +1461 -1401
- data/ext/prism/extconf.rb +3 -4
- data/ext/prism/extension.c +796 -422
- data/ext/prism/extension.h +3 -3
- data/include/prism/arena.h +37 -0
- data/include/prism/ast.h +2727 -610
- data/include/prism/buffer.h +52 -0
- data/include/prism/comments.h +55 -0
- data/include/prism/compiler/accel.h +26 -0
- data/include/prism/compiler/align.h +36 -0
- data/include/prism/compiler/assume.h +25 -0
- data/include/prism/compiler/bswap.h +46 -0
- data/include/prism/compiler/endianness.h +34 -0
- data/include/prism/compiler/exported.h +24 -0
- data/include/prism/compiler/fallthrough.h +22 -0
- data/include/prism/compiler/filesystem.h +32 -0
- data/include/prism/compiler/flex_array.h +19 -0
- data/include/prism/compiler/force_inline.h +21 -0
- data/include/prism/compiler/format.h +25 -0
- data/include/prism/compiler/inline.h +17 -0
- data/include/prism/compiler/nodiscard.h +22 -0
- data/include/prism/compiler/nonnull.h +18 -0
- data/include/prism/compiler/unused.h +18 -0
- data/include/prism/constant_pool.h +81 -0
- data/include/prism/diagnostic.h +38 -403
- data/include/prism/errors_format.h +53 -0
- data/include/prism/excludes.h +29 -0
- data/include/prism/integer.h +41 -0
- data/include/prism/internal/allocator.h +68 -0
- data/include/prism/internal/allocator_debug.h +88 -0
- data/include/prism/internal/arena.h +108 -0
- data/include/prism/internal/bit.h +42 -0
- data/include/prism/internal/buffer.h +94 -0
- data/include/prism/internal/char.h +145 -0
- data/include/prism/internal/comments.h +53 -0
- data/include/prism/internal/constant_pool.h +152 -0
- data/include/prism/internal/diagnostic.h +389 -0
- data/include/prism/{encoding.h → internal/encoding.h} +27 -68
- data/include/prism/internal/integer.h +68 -0
- data/include/prism/internal/isinf.h +16 -0
- data/include/prism/internal/line_offset_list.h +34 -0
- data/include/prism/{util/pm_list.h → internal/list.h} +11 -52
- data/include/prism/internal/magic_comments.h +23 -0
- data/include/prism/internal/memchr.h +15 -0
- data/include/prism/internal/node.h +38 -0
- data/include/prism/internal/options.h +232 -0
- data/include/prism/internal/parser.h +1004 -0
- data/include/prism/internal/regexp.h +26 -0
- data/include/prism/internal/serialize.h +39 -0
- data/include/prism/internal/source.h +72 -0
- data/include/prism/{static_literals.h → internal/static_literals.h} +26 -47
- data/include/prism/internal/stringy.h +35 -0
- data/include/prism/{util/pm_strncasecmp.h → internal/strncasecmp.h} +3 -17
- data/include/prism/{util/pm_strpbrk.h → internal/strpbrk.h} +7 -20
- data/include/prism/internal/tokens.h +11 -0
- data/include/prism/internal/xxh3.h +16 -0
- data/include/prism/json.h +32 -0
- data/include/prism/line_offset_list.h +61 -0
- data/include/prism/magic_comments.h +35 -0
- data/include/prism/node.h +18 -53
- data/include/prism/options.h +146 -280
- data/include/prism/parser.h +356 -867
- data/include/prism/prettyprint.h +6 -9
- data/include/prism/serialize.h +115 -0
- data/include/prism/source.h +155 -0
- data/include/prism/stream.h +28 -0
- data/include/prism/string_query.h +74 -0
- data/include/prism/stringy.h +72 -0
- data/include/prism/version.h +12 -3
- data/include/prism.h +43 -320
- data/lib/prism/compiler.rb +319 -305
- data/lib/prism/desugar_compiler.rb +105 -34
- data/lib/prism/dispatcher.rb +646 -473
- data/lib/prism/dot_visitor.rb +592 -511
- data/lib/prism/dsl.rb +391 -25
- data/lib/prism/ffi.rb +258 -90
- data/lib/prism/inspect_visitor.rb +357 -325
- data/lib/prism/lex_compat.rb +254 -212
- data/lib/prism/mutation_compiler.rb +313 -305
- data/lib/prism/node.rb +20966 -6992
- data/lib/prism/node_ext.rb +180 -187
- data/lib/prism/node_find.rb +215 -0
- data/lib/prism/parse_result/errors.rb +7 -1
- data/lib/prism/parse_result/newlines.rb +276 -8
- data/lib/prism/parse_result.rb +468 -139
- data/lib/prism/pattern.rb +65 -20
- data/lib/prism/reflection.rb +23 -12
- data/lib/prism/relocation.rb +149 -87
- data/lib/prism/serialize.rb +3460 -539
- data/lib/prism/string_query.rb +24 -1
- data/lib/prism/translation/parser/builder.rb +10 -2
- data/lib/prism/translation/parser/compiler.rb +44 -52
- data/lib/prism/translation/parser/lexer.rb +41 -92
- data/lib/prism/translation/parser.rb +1 -1
- data/lib/prism/translation/parser_current.rb +1 -1
- data/lib/prism/translation/ripper/lexer.rb +8 -10
- data/lib/prism/translation/ripper/sexp.rb +2 -10
- data/lib/prism/translation/ripper/shim.rb +2 -0
- data/lib/prism/translation/ripper.rb +967 -209
- data/lib/prism/translation/ruby_parser.rb +73 -316
- data/lib/prism/translation.rb +2 -0
- data/lib/prism/visitor.rb +632 -5
- data/lib/prism.rb +79 -9
- data/prism.gemspec +128 -62
- data/rbi/generated/prism/compiler.rbi +489 -0
- data/rbi/generated/prism/desugar_compiler.rbi +306 -0
- data/rbi/generated/prism/dispatcher.rbi +1138 -0
- data/rbi/generated/prism/dot_visitor.rbi +618 -0
- data/rbi/generated/prism/dsl.rbi +751 -0
- data/rbi/generated/prism/inspect_visitor.rbi +503 -0
- data/rbi/generated/prism/lex_compat.rbi +162 -0
- data/rbi/generated/prism/mutation_compiler.rbi +464 -0
- data/rbi/generated/prism/node.rbi +14407 -0
- data/rbi/generated/prism/node_ext.rbi +259 -0
- data/rbi/generated/prism/node_find.rbi +79 -0
- data/rbi/generated/prism/parse_result/errors.rbi +21 -0
- data/rbi/generated/prism/parse_result/newlines.rbi +208 -0
- data/rbi/generated/prism/parse_result.rbi +776 -0
- data/rbi/generated/prism/pattern.rbi +134 -0
- data/rbi/generated/prism/reflection.rbi +89 -0
- data/rbi/generated/prism/relocation.rbi +329 -0
- data/rbi/generated/prism/serialize.rbi +184 -0
- data/rbi/generated/prism/string_query.rbi +43 -0
- data/rbi/generated/prism/translation.rbi +7 -0
- data/rbi/generated/prism/visitor.rbi +650 -0
- data/rbi/generated/prism.rbi +86 -0
- data/rbi/prism/translation/parser_versions.rbi +5 -0
- data/rbi/rubyvm/node_find.rbi +14 -0
- data/sig/generated/prism/compiler.rbs +492 -0
- data/sig/generated/prism/desugar_compiler.rbs +305 -0
- data/sig/generated/prism/dispatcher.rbs +1292 -0
- data/sig/generated/prism/dot_visitor.rbs +635 -0
- data/sig/generated/prism/dsl.rbs +928 -0
- data/sig/generated/prism/inspect_visitor.rbs +509 -0
- data/sig/generated/prism/lex_compat.rbs +166 -0
- data/sig/{prism → generated/prism}/mutation_compiler.rbs +309 -4
- data/sig/generated/prism/node.rbs +20896 -0
- data/sig/generated/prism/node_ext.rbs +290 -0
- data/sig/generated/prism/node_find.rbs +90 -0
- data/sig/generated/prism/parse_result/errors.rbs +22 -0
- data/sig/generated/prism/parse_result/newlines.rbs +223 -0
- data/sig/generated/prism/parse_result.rbs +871 -0
- data/sig/generated/prism/pattern.rbs +156 -0
- data/sig/generated/prism/reflection.rbs +101 -0
- data/sig/generated/prism/relocation.rbs +428 -0
- data/sig/generated/prism/serialize.rbs +198 -0
- data/sig/generated/prism/string_query.rbs +43 -0
- data/sig/generated/prism/translation.rbs +8 -0
- data/sig/generated/prism/visitor.rbs +1111 -0
- data/sig/generated/prism.rbs +84 -0
- data/sig/manifest.yaml +2 -0
- data/src/arena.c +117 -0
- data/src/{util/pm_buffer.c → buffer.c} +53 -21
- data/src/{util/pm_char.c → char.c} +28 -57
- data/src/comments.c +454 -0
- data/src/constant_pool.c +406 -0
- data/src/diagnostic.c +97 -65
- data/src/encoding.c +8 -3
- data/src/errors_format.c +519 -0
- data/src/{util/pm_integer.c → integer.c} +33 -22
- data/src/json.c +5733 -0
- data/src/line_offset_list.c +100 -0
- data/src/list.c +24 -0
- data/src/{util/pm_memchr.c → memchr.c} +8 -6
- data/src/node.c +3504 -7674
- data/src/options.c +162 -49
- data/src/parser.c +367 -0
- data/src/prettyprint.c +421 -354
- data/src/prism.c +8402 -7161
- data/src/regexp.c +961 -45
- data/src/serialize.c +460 -424
- data/src/source.c +518 -0
- data/src/static_literals.c +111 -43
- data/src/string_query.c +180 -0
- data/src/stringy.c +91 -0
- data/src/{util/pm_strncasecmp.c → strncasecmp.c} +5 -4
- data/src/strpbrk.c +447 -0
- data/src/{token_type.c → tokens.c} +39 -18
- data/src/xxh3.c +292 -0
- metadata +128 -63
- data/ext/prism/api_pack.c +0 -276
- data/include/prism/defines.h +0 -260
- data/include/prism/pack.h +0 -163
- data/include/prism/regexp.h +0 -43
- data/include/prism/util/pm_buffer.h +0 -236
- data/include/prism/util/pm_char.h +0 -204
- data/include/prism/util/pm_constant_pool.h +0 -218
- data/include/prism/util/pm_integer.h +0 -130
- data/include/prism/util/pm_memchr.h +0 -29
- data/include/prism/util/pm_newline_list.h +0 -113
- data/include/prism/util/pm_string.h +0 -200
- data/lib/prism/pack.rb +0 -230
- data/lib/prism/parse_result/comments.rb +0 -188
- data/rbi/prism/compiler.rbi +0 -12
- data/rbi/prism/dsl.rbi +0 -524
- data/rbi/prism/inspect_visitor.rbi +0 -12
- data/rbi/prism/node.rbi +0 -8750
- data/rbi/prism/node_ext.rbi +0 -107
- data/rbi/prism/parse_result.rbi +0 -404
- data/rbi/prism/reflection.rbi +0 -58
- data/rbi/prism/string_query.rbi +0 -12
- data/rbi/prism/visitor.rbi +0 -473
- data/rbi/prism.rbi +0 -63
- data/sig/prism/compiler.rbs +0 -9
- data/sig/prism/dispatcher.rbs +0 -19
- data/sig/prism/dot_visitor.rbs +0 -6
- data/sig/prism/dsl.rbs +0 -351
- data/sig/prism/inspect_visitor.rbs +0 -22
- data/sig/prism/lex_compat.rbs +0 -10
- data/sig/prism/node.rbs +0 -4042
- data/sig/prism/node_ext.rbs +0 -149
- data/sig/prism/pack.rbs +0 -43
- data/sig/prism/parse_result/comments.rbs +0 -38
- data/sig/prism/parse_result.rbs +0 -197
- data/sig/prism/pattern.rbs +0 -13
- data/sig/prism/reflection.rbs +0 -50
- data/sig/prism/relocation.rbs +0 -185
- data/sig/prism/serialize.rbs +0 -8
- data/sig/prism/string_query.rbs +0 -11
- data/sig/prism/visitor.rbs +0 -169
- data/sig/prism.rbs +0 -272
- data/src/pack.c +0 -509
- data/src/util/pm_constant_pool.c +0 -342
- data/src/util/pm_list.c +0 -49
- data/src/util/pm_newline_list.c +0 -125
- data/src/util/pm_string.c +0 -381
- data/src/util/pm_strpbrk.c +0 -206
data/include/prism/diagnostic.h
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/* :markup: markdown */
|
|
2
|
-
|
|
3
|
-
/*----------------------------------------------------------------------------*/
|
|
4
|
-
/* This file is generated by the templates/template.rb script and should not */
|
|
5
|
-
/* be modified manually. See */
|
|
6
|
-
/* templates/include/prism/diagnostic.h.erb */
|
|
7
|
-
/* if you are looking to modify the */
|
|
8
|
-
/* template */
|
|
9
|
-
/*----------------------------------------------------------------------------*/
|
|
10
|
-
|
|
11
1
|
/**
|
|
12
2
|
* @file diagnostic.h
|
|
13
3
|
*
|
|
@@ -16,379 +6,16 @@
|
|
|
16
6
|
#ifndef PRISM_DIAGNOSTIC_H
|
|
17
7
|
#define PRISM_DIAGNOSTIC_H
|
|
18
8
|
|
|
19
|
-
#include "prism/
|
|
20
|
-
#include "prism/
|
|
21
|
-
#include "prism/
|
|
9
|
+
#include "prism/compiler/exported.h"
|
|
10
|
+
#include "prism/compiler/nodiscard.h"
|
|
11
|
+
#include "prism/compiler/nonnull.h"
|
|
22
12
|
|
|
23
|
-
#include
|
|
24
|
-
#include <stdlib.h>
|
|
25
|
-
#include <assert.h>
|
|
13
|
+
#include "prism/ast.h"
|
|
26
14
|
|
|
27
15
|
/**
|
|
28
|
-
*
|
|
29
|
-
* of errors between the parser and the user.
|
|
16
|
+
* An opaque pointer to a diagnostic generated during parsing.
|
|
30
17
|
*/
|
|
31
|
-
typedef
|
|
32
|
-
// These are the error diagnostics.
|
|
33
|
-
PM_ERR_ALIAS_ARGUMENT,
|
|
34
|
-
PM_ERR_ALIAS_ARGUMENT_NUMBERED_REFERENCE,
|
|
35
|
-
PM_ERR_AMPAMPEQ_MULTI_ASSIGN,
|
|
36
|
-
PM_ERR_ARGUMENT_AFTER_BLOCK,
|
|
37
|
-
PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES,
|
|
38
|
-
PM_ERR_ARGUMENT_BARE_HASH,
|
|
39
|
-
PM_ERR_ARGUMENT_BLOCK_FORWARDING,
|
|
40
|
-
PM_ERR_ARGUMENT_BLOCK_MULTI,
|
|
41
|
-
PM_ERR_ARGUMENT_CONFLICT_AMPERSAND,
|
|
42
|
-
PM_ERR_ARGUMENT_CONFLICT_STAR,
|
|
43
|
-
PM_ERR_ARGUMENT_CONFLICT_STAR_STAR,
|
|
44
|
-
PM_ERR_ARGUMENT_FORMAL_CLASS,
|
|
45
|
-
PM_ERR_ARGUMENT_FORMAL_CONSTANT,
|
|
46
|
-
PM_ERR_ARGUMENT_FORMAL_GLOBAL,
|
|
47
|
-
PM_ERR_ARGUMENT_FORMAL_IVAR,
|
|
48
|
-
PM_ERR_ARGUMENT_FORWARDING_UNBOUND,
|
|
49
|
-
PM_ERR_ARGUMENT_NO_FORWARDING_AMPERSAND,
|
|
50
|
-
PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES,
|
|
51
|
-
PM_ERR_ARGUMENT_NO_FORWARDING_STAR,
|
|
52
|
-
PM_ERR_ARGUMENT_NO_FORWARDING_STAR_STAR,
|
|
53
|
-
PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT,
|
|
54
|
-
PM_ERR_ARGUMENT_SPLAT_AFTER_SPLAT,
|
|
55
|
-
PM_ERR_ARGUMENT_TERM_PAREN,
|
|
56
|
-
PM_ERR_ARGUMENT_UNEXPECTED_BLOCK,
|
|
57
|
-
PM_ERR_ARRAY_ELEMENT,
|
|
58
|
-
PM_ERR_ARRAY_EXPRESSION,
|
|
59
|
-
PM_ERR_ARRAY_EXPRESSION_AFTER_STAR,
|
|
60
|
-
PM_ERR_ARRAY_SEPARATOR,
|
|
61
|
-
PM_ERR_ARRAY_TERM,
|
|
62
|
-
PM_ERR_BEGIN_LONELY_ELSE,
|
|
63
|
-
PM_ERR_BEGIN_TERM,
|
|
64
|
-
PM_ERR_BEGIN_UPCASE_BRACE,
|
|
65
|
-
PM_ERR_BEGIN_UPCASE_TERM,
|
|
66
|
-
PM_ERR_BEGIN_UPCASE_TOPLEVEL,
|
|
67
|
-
PM_ERR_BLOCK_PARAM_LOCAL_VARIABLE,
|
|
68
|
-
PM_ERR_BLOCK_PARAM_PIPE_TERM,
|
|
69
|
-
PM_ERR_BLOCK_TERM_BRACE,
|
|
70
|
-
PM_ERR_BLOCK_TERM_END,
|
|
71
|
-
PM_ERR_CANNOT_PARSE_EXPRESSION,
|
|
72
|
-
PM_ERR_CANNOT_PARSE_STRING_PART,
|
|
73
|
-
PM_ERR_CASE_EXPRESSION_AFTER_CASE,
|
|
74
|
-
PM_ERR_CASE_EXPRESSION_AFTER_WHEN,
|
|
75
|
-
PM_ERR_CASE_MATCH_MISSING_PREDICATE,
|
|
76
|
-
PM_ERR_CASE_MISSING_CONDITIONS,
|
|
77
|
-
PM_ERR_CASE_TERM,
|
|
78
|
-
PM_ERR_CLASS_IN_METHOD,
|
|
79
|
-
PM_ERR_CLASS_NAME,
|
|
80
|
-
PM_ERR_CLASS_SUPERCLASS,
|
|
81
|
-
PM_ERR_CLASS_TERM,
|
|
82
|
-
PM_ERR_CLASS_UNEXPECTED_END,
|
|
83
|
-
PM_ERR_CLASS_VARIABLE_BARE,
|
|
84
|
-
PM_ERR_CONDITIONAL_ELSIF_PREDICATE,
|
|
85
|
-
PM_ERR_CONDITIONAL_IF_PREDICATE,
|
|
86
|
-
PM_ERR_CONDITIONAL_PREDICATE_TERM,
|
|
87
|
-
PM_ERR_CONDITIONAL_TERM,
|
|
88
|
-
PM_ERR_CONDITIONAL_TERM_ELSE,
|
|
89
|
-
PM_ERR_CONDITIONAL_UNLESS_PREDICATE,
|
|
90
|
-
PM_ERR_CONDITIONAL_UNTIL_PREDICATE,
|
|
91
|
-
PM_ERR_CONDITIONAL_WHILE_PREDICATE,
|
|
92
|
-
PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT,
|
|
93
|
-
PM_ERR_DEF_ENDLESS,
|
|
94
|
-
PM_ERR_DEF_ENDLESS_PARAMETERS,
|
|
95
|
-
PM_ERR_DEF_ENDLESS_SETTER,
|
|
96
|
-
PM_ERR_DEF_NAME,
|
|
97
|
-
PM_ERR_DEF_PARAMS_TERM,
|
|
98
|
-
PM_ERR_DEF_PARAMS_TERM_PAREN,
|
|
99
|
-
PM_ERR_DEF_RECEIVER,
|
|
100
|
-
PM_ERR_DEF_RECEIVER_TERM,
|
|
101
|
-
PM_ERR_DEF_TERM,
|
|
102
|
-
PM_ERR_DEFINED_EXPRESSION,
|
|
103
|
-
PM_ERR_EMBDOC_TERM,
|
|
104
|
-
PM_ERR_EMBEXPR_END,
|
|
105
|
-
PM_ERR_EMBVAR_INVALID,
|
|
106
|
-
PM_ERR_END_UPCASE_BRACE,
|
|
107
|
-
PM_ERR_END_UPCASE_TERM,
|
|
108
|
-
PM_ERR_ESCAPE_INVALID_CONTROL,
|
|
109
|
-
PM_ERR_ESCAPE_INVALID_CONTROL_REPEAT,
|
|
110
|
-
PM_ERR_ESCAPE_INVALID_HEXADECIMAL,
|
|
111
|
-
PM_ERR_ESCAPE_INVALID_META,
|
|
112
|
-
PM_ERR_ESCAPE_INVALID_META_REPEAT,
|
|
113
|
-
PM_ERR_ESCAPE_INVALID_UNICODE,
|
|
114
|
-
PM_ERR_ESCAPE_INVALID_UNICODE_CM_FLAGS,
|
|
115
|
-
PM_ERR_ESCAPE_INVALID_UNICODE_LIST,
|
|
116
|
-
PM_ERR_ESCAPE_INVALID_UNICODE_LITERAL,
|
|
117
|
-
PM_ERR_ESCAPE_INVALID_UNICODE_LONG,
|
|
118
|
-
PM_ERR_ESCAPE_INVALID_UNICODE_SHORT,
|
|
119
|
-
PM_ERR_ESCAPE_INVALID_UNICODE_TERM,
|
|
120
|
-
PM_ERR_EXPECT_ARGUMENT,
|
|
121
|
-
PM_ERR_EXPECT_EOL_AFTER_STATEMENT,
|
|
122
|
-
PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ,
|
|
123
|
-
PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA,
|
|
124
|
-
PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL,
|
|
125
|
-
PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS,
|
|
126
|
-
PM_ERR_EXPECT_EXPRESSION_AFTER_LPAREN,
|
|
127
|
-
PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR,
|
|
128
|
-
PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ,
|
|
129
|
-
PM_ERR_EXPECT_EXPRESSION_AFTER_QUESTION,
|
|
130
|
-
PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT,
|
|
131
|
-
PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH,
|
|
132
|
-
PM_ERR_EXPECT_EXPRESSION_AFTER_STAR,
|
|
133
|
-
PM_ERR_EXPECT_FOR_DELIMITER,
|
|
134
|
-
PM_ERR_EXPECT_IDENT_REQ_PARAMETER,
|
|
135
|
-
PM_ERR_EXPECT_IN_DELIMITER,
|
|
136
|
-
PM_ERR_EXPECT_LPAREN_AFTER_NOT_LPAREN,
|
|
137
|
-
PM_ERR_EXPECT_LPAREN_AFTER_NOT_OTHER,
|
|
138
|
-
PM_ERR_EXPECT_LPAREN_REQ_PARAMETER,
|
|
139
|
-
PM_ERR_EXPECT_MESSAGE,
|
|
140
|
-
PM_ERR_EXPECT_RBRACKET,
|
|
141
|
-
PM_ERR_EXPECT_RPAREN,
|
|
142
|
-
PM_ERR_EXPECT_RPAREN_AFTER_MULTI,
|
|
143
|
-
PM_ERR_EXPECT_RPAREN_REQ_PARAMETER,
|
|
144
|
-
PM_ERR_EXPECT_SINGLETON_CLASS_DELIMITER,
|
|
145
|
-
PM_ERR_EXPECT_STRING_CONTENT,
|
|
146
|
-
PM_ERR_EXPECT_WHEN_DELIMITER,
|
|
147
|
-
PM_ERR_EXPRESSION_BARE_HASH,
|
|
148
|
-
PM_ERR_EXPRESSION_NOT_WRITABLE,
|
|
149
|
-
PM_ERR_EXPRESSION_NOT_WRITABLE_ENCODING,
|
|
150
|
-
PM_ERR_EXPRESSION_NOT_WRITABLE_FALSE,
|
|
151
|
-
PM_ERR_EXPRESSION_NOT_WRITABLE_FILE,
|
|
152
|
-
PM_ERR_EXPRESSION_NOT_WRITABLE_LINE,
|
|
153
|
-
PM_ERR_EXPRESSION_NOT_WRITABLE_NIL,
|
|
154
|
-
PM_ERR_EXPRESSION_NOT_WRITABLE_NUMBERED,
|
|
155
|
-
PM_ERR_EXPRESSION_NOT_WRITABLE_SELF,
|
|
156
|
-
PM_ERR_EXPRESSION_NOT_WRITABLE_TRUE,
|
|
157
|
-
PM_ERR_FLOAT_PARSE,
|
|
158
|
-
PM_ERR_FOR_COLLECTION,
|
|
159
|
-
PM_ERR_FOR_IN,
|
|
160
|
-
PM_ERR_FOR_INDEX,
|
|
161
|
-
PM_ERR_FOR_TERM,
|
|
162
|
-
PM_ERR_GLOBAL_VARIABLE_BARE,
|
|
163
|
-
PM_ERR_HASH_EXPRESSION_AFTER_LABEL,
|
|
164
|
-
PM_ERR_HASH_KEY,
|
|
165
|
-
PM_ERR_HASH_ROCKET,
|
|
166
|
-
PM_ERR_HASH_TERM,
|
|
167
|
-
PM_ERR_HASH_VALUE,
|
|
168
|
-
PM_ERR_HEREDOC_IDENTIFIER,
|
|
169
|
-
PM_ERR_HEREDOC_TERM,
|
|
170
|
-
PM_ERR_INCOMPLETE_QUESTION_MARK,
|
|
171
|
-
PM_ERR_INCOMPLETE_VARIABLE_CLASS,
|
|
172
|
-
PM_ERR_INCOMPLETE_VARIABLE_CLASS_3_3,
|
|
173
|
-
PM_ERR_INCOMPLETE_VARIABLE_INSTANCE,
|
|
174
|
-
PM_ERR_INCOMPLETE_VARIABLE_INSTANCE_3_3,
|
|
175
|
-
PM_ERR_INSTANCE_VARIABLE_BARE,
|
|
176
|
-
PM_ERR_INVALID_BLOCK_EXIT,
|
|
177
|
-
PM_ERR_INVALID_CHARACTER,
|
|
178
|
-
PM_ERR_INVALID_COMMA,
|
|
179
|
-
PM_ERR_INVALID_ENCODING_MAGIC_COMMENT,
|
|
180
|
-
PM_ERR_INVALID_ESCAPE_CHARACTER,
|
|
181
|
-
PM_ERR_INVALID_FLOAT_EXPONENT,
|
|
182
|
-
PM_ERR_INVALID_LOCAL_VARIABLE_READ,
|
|
183
|
-
PM_ERR_INVALID_LOCAL_VARIABLE_WRITE,
|
|
184
|
-
PM_ERR_INVALID_MULTIBYTE_CHAR,
|
|
185
|
-
PM_ERR_INVALID_MULTIBYTE_CHARACTER,
|
|
186
|
-
PM_ERR_INVALID_MULTIBYTE_ESCAPE,
|
|
187
|
-
PM_ERR_INVALID_NUMBER_BINARY,
|
|
188
|
-
PM_ERR_INVALID_NUMBER_DECIMAL,
|
|
189
|
-
PM_ERR_INVALID_NUMBER_FRACTION,
|
|
190
|
-
PM_ERR_INVALID_NUMBER_HEXADECIMAL,
|
|
191
|
-
PM_ERR_INVALID_NUMBER_OCTAL,
|
|
192
|
-
PM_ERR_INVALID_NUMBER_UNDERSCORE_INNER,
|
|
193
|
-
PM_ERR_INVALID_NUMBER_UNDERSCORE_TRAILING,
|
|
194
|
-
PM_ERR_INVALID_PERCENT,
|
|
195
|
-
PM_ERR_INVALID_PERCENT_EOF,
|
|
196
|
-
PM_ERR_INVALID_PRINTABLE_CHARACTER,
|
|
197
|
-
PM_ERR_INVALID_RETRY_AFTER_ELSE,
|
|
198
|
-
PM_ERR_INVALID_RETRY_AFTER_ENSURE,
|
|
199
|
-
PM_ERR_INVALID_RETRY_WITHOUT_RESCUE,
|
|
200
|
-
PM_ERR_INVALID_SYMBOL,
|
|
201
|
-
PM_ERR_INVALID_VARIABLE_GLOBAL,
|
|
202
|
-
PM_ERR_INVALID_VARIABLE_GLOBAL_3_3,
|
|
203
|
-
PM_ERR_INVALID_YIELD,
|
|
204
|
-
PM_ERR_IT_NOT_ALLOWED_NUMBERED,
|
|
205
|
-
PM_ERR_IT_NOT_ALLOWED_ORDINARY,
|
|
206
|
-
PM_ERR_LAMBDA_OPEN,
|
|
207
|
-
PM_ERR_LAMBDA_TERM_BRACE,
|
|
208
|
-
PM_ERR_LAMBDA_TERM_END,
|
|
209
|
-
PM_ERR_LIST_I_LOWER_ELEMENT,
|
|
210
|
-
PM_ERR_LIST_I_LOWER_TERM,
|
|
211
|
-
PM_ERR_LIST_I_UPPER_ELEMENT,
|
|
212
|
-
PM_ERR_LIST_I_UPPER_TERM,
|
|
213
|
-
PM_ERR_LIST_W_LOWER_ELEMENT,
|
|
214
|
-
PM_ERR_LIST_W_LOWER_TERM,
|
|
215
|
-
PM_ERR_LIST_W_UPPER_ELEMENT,
|
|
216
|
-
PM_ERR_LIST_W_UPPER_TERM,
|
|
217
|
-
PM_ERR_MALLOC_FAILED,
|
|
218
|
-
PM_ERR_MIXED_ENCODING,
|
|
219
|
-
PM_ERR_MODULE_IN_METHOD,
|
|
220
|
-
PM_ERR_MODULE_NAME,
|
|
221
|
-
PM_ERR_MODULE_TERM,
|
|
222
|
-
PM_ERR_MULTI_ASSIGN_MULTI_SPLATS,
|
|
223
|
-
PM_ERR_MULTI_ASSIGN_UNEXPECTED_REST,
|
|
224
|
-
PM_ERR_NESTING_TOO_DEEP,
|
|
225
|
-
PM_ERR_NO_LOCAL_VARIABLE,
|
|
226
|
-
PM_ERR_NON_ASSOCIATIVE_OPERATOR,
|
|
227
|
-
PM_ERR_NOT_EXPRESSION,
|
|
228
|
-
PM_ERR_NUMBER_LITERAL_UNDERSCORE,
|
|
229
|
-
PM_ERR_NUMBERED_PARAMETER_INNER_BLOCK,
|
|
230
|
-
PM_ERR_NUMBERED_PARAMETER_IT,
|
|
231
|
-
PM_ERR_NUMBERED_PARAMETER_ORDINARY,
|
|
232
|
-
PM_ERR_NUMBERED_PARAMETER_OUTER_BLOCK,
|
|
233
|
-
PM_ERR_OPERATOR_MULTI_ASSIGN,
|
|
234
|
-
PM_ERR_OPERATOR_WRITE_ARGUMENTS,
|
|
235
|
-
PM_ERR_OPERATOR_WRITE_BLOCK,
|
|
236
|
-
PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI,
|
|
237
|
-
PM_ERR_PARAMETER_BLOCK_MULTI,
|
|
238
|
-
PM_ERR_PARAMETER_CIRCULAR,
|
|
239
|
-
PM_ERR_PARAMETER_FORWARDING_AFTER_REST,
|
|
240
|
-
PM_ERR_PARAMETER_METHOD_NAME,
|
|
241
|
-
PM_ERR_PARAMETER_NAME_DUPLICATED,
|
|
242
|
-
PM_ERR_PARAMETER_NO_DEFAULT,
|
|
243
|
-
PM_ERR_PARAMETER_NO_DEFAULT_KW,
|
|
244
|
-
PM_ERR_PARAMETER_NUMBERED_RESERVED,
|
|
245
|
-
PM_ERR_PARAMETER_ORDER,
|
|
246
|
-
PM_ERR_PARAMETER_SPLAT_MULTI,
|
|
247
|
-
PM_ERR_PARAMETER_STAR,
|
|
248
|
-
PM_ERR_PARAMETER_UNEXPECTED_FWD,
|
|
249
|
-
PM_ERR_PARAMETER_UNEXPECTED_NO_KW,
|
|
250
|
-
PM_ERR_PARAMETER_WILD_LOOSE_COMMA,
|
|
251
|
-
PM_ERR_PATTERN_ARRAY_MULTIPLE_RESTS,
|
|
252
|
-
PM_ERR_PATTERN_CAPTURE_DUPLICATE,
|
|
253
|
-
PM_ERR_PATTERN_CAPTURE_IN_ALTERNATIVE,
|
|
254
|
-
PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET,
|
|
255
|
-
PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA,
|
|
256
|
-
PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET,
|
|
257
|
-
PM_ERR_PATTERN_EXPRESSION_AFTER_IN,
|
|
258
|
-
PM_ERR_PATTERN_EXPRESSION_AFTER_KEY,
|
|
259
|
-
PM_ERR_PATTERN_EXPRESSION_AFTER_PAREN,
|
|
260
|
-
PM_ERR_PATTERN_EXPRESSION_AFTER_PIN,
|
|
261
|
-
PM_ERR_PATTERN_EXPRESSION_AFTER_PIPE,
|
|
262
|
-
PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE,
|
|
263
|
-
PM_ERR_PATTERN_EXPRESSION_AFTER_REST,
|
|
264
|
-
PM_ERR_PATTERN_FIND_MISSING_INNER,
|
|
265
|
-
PM_ERR_PATTERN_HASH_IMPLICIT,
|
|
266
|
-
PM_ERR_PATTERN_HASH_KEY,
|
|
267
|
-
PM_ERR_PATTERN_HASH_KEY_DUPLICATE,
|
|
268
|
-
PM_ERR_PATTERN_HASH_KEY_INTERPOLATED,
|
|
269
|
-
PM_ERR_PATTERN_HASH_KEY_LABEL,
|
|
270
|
-
PM_ERR_PATTERN_HASH_KEY_LOCALS,
|
|
271
|
-
PM_ERR_PATTERN_IDENT_AFTER_HROCKET,
|
|
272
|
-
PM_ERR_PATTERN_LABEL_AFTER_COMMA,
|
|
273
|
-
PM_ERR_PATTERN_REST,
|
|
274
|
-
PM_ERR_PATTERN_TERM_BRACE,
|
|
275
|
-
PM_ERR_PATTERN_TERM_BRACKET,
|
|
276
|
-
PM_ERR_PATTERN_TERM_PAREN,
|
|
277
|
-
PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN,
|
|
278
|
-
PM_ERR_REGEXP_ENCODING_OPTION_MISMATCH,
|
|
279
|
-
PM_ERR_REGEXP_INCOMPAT_CHAR_ENCODING,
|
|
280
|
-
PM_ERR_REGEXP_INVALID_UNICODE_RANGE,
|
|
281
|
-
PM_ERR_REGEXP_NON_ESCAPED_MBC,
|
|
282
|
-
PM_ERR_REGEXP_PARSE_ERROR,
|
|
283
|
-
PM_ERR_REGEXP_TERM,
|
|
284
|
-
PM_ERR_REGEXP_UNKNOWN_OPTIONS,
|
|
285
|
-
PM_ERR_REGEXP_UTF8_CHAR_NON_UTF8_REGEXP,
|
|
286
|
-
PM_ERR_RESCUE_EXPRESSION,
|
|
287
|
-
PM_ERR_RESCUE_MODIFIER_VALUE,
|
|
288
|
-
PM_ERR_RESCUE_TERM,
|
|
289
|
-
PM_ERR_RESCUE_VARIABLE,
|
|
290
|
-
PM_ERR_RETURN_INVALID,
|
|
291
|
-
PM_ERR_SCRIPT_NOT_FOUND,
|
|
292
|
-
PM_ERR_SINGLETON_FOR_LITERALS,
|
|
293
|
-
PM_ERR_STATEMENT_ALIAS,
|
|
294
|
-
PM_ERR_STATEMENT_POSTEXE_END,
|
|
295
|
-
PM_ERR_STATEMENT_PREEXE_BEGIN,
|
|
296
|
-
PM_ERR_STATEMENT_UNDEF,
|
|
297
|
-
PM_ERR_STRING_CONCATENATION,
|
|
298
|
-
PM_ERR_STRING_INTERPOLATED_TERM,
|
|
299
|
-
PM_ERR_STRING_LITERAL_EOF,
|
|
300
|
-
PM_ERR_STRING_LITERAL_TERM,
|
|
301
|
-
PM_ERR_SYMBOL_INVALID,
|
|
302
|
-
PM_ERR_SYMBOL_TERM_DYNAMIC,
|
|
303
|
-
PM_ERR_SYMBOL_TERM_INTERPOLATED,
|
|
304
|
-
PM_ERR_TERNARY_COLON,
|
|
305
|
-
PM_ERR_TERNARY_EXPRESSION_FALSE,
|
|
306
|
-
PM_ERR_TERNARY_EXPRESSION_TRUE,
|
|
307
|
-
PM_ERR_UNARY_DISALLOWED,
|
|
308
|
-
PM_ERR_UNARY_RECEIVER,
|
|
309
|
-
PM_ERR_UNDEF_ARGUMENT,
|
|
310
|
-
PM_ERR_UNEXPECTED_BLOCK_ARGUMENT,
|
|
311
|
-
PM_ERR_UNEXPECTED_INDEX_BLOCK,
|
|
312
|
-
PM_ERR_UNEXPECTED_INDEX_KEYWORDS,
|
|
313
|
-
PM_ERR_UNEXPECTED_LABEL,
|
|
314
|
-
PM_ERR_UNEXPECTED_MULTI_WRITE,
|
|
315
|
-
PM_ERR_UNEXPECTED_PARAMETER_DEFAULT_VALUE,
|
|
316
|
-
PM_ERR_UNEXPECTED_RANGE_OPERATOR,
|
|
317
|
-
PM_ERR_UNEXPECTED_SAFE_NAVIGATION,
|
|
318
|
-
PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT,
|
|
319
|
-
PM_ERR_UNEXPECTED_TOKEN_IGNORE,
|
|
320
|
-
PM_ERR_UNTIL_TERM,
|
|
321
|
-
PM_ERR_VOID_EXPRESSION,
|
|
322
|
-
PM_ERR_WHILE_TERM,
|
|
323
|
-
PM_ERR_WRITE_TARGET_IN_METHOD,
|
|
324
|
-
PM_ERR_WRITE_TARGET_READONLY,
|
|
325
|
-
PM_ERR_WRITE_TARGET_UNEXPECTED,
|
|
326
|
-
PM_ERR_XSTRING_TERM,
|
|
327
|
-
|
|
328
|
-
// These are the warning diagnostics.
|
|
329
|
-
PM_WARN_AMBIGUOUS_BINARY_OPERATOR,
|
|
330
|
-
PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS,
|
|
331
|
-
PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS,
|
|
332
|
-
PM_WARN_AMBIGUOUS_PREFIX_AMPERSAND,
|
|
333
|
-
PM_WARN_AMBIGUOUS_PREFIX_STAR,
|
|
334
|
-
PM_WARN_AMBIGUOUS_PREFIX_STAR_STAR,
|
|
335
|
-
PM_WARN_AMBIGUOUS_SLASH,
|
|
336
|
-
PM_WARN_COMPARISON_AFTER_COMPARISON,
|
|
337
|
-
PM_WARN_DOT_DOT_DOT_EOL,
|
|
338
|
-
PM_WARN_EQUAL_IN_CONDITIONAL,
|
|
339
|
-
PM_WARN_EQUAL_IN_CONDITIONAL_3_3,
|
|
340
|
-
PM_WARN_END_IN_METHOD,
|
|
341
|
-
PM_WARN_DUPLICATED_HASH_KEY,
|
|
342
|
-
PM_WARN_DUPLICATED_WHEN_CLAUSE,
|
|
343
|
-
PM_WARN_FLOAT_OUT_OF_RANGE,
|
|
344
|
-
PM_WARN_IGNORED_FROZEN_STRING_LITERAL,
|
|
345
|
-
PM_WARN_INDENTATION_MISMATCH,
|
|
346
|
-
PM_WARN_INTEGER_IN_FLIP_FLOP,
|
|
347
|
-
PM_WARN_INVALID_CHARACTER,
|
|
348
|
-
PM_WARN_INVALID_MAGIC_COMMENT_VALUE,
|
|
349
|
-
PM_WARN_INVALID_NUMBERED_REFERENCE,
|
|
350
|
-
PM_WARN_KEYWORD_EOL,
|
|
351
|
-
PM_WARN_LITERAL_IN_CONDITION_DEFAULT,
|
|
352
|
-
PM_WARN_LITERAL_IN_CONDITION_VERBOSE,
|
|
353
|
-
PM_WARN_SHAREABLE_CONSTANT_VALUE_LINE,
|
|
354
|
-
PM_WARN_SHEBANG_CARRIAGE_RETURN,
|
|
355
|
-
PM_WARN_UNEXPECTED_CARRIAGE_RETURN,
|
|
356
|
-
PM_WARN_UNREACHABLE_STATEMENT,
|
|
357
|
-
PM_WARN_UNUSED_LOCAL_VARIABLE,
|
|
358
|
-
PM_WARN_VOID_STATEMENT,
|
|
359
|
-
} pm_diagnostic_id_t;
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* This struct represents a diagnostic generated during parsing.
|
|
363
|
-
*
|
|
364
|
-
* @extends pm_list_node_t
|
|
365
|
-
*/
|
|
366
|
-
typedef struct {
|
|
367
|
-
/** The embedded base node. */
|
|
368
|
-
pm_list_node_t node;
|
|
369
|
-
|
|
370
|
-
/** The location of the diagnostic in the source. */
|
|
371
|
-
pm_location_t location;
|
|
372
|
-
|
|
373
|
-
/** The ID of the diagnostic. */
|
|
374
|
-
pm_diagnostic_id_t diag_id;
|
|
375
|
-
|
|
376
|
-
/** The message associated with the diagnostic. */
|
|
377
|
-
const char *message;
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Whether or not the memory related to the message of this diagnostic is
|
|
381
|
-
* owned by this diagnostic. If it is, it needs to be freed when the
|
|
382
|
-
* diagnostic is freed.
|
|
383
|
-
*/
|
|
384
|
-
bool owned;
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* The level of the diagnostic, see `pm_error_level_t` and
|
|
388
|
-
* `pm_warning_level_t` for possible values.
|
|
389
|
-
*/
|
|
390
|
-
uint8_t level;
|
|
391
|
-
} pm_diagnostic_t;
|
|
18
|
+
typedef struct pm_diagnostic_t pm_diagnostic_t;
|
|
392
19
|
|
|
393
20
|
/**
|
|
394
21
|
* The levels of errors generated during parsing.
|
|
@@ -416,43 +43,51 @@ typedef enum {
|
|
|
416
43
|
} pm_warning_level_t;
|
|
417
44
|
|
|
418
45
|
/**
|
|
419
|
-
* Get the
|
|
46
|
+
* Get the type of the given diagnostic.
|
|
47
|
+
*
|
|
48
|
+
* @param diagnostic The diagnostic to get the type of.
|
|
49
|
+
* @returns The type of the given diagnostic. Note that this is a string
|
|
50
|
+
* representation of an internal ID, and is not meant to be relied upon as a
|
|
51
|
+
* stable identifier for the diagnostic. We do not guarantee that these will
|
|
52
|
+
* not change in the future. This is meant to be used for debugging and
|
|
53
|
+
* error reporting purposes, and not for programmatic checks.
|
|
54
|
+
*/
|
|
55
|
+
PRISM_EXPORTED_FUNCTION const char * pm_diagnostic_type(const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get the location of the given diagnostic.
|
|
420
59
|
*
|
|
421
|
-
* @param
|
|
422
|
-
* @
|
|
60
|
+
* @param diagnostic The diagnostic to get the location of.
|
|
61
|
+
* @returns The location of the given diagnostic.
|
|
423
62
|
*/
|
|
424
|
-
const
|
|
63
|
+
PRISM_EXPORTED_FUNCTION pm_location_t pm_diagnostic_location(const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1);
|
|
425
64
|
|
|
426
65
|
/**
|
|
427
|
-
*
|
|
428
|
-
* memory for its message.
|
|
66
|
+
* Get the message of the given diagnostic.
|
|
429
67
|
*
|
|
430
|
-
* @param
|
|
431
|
-
* @
|
|
432
|
-
* @param end The end of the diagnostic.
|
|
433
|
-
* @param diag_id The diagnostic ID.
|
|
434
|
-
* @return Whether the diagnostic was successfully appended.
|
|
68
|
+
* @param diagnostic The diagnostic to get the message of.
|
|
69
|
+
* @returns The message of the given diagnostic.
|
|
435
70
|
*/
|
|
436
|
-
|
|
71
|
+
PRISM_EXPORTED_FUNCTION const char * pm_diagnostic_message(const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1);
|
|
437
72
|
|
|
438
73
|
/**
|
|
439
|
-
*
|
|
440
|
-
* string for its message.
|
|
74
|
+
* Get the error level associated with the given diagnostic.
|
|
441
75
|
*
|
|
442
|
-
* @param
|
|
443
|
-
* @
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
* @param ... The arguments to the format string for the message.
|
|
447
|
-
* @return Whether the diagnostic was successfully appended.
|
|
76
|
+
* @param diagnostic The diagnostic to get the error level of.
|
|
77
|
+
* @returns The error level of the given diagnostic. If the diagnostic was a
|
|
78
|
+
* warning, or is in any way not an error, then the return value is
|
|
79
|
+
* undefined and should not be relied upon.
|
|
448
80
|
*/
|
|
449
|
-
|
|
81
|
+
PRISM_EXPORTED_FUNCTION pm_error_level_t pm_diagnostic_error_level(const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1);
|
|
450
82
|
|
|
451
83
|
/**
|
|
452
|
-
*
|
|
84
|
+
* Get the warning level associated with the given diagnostic.
|
|
453
85
|
*
|
|
454
|
-
* @param
|
|
86
|
+
* @param diagnostic The diagnostic to get the warning level of.
|
|
87
|
+
* @returns The warning level of the given diagnostic. If the diagnostic was an
|
|
88
|
+
* error, or is in any way not a warning, then the return value is
|
|
89
|
+
* undefined and should not be relied upon.
|
|
455
90
|
*/
|
|
456
|
-
|
|
91
|
+
PRISM_EXPORTED_FUNCTION pm_warning_level_t pm_diagnostic_warning_level(const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1);
|
|
457
92
|
|
|
458
93
|
#endif
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file errors_format.h
|
|
3
|
+
*
|
|
4
|
+
* A function for formatting the errors in a parser into a buffer.
|
|
5
|
+
*/
|
|
6
|
+
#ifndef PRISM_ERRORS_FORMAT_H
|
|
7
|
+
#define PRISM_ERRORS_FORMAT_H
|
|
8
|
+
|
|
9
|
+
#include "prism/compiler/exported.h"
|
|
10
|
+
#include "prism/compiler/nodiscard.h"
|
|
11
|
+
#include "prism/compiler/nonnull.h"
|
|
12
|
+
|
|
13
|
+
#include "prism/buffer.h"
|
|
14
|
+
#include "prism/diagnostic.h"
|
|
15
|
+
#include "prism/parser.h"
|
|
16
|
+
|
|
17
|
+
/** The type of formatting to use when formatting errors. */
|
|
18
|
+
typedef enum {
|
|
19
|
+
/** Format errors in a plain format with no colors or styles. Typically
|
|
20
|
+
* used when outputting to a file or when the output is not a terminal.
|
|
21
|
+
*/
|
|
22
|
+
PM_ERRORS_FORMAT_PLAIN = 1,
|
|
23
|
+
|
|
24
|
+
/** Format errors in a style format with bold only. Typically used when
|
|
25
|
+
* outputting to a terminal where you do not want colors.
|
|
26
|
+
*/
|
|
27
|
+
PM_ERRORS_FORMAT_STYLE = 2,
|
|
28
|
+
|
|
29
|
+
/** Format errors in a color format with bold and colors. The default case
|
|
30
|
+
* when outputting on the terminal.
|
|
31
|
+
*/
|
|
32
|
+
PM_ERRORS_FORMAT_COLOR = 3
|
|
33
|
+
} pm_errors_format_type_t;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Format the errors in a parser into a buffer. After return, the buffer will
|
|
37
|
+
* contain the formatted errors and any relevant source snippets if available
|
|
38
|
+
* and possible.
|
|
39
|
+
*
|
|
40
|
+
* @param parser The parser containing the errors to format. Note that the
|
|
41
|
+
* parser does not need to be fully initialized, but it will need to have
|
|
42
|
+
* start, end, start_line, encoding, line_offsets, filepath, and error_list
|
|
43
|
+
* initialized.
|
|
44
|
+
* @param buffer The buffer to format the errors into.
|
|
45
|
+
* @param format_type The type of formatting to use when formatting the errors.
|
|
46
|
+
* @returns The error level of the error with the highest precedence that was
|
|
47
|
+
* formatted. In practice this means it will be the argument or load error
|
|
48
|
+
* level if any were found, otherwise it will be the syntax error level.
|
|
49
|
+
* Callers should raise appropriate error types based on the returned level.
|
|
50
|
+
*/
|
|
51
|
+
PRISM_EXPORTED_FUNCTION pm_error_level_t pm_errors_format(const pm_parser_t *parser, pm_buffer_t *buffer, pm_errors_format_type_t format_type) PRISM_NONNULL(1, 2);
|
|
52
|
+
|
|
53
|
+
#endif
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file excludes.h
|
|
3
|
+
*
|
|
4
|
+
* A header file that defines macros to exclude certain features of the prism
|
|
5
|
+
* library. This is useful for reducing the size of the library when certain
|
|
6
|
+
* features are not needed.
|
|
7
|
+
*/
|
|
8
|
+
#ifndef PRISM_EXCLUDES_H
|
|
9
|
+
#define PRISM_EXCLUDES_H
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* If PRISM_BUILD_MINIMAL is defined, then we're going to define every possible
|
|
13
|
+
* switch that will turn off certain features of prism.
|
|
14
|
+
*/
|
|
15
|
+
#ifdef PRISM_BUILD_MINIMAL
|
|
16
|
+
/** Exclude the serialization API. */
|
|
17
|
+
#define PRISM_EXCLUDE_SERIALIZATION
|
|
18
|
+
|
|
19
|
+
/** Exclude the JSON serialization API. */
|
|
20
|
+
#define PRISM_EXCLUDE_JSON
|
|
21
|
+
|
|
22
|
+
/** Exclude the prettyprint API. */
|
|
23
|
+
#define PRISM_EXCLUDE_PRETTYPRINT
|
|
24
|
+
|
|
25
|
+
/** Exclude the full set of encodings, using the minimal only. */
|
|
26
|
+
#define PRISM_ENCODING_EXCLUDE_FULL
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#endif
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file integer.h
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for working with arbitrary-sized integers.
|
|
5
|
+
*/
|
|
6
|
+
#ifndef PRISM_INTEGER_H
|
|
7
|
+
#define PRISM_INTEGER_H
|
|
8
|
+
|
|
9
|
+
#include <stdbool.h>
|
|
10
|
+
#include <stddef.h>
|
|
11
|
+
#include <stdint.h>
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A structure represents an arbitrary-sized integer.
|
|
15
|
+
*/
|
|
16
|
+
typedef struct {
|
|
17
|
+
/**
|
|
18
|
+
* The number of allocated values. length is set to 0 if the integer fits
|
|
19
|
+
* into uint32_t.
|
|
20
|
+
*/
|
|
21
|
+
size_t length;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* List of 32-bit integers. Set to NULL if the integer fits into uint32_t.
|
|
25
|
+
*/
|
|
26
|
+
uint32_t *values;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Embedded value for small integer. This value is set to 0 if the value
|
|
30
|
+
* does not fit into uint32_t.
|
|
31
|
+
*/
|
|
32
|
+
uint32_t value;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Whether or not the integer is negative. It is stored this way so that a
|
|
36
|
+
* zeroed pm_integer_t is always positive zero.
|
|
37
|
+
*/
|
|
38
|
+
bool negative;
|
|
39
|
+
} pm_integer_t;
|
|
40
|
+
|
|
41
|
+
#endif
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#ifndef PRISM_INTERNAL_ALLOCATOR_H
|
|
2
|
+
#define PRISM_INTERNAL_ALLOCATOR_H
|
|
3
|
+
|
|
4
|
+
/* If you build Prism with a custom allocator, configure it with
|
|
5
|
+
* "-D PRISM_XALLOCATOR" to use your own allocator that defines xmalloc,
|
|
6
|
+
* xrealloc, xcalloc, and xfree.
|
|
7
|
+
*
|
|
8
|
+
* For example, your `prism_xallocator.h` file could look like this:
|
|
9
|
+
*
|
|
10
|
+
* ```
|
|
11
|
+
* #ifndef PRISM_XALLOCATOR_H
|
|
12
|
+
* #define PRISM_XALLOCATOR_H
|
|
13
|
+
* #define xmalloc my_malloc
|
|
14
|
+
* #define xrealloc my_realloc
|
|
15
|
+
* #define xcalloc my_calloc
|
|
16
|
+
* #define xfree my_free
|
|
17
|
+
* #define xrealloc_sized my_realloc_sized // (optional)
|
|
18
|
+
* #define xfree_sized my_free_sized // (optional)
|
|
19
|
+
* #endif
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
#ifdef PRISM_XALLOCATOR
|
|
23
|
+
#include "prism_xallocator.h"
|
|
24
|
+
#else
|
|
25
|
+
#ifndef xmalloc
|
|
26
|
+
/* The malloc function that should be used. This can be overridden with
|
|
27
|
+
* the PRISM_XALLOCATOR define. */
|
|
28
|
+
#define xmalloc malloc
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
#ifndef xrealloc
|
|
32
|
+
/* The realloc function that should be used. This can be overridden with
|
|
33
|
+
* the PRISM_XALLOCATOR define. */
|
|
34
|
+
#define xrealloc realloc
|
|
35
|
+
#endif
|
|
36
|
+
|
|
37
|
+
#ifndef xcalloc
|
|
38
|
+
/* The calloc function that should be used. This can be overridden with
|
|
39
|
+
* the PRISM_XALLOCATOR define. */
|
|
40
|
+
#define xcalloc calloc
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
#ifndef xfree
|
|
44
|
+
/* The free function that should be used. This can be overridden with
|
|
45
|
+
* the PRISM_XALLOCATOR define. */
|
|
46
|
+
#define xfree free
|
|
47
|
+
#endif
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
#ifndef xfree_sized
|
|
51
|
+
/* The free_sized function that should be used. This can be overridden with
|
|
52
|
+
* the PRISM_XALLOCATOR define. If not defined, defaults to calling xfree.
|
|
53
|
+
*/
|
|
54
|
+
#define xfree_sized(p, s) xfree(((void)(s), (p)))
|
|
55
|
+
#endif
|
|
56
|
+
|
|
57
|
+
#ifndef xrealloc_sized
|
|
58
|
+
/* The xrealloc_sized function that should be used. This can be overridden
|
|
59
|
+
* with the PRISM_XALLOCATOR define. If not defined, defaults to calling
|
|
60
|
+
* xrealloc. */
|
|
61
|
+
#define xrealloc_sized(p, ns, os) xrealloc((p), ((void)(os), (ns)))
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
#ifdef PRISM_BUILD_DEBUG
|
|
65
|
+
#include "prism/internal/allocator_debug.h"
|
|
66
|
+
#endif
|
|
67
|
+
|
|
68
|
+
#endif
|