herb 0.11.1 → 0.11.2
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/Rakefile +4 -2
- data/config.yml +6 -0
- data/ext/herb/extconf.rb +8 -31
- data/ext/herb/nodes.c +75 -75
- data/ext/herb/parser_options_helpers.c +26 -0
- data/lib/herb/analysis/partial_index.rb +1 -1
- data/lib/herb/analysis/partial_resolution.rb +27 -0
- data/lib/herb/ast/helpers.rb +1 -1
- data/lib/herb/configuration.rb +11 -1
- data/lib/herb/dev/classifier.rb +1 -1
- data/lib/herb/engine/compiler.rb +5 -8
- data/lib/herb/engine/slots/dynamics_compiler.rb +53 -14
- data/lib/herb/engine/slots/subtree_compiler.rb +1 -1
- data/lib/herb/engine/slots/visitor.rb +32 -4
- data/lib/herb/engine/visitors/instrumentation_visitor.rb +18 -6
- data/lib/herb/parser_options.rb +6 -3
- data/lib/herb/project.rb +19 -8
- data/lib/herb/version.rb +1 -1
- data/lib/herb.rb +1 -1
- data/sig/herb/analysis/partial_resolution.rbs +8 -0
- data/sig/herb/configuration.rbs +3 -0
- data/sig/herb/engine/slots/dynamics_compiler.rbs +24 -7
- data/sig/herb/engine/slots/visitor.rbs +14 -0
- data/sig/herb/engine/visitors/instrumentation_visitor.rbs +5 -1
- data/sig/herb/parser_options.rbs +6 -4
- data/sig/herb.rbs +2 -2
- data/src/analyze/action_view/attribute_extraction_helpers.c +40 -21
- data/src/analyze/action_view/generated_handlers.c +36 -36
- data/src/analyze/action_view/image_tag.c +7 -3
- data/src/analyze/action_view/javascript_include_tag.c +6 -3
- data/src/analyze/action_view/link_to.c +23 -23
- data/src/analyze/action_view/registry.c +7 -3
- data/src/analyze/action_view/tag_helper_node_builders.c +6 -13
- data/src/analyze/action_view/tag_helpers.c +139 -90
- data/src/analyze/action_view/turbo_frame_tag.c +5 -4
- data/src/analyze/analyze.c +35 -19
- data/src/analyze/analyze_helpers.c +161 -188
- data/src/analyze/analyzed_ruby.c +8 -7
- data/src/analyze/control_type.c +29 -22
- data/src/analyze/herb_directives.c +16 -20
- data/src/analyze/iteration_nodes.c +69 -24
- data/src/analyze/parse_errors.c +32 -22
- data/src/analyze/postfix_conditionals.c +23 -13
- data/src/analyze/prism_annotate.c +29 -28
- data/src/analyze/render_nodes.c +51 -41
- data/src/analyze/strict_locals.c +14 -15
- data/src/analyze/ternary_conditionals.c +14 -10
- data/src/herb.c +10 -8
- data/src/include/analyze/action_view/tag_helper_handler.h +1 -1
- data/src/include/analyze/action_view/tag_helper_node_builders.h +1 -0
- data/src/include/analyze/action_view/tag_helpers.h +1 -1
- data/src/include/analyze/analyze.h +3 -2
- data/src/include/analyze/analyzed_ruby.h +4 -2
- data/src/include/analyze/helpers.h +6 -6
- data/src/include/herb.h +3 -2
- data/src/include/parser/parser_options.h +5 -0
- data/src/include/prism/prism_context.h +12 -12
- data/src/include/prism/prism_helpers.h +30 -0
- data/src/include/prism_version.h +11 -0
- data/src/include/version.h +1 -1
- data/src/parser/parser_helpers.c +1 -2
- data/src/parser.c +6 -7
- data/src/parser_options_defaults.c +1 -0
- data/src/prism/prism_helpers.c +84 -50
- data/src/prism/ruby_parser.c +20 -20
- data/templates/ext/herb/nodes.c.erb +5 -5
- data/templates/ext/herb/parser_options_helpers.c.erb +33 -0
- data/templates/java/nodes.c.erb +6 -6
- data/templates/java/parser_options_helpers.c.erb +41 -2
- data/templates/java/parser_options_helpers.h.erb +2 -1
- data/templates/javascript/packages/node/extension/nodes.cpp.erb +5 -5
- data/templates/javascript/packages/node/extension/parser_options_helpers.cpp.erb +34 -2
- data/templates/javascript/packages/node/extension/parser_options_helpers.h.erb +1 -1
- data/templates/lib/herb/parser_options.rb.erb +1 -1
- data/templates/rust/src/prism/generated_deserialize.rs.erb +90 -44
- data/templates/rust/src/prism/generated_prettyprint.rs.erb +18 -27
- data/templates/src/analyze/action_view/generated_handlers.c.erb +23 -22
- data/templates/src/include/parser/parser_options.h.erb +10 -0
- data/templates/src/include/prism_version.h.erb +17 -0
- data/templates/src/parser_options_defaults.c.erb +1 -1
- data/templates/template.rb +17 -2
- data/templates/wasm/nodes.cpp.erb +5 -5
- data/templates/wasm/parser_options_helpers.cpp.erb +24 -0
- data/vendor/prism/Rakefile +76 -7
- data/vendor/prism/config.yml +174 -161
- data/vendor/prism/include/prism/arena.h +45 -0
- data/vendor/prism/include/prism/arena.hpp +42 -0
- data/vendor/prism/include/prism/ast.h +2738 -611
- data/vendor/prism/include/prism/ast.hpp +641 -0
- data/vendor/prism/include/prism/buffer.h +60 -0
- data/vendor/prism/include/prism/buffer.hpp +55 -0
- data/vendor/prism/include/prism/comments.h +72 -0
- data/vendor/prism/include/prism/compiler/accel.h +26 -0
- data/vendor/prism/include/prism/compiler/align.h +36 -0
- data/vendor/prism/include/prism/compiler/assume.h +25 -0
- data/vendor/prism/include/prism/compiler/branch.h +26 -0
- data/vendor/prism/include/prism/compiler/bswap.h +46 -0
- data/vendor/prism/include/prism/compiler/cplusplus.hpp +16 -0
- data/vendor/prism/include/prism/compiler/endianness.h +34 -0
- data/vendor/prism/include/prism/compiler/exceptions.hpp +17 -0
- data/vendor/prism/include/prism/compiler/exported.h +24 -0
- data/vendor/prism/include/prism/compiler/fallthrough.h +22 -0
- data/vendor/prism/include/prism/compiler/filesystem.h +32 -0
- data/vendor/prism/include/prism/compiler/flex_array.h +19 -0
- data/vendor/prism/include/prism/compiler/force_inline.h +21 -0
- data/vendor/prism/include/prism/compiler/format.h +27 -0
- data/vendor/prism/include/prism/compiler/inline.h +17 -0
- data/vendor/prism/include/prism/compiler/lifetimebound.hpp +25 -0
- data/vendor/prism/include/prism/compiler/nodiscard.h +22 -0
- data/vendor/prism/include/prism/compiler/nonnull.h +18 -0
- data/vendor/prism/include/prism/compiler/unused.h +18 -0
- data/vendor/prism/include/prism/constant_pool.h +106 -0
- data/vendor/prism/include/prism/diagnostic.h +55 -402
- data/vendor/prism/include/prism/errors_format.h +61 -0
- data/vendor/prism/include/prism/excludes.h +29 -0
- data/vendor/prism/include/prism/integer.h +41 -0
- data/vendor/prism/include/prism/internal/allocator.h +68 -0
- data/vendor/prism/include/prism/internal/allocator_debug.h +88 -0
- data/vendor/prism/include/prism/internal/arena.h +108 -0
- data/vendor/prism/include/prism/internal/bit.h +42 -0
- data/vendor/prism/include/prism/internal/buffer.h +94 -0
- data/vendor/prism/include/prism/internal/char.h +145 -0
- data/vendor/prism/include/prism/internal/comments.h +54 -0
- data/vendor/prism/include/prism/internal/constant_pool.h +152 -0
- data/vendor/prism/include/prism/internal/diagnostic.h +389 -0
- data/vendor/prism/include/prism/{encoding.h → internal/encoding.h} +27 -68
- data/vendor/prism/include/prism/internal/integer.h +68 -0
- data/vendor/prism/include/prism/internal/isinf.h +16 -0
- data/vendor/prism/include/prism/internal/line_offset_list.h +34 -0
- data/vendor/prism/include/prism/{util/pm_list.h → internal/list.h} +11 -52
- data/vendor/prism/include/prism/internal/magic_comments.h +23 -0
- data/vendor/prism/include/prism/internal/memchr.h +15 -0
- data/vendor/prism/include/prism/internal/node.h +42 -0
- data/vendor/prism/include/prism/internal/options.h +232 -0
- data/vendor/prism/include/prism/internal/parser.h +1015 -0
- data/vendor/prism/include/prism/internal/regexp.h +26 -0
- data/vendor/prism/include/prism/internal/serialize.h +39 -0
- data/vendor/prism/include/prism/internal/source.h +72 -0
- data/vendor/prism/include/prism/internal/static_literals.h +60 -0
- data/vendor/prism/include/prism/internal/stringy.h +30 -0
- data/vendor/prism/include/prism/{util/pm_strncasecmp.h → internal/strncasecmp.h} +3 -17
- data/vendor/prism/include/prism/{util/pm_strpbrk.h → internal/strpbrk.h} +7 -20
- data/vendor/prism/include/prism/internal/tokens.h +11 -0
- data/vendor/prism/include/prism/internal/xxh3.h +16 -0
- data/vendor/prism/include/prism/json.h +40 -0
- data/vendor/prism/include/prism/line_offset_list.h +69 -0
- data/vendor/prism/include/prism/magic_comments.h +53 -0
- data/vendor/prism/include/prism/node.h +59 -49
- data/vendor/prism/include/prism/node.hpp +272 -0
- data/vendor/prism/include/prism/node_type.hpp +38 -0
- data/vendor/prism/include/prism/options.h +154 -279
- data/vendor/prism/include/prism/options.hpp +43 -0
- data/vendor/prism/include/prism/parser.h +367 -870
- data/vendor/prism/include/prism/parser.hpp +274 -0
- data/vendor/prism/include/prism/prettyprint.h +14 -9
- data/vendor/prism/include/prism/serialize.h +123 -0
- data/vendor/prism/include/prism/source.h +163 -0
- data/vendor/prism/include/prism/stream.h +36 -0
- data/vendor/prism/include/prism/string_query.h +82 -0
- data/vendor/prism/include/prism/stringy.h +61 -0
- data/vendor/prism/include/prism/stringy.hpp +31 -0
- data/vendor/prism/include/prism/version.h +20 -3
- data/vendor/prism/include/prism.h +35 -320
- data/vendor/prism/include/prism.hpp +24 -0
- data/vendor/prism/src/arena.c +122 -0
- data/vendor/prism/src/{util/pm_buffer.c → buffer.c} +53 -21
- data/vendor/prism/src/{util/pm_char.c → char.c} +28 -57
- data/vendor/prism/src/comments.c +455 -0
- data/vendor/prism/src/constant_pool.c +406 -0
- data/vendor/prism/src/diagnostic.c +120 -68
- data/vendor/prism/src/encoding.c +8 -3
- data/vendor/prism/src/errors_format.c +519 -0
- data/vendor/prism/src/{util/pm_integer.c → integer.c} +38 -22
- data/vendor/prism/src/json.c +5733 -0
- data/vendor/prism/src/line_offset_list.c +100 -0
- data/vendor/prism/src/list.c +24 -0
- data/vendor/prism/src/{util/pm_memchr.c → memchr.c} +8 -6
- data/vendor/prism/src/node.c +3465 -7787
- data/vendor/prism/src/options.c +161 -54
- data/vendor/prism/src/parser.c +371 -0
- data/vendor/prism/src/prettyprint.c +421 -354
- data/vendor/prism/src/prism.c +8522 -7280
- data/vendor/prism/src/regexp.c +960 -45
- data/vendor/prism/src/serialize.c +2434 -2048
- data/vendor/prism/src/source.c +524 -0
- data/vendor/prism/src/static_literals.c +303 -360
- data/vendor/prism/src/string_query.c +180 -0
- data/vendor/prism/src/stringy.c +61 -0
- data/vendor/prism/src/{util/pm_strncasecmp.c → strncasecmp.c} +5 -4
- data/vendor/prism/src/strpbrk.c +447 -0
- data/vendor/prism/src/{token_type.c → tokens.c} +39 -18
- data/vendor/prism/src/xxh3.c +292 -0
- data/vendor/prism/templates/ext/prism/api_node.c.erb +58 -44
- data/vendor/prism/templates/include/prism/ast.h.erb +67 -17
- data/vendor/prism/templates/include/prism/ast.hpp.erb +31 -0
- data/vendor/prism/templates/include/prism/internal/diagnostic.h.erb +60 -0
- data/vendor/prism/templates/java/{org → api/src/main/java-templates/org/ruby_lang}/prism/AbstractNodeVisitor.java.erb +1 -1
- data/vendor/prism/templates/java/{org → api/src/main/java-templates/org/ruby_lang}/prism/Loader.java.erb +232 -133
- data/vendor/prism/templates/java/{org → api/src/main/java-templates/org/ruby_lang}/prism/Nodes.java.erb +62 -23
- data/vendor/prism/templates/javascript/src/deserialize.js.erb +153 -146
- data/vendor/prism/templates/javascript/src/nodes.js.erb +4 -9
- data/vendor/prism/templates/lib/prism/compiler.rb.erb +14 -5
- data/vendor/prism/templates/lib/prism/dispatcher.rb.erb +20 -12
- data/vendor/prism/templates/lib/prism/dot_visitor.rb.erb +37 -11
- data/vendor/prism/templates/lib/prism/dsl.rb.erb +43 -4
- data/vendor/prism/templates/lib/prism/inspect_visitor.rb.erb +26 -10
- data/vendor/prism/templates/lib/prism/mutation_compiler.rb.erb +5 -2
- data/vendor/prism/templates/lib/prism/node.rb.erb +283 -105
- data/vendor/prism/templates/lib/prism/reflection.rb.erb +11 -2
- data/vendor/prism/templates/lib/prism/serialize.rb.erb +291 -134
- data/vendor/prism/templates/lib/prism/visitor.rb.erb +18 -0
- data/vendor/prism/templates/src/diagnostic.c.erb +114 -63
- data/vendor/prism/templates/src/json.c.erb +130 -0
- data/vendor/prism/templates/src/node.c.erb +79 -236
- data/vendor/prism/templates/src/prettyprint.c.erb +24 -13
- data/vendor/prism/templates/src/serialize.c.erb +369 -183
- data/vendor/prism/templates/src/{token_type.c.erb → tokens.c.erb} +22 -11
- data/vendor/prism/templates/template.rb +193 -91
- metadata +100 -42
- data/vendor/prism/include/prism/defines.h +0 -260
- data/vendor/prism/include/prism/pack.h +0 -163
- data/vendor/prism/include/prism/regexp.h +0 -43
- data/vendor/prism/include/prism/static_literals.h +0 -121
- data/vendor/prism/include/prism/util/pm_buffer.h +0 -236
- data/vendor/prism/include/prism/util/pm_char.h +0 -204
- data/vendor/prism/include/prism/util/pm_constant_pool.h +0 -218
- data/vendor/prism/include/prism/util/pm_integer.h +0 -130
- data/vendor/prism/include/prism/util/pm_memchr.h +0 -29
- data/vendor/prism/include/prism/util/pm_newline_list.h +0 -113
- data/vendor/prism/include/prism/util/pm_string.h +0 -200
- data/vendor/prism/src/pack.c +0 -509
- data/vendor/prism/src/util/pm_constant_pool.c +0 -342
- data/vendor/prism/src/util/pm_list.c +0 -49
- data/vendor/prism/src/util/pm_newline_list.c +0 -125
- data/vendor/prism/src/util/pm_string.c +0 -381
- data/vendor/prism/src/util/pm_strpbrk.c +0 -206
- data/vendor/prism/templates/include/prism/diagnostic.h.erb +0 -130
- data/vendor/prism/templates/rbi/prism/dsl.rbi.erb +0 -68
- data/vendor/prism/templates/rbi/prism/node.rbi.erb +0 -167
- data/vendor/prism/templates/rbi/prism/visitor.rbi.erb +0 -18
- data/vendor/prism/templates/sig/prism/_private/dot_visitor.rbs.erb +0 -45
- data/vendor/prism/templates/sig/prism/dsl.rbs.erb +0 -31
- data/vendor/prism/templates/sig/prism/mutation_compiler.rbs.erb +0 -7
- data/vendor/prism/templates/sig/prism/node.rbs.erb +0 -136
- data/vendor/prism/templates/sig/prism/visitor.rbs.erb +0 -17
- data/vendor/prism/templates/sig/prism.rbs.erb +0 -92
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* :markup: markdown */
|
|
2
|
-
|
|
3
1
|
/*----------------------------------------------------------------------------*/
|
|
4
2
|
/* This file is generated by the templates/template.rb script and should not */
|
|
5
3
|
/* be modified manually. See */
|
|
@@ -8,9 +6,23 @@
|
|
|
8
6
|
/* template */
|
|
9
7
|
/*----------------------------------------------------------------------------*/
|
|
10
8
|
|
|
11
|
-
#include "prism/diagnostic.h"
|
|
9
|
+
#include "prism/internal/diagnostic.h"
|
|
10
|
+
|
|
11
|
+
#include "prism/compiler/assume.h"
|
|
12
|
+
#include "prism/compiler/inline.h"
|
|
13
|
+
|
|
14
|
+
#include "prism/internal/allocator.h"
|
|
15
|
+
#include "prism/internal/arena.h"
|
|
16
|
+
#include "prism/internal/list.h"
|
|
17
|
+
|
|
18
|
+
#include <assert.h>
|
|
19
|
+
#include <inttypes.h>
|
|
20
|
+
#include <stdarg.h>
|
|
21
|
+
#include <stdio.h>
|
|
22
|
+
#include <stdlib.h>
|
|
23
|
+
#include <string.h>
|
|
12
24
|
|
|
13
|
-
#define PM_DIAGNOSTIC_ID_MAX
|
|
25
|
+
#define PM_DIAGNOSTIC_ID_MAX 327
|
|
14
26
|
|
|
15
27
|
/** This struct holds the data for each diagnostic. */
|
|
16
28
|
typedef struct {
|
|
@@ -85,16 +97,16 @@ typedef struct {
|
|
|
85
97
|
* * `PM_WARNING_LEVEL_VERBOSE` - Warnings that appear with `-w`, as in `ruby -w -c -e 'code'`.
|
|
86
98
|
*/
|
|
87
99
|
static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
|
|
88
|
-
|
|
100
|
+
/* Special error that can be replaced */
|
|
89
101
|
[PM_ERR_CANNOT_PARSE_EXPRESSION] = { "cannot parse the expression", PM_ERROR_LEVEL_SYNTAX },
|
|
90
102
|
|
|
91
|
-
|
|
103
|
+
/* Errors that should raise argument errors */
|
|
92
104
|
[PM_ERR_INVALID_ENCODING_MAGIC_COMMENT] = { "unknown or invalid encoding in the magic comment", PM_ERROR_LEVEL_ARGUMENT },
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
/* Errors that should raise load errors */
|
|
95
107
|
[PM_ERR_SCRIPT_NOT_FOUND] = { "no Ruby script found in input", PM_ERROR_LEVEL_LOAD },
|
|
96
108
|
|
|
97
|
-
|
|
109
|
+
/* Errors that should raise syntax errors */
|
|
98
110
|
[PM_ERR_ALIAS_ARGUMENT] = { "invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", PM_ERROR_LEVEL_SYNTAX },
|
|
99
111
|
[PM_ERR_ALIAS_ARGUMENT_NUMBERED_REFERENCE] = { "invalid argument being passed to `alias`; can't make alias for the number variables", PM_ERROR_LEVEL_SYNTAX },
|
|
100
112
|
[PM_ERR_AMPAMPEQ_MULTI_ASSIGN] = { "unexpected `&&=` in a multiple assignment", PM_ERROR_LEVEL_SYNTAX },
|
|
@@ -112,6 +124,8 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
|
|
|
112
124
|
[PM_ERR_ARGUMENT_FORWARDING_UNBOUND] = { "unexpected `...` in an non-parenthesized call", PM_ERROR_LEVEL_SYNTAX },
|
|
113
125
|
[PM_ERR_ARGUMENT_NO_FORWARDING_AMPERSAND] = { "unexpected `&`; no anonymous block parameter", PM_ERROR_LEVEL_SYNTAX },
|
|
114
126
|
[PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES] = { "unexpected ... when the parent method is not forwarding", PM_ERROR_LEVEL_SYNTAX },
|
|
127
|
+
[PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES_LAMBDA] = { "unexpected ... in lambda argument", PM_ERROR_LEVEL_SYNTAX },
|
|
128
|
+
[PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES_BLOCK] = { "unexpected ... in block argument", PM_ERROR_LEVEL_SYNTAX },
|
|
115
129
|
[PM_ERR_ARGUMENT_NO_FORWARDING_STAR] = { "unexpected `*`; no anonymous rest parameter", PM_ERROR_LEVEL_SYNTAX },
|
|
116
130
|
[PM_ERR_ARGUMENT_NO_FORWARDING_STAR_STAR] = { "unexpected `**`; no anonymous keyword rest parameter", PM_ERROR_LEVEL_SYNTAX },
|
|
117
131
|
[PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT] = { "unexpected `*` splat argument after a `**` keyword splat argument", PM_ERROR_LEVEL_SYNTAX },
|
|
@@ -156,6 +170,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
|
|
|
156
170
|
[PM_ERR_DEF_ENDLESS] = { "could not parse the endless method body", PM_ERROR_LEVEL_SYNTAX },
|
|
157
171
|
[PM_ERR_DEF_ENDLESS_PARAMETERS] = { "could not parse the endless method parameters", PM_ERROR_LEVEL_SYNTAX },
|
|
158
172
|
[PM_ERR_DEF_ENDLESS_SETTER] = { "invalid method name; a setter method cannot be defined in an endless method definition", PM_ERROR_LEVEL_SYNTAX },
|
|
173
|
+
[PM_ERR_DEF_ENDLESS_DO_BLOCK] = { "unexpected `do` for block in an endless method definition", PM_ERROR_LEVEL_SYNTAX },
|
|
159
174
|
[PM_ERR_DEF_NAME] = { "unexpected %s; expected a method name", PM_ERROR_LEVEL_SYNTAX },
|
|
160
175
|
[PM_ERR_DEF_PARAMS_TERM] = { "expected a delimiter to close the parameters", PM_ERROR_LEVEL_SYNTAX },
|
|
161
176
|
[PM_ERR_DEF_PARAMS_TERM_PAREN] = { "unexpected %s; expected a `)` to close the parameters", PM_ERROR_LEVEL_SYNTAX },
|
|
@@ -337,13 +352,15 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
|
|
|
337
352
|
[PM_ERR_PATTERN_TERM_PAREN] = { "expected a `)` to close the pattern expression", PM_ERROR_LEVEL_SYNTAX },
|
|
338
353
|
[PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN] = { "unexpected `||=` in a multiple assignment", PM_ERROR_LEVEL_SYNTAX },
|
|
339
354
|
[PM_ERR_REGEXP_ENCODING_OPTION_MISMATCH] = { "regexp encoding option '%c' differs from source encoding '%s'", PM_ERROR_LEVEL_SYNTAX },
|
|
355
|
+
[PM_ERR_REGEXP_ESCAPED_NON_ASCII_IN_UTF8] = { "escaped non ASCII character in UTF-8 regexp: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
|
|
340
356
|
[PM_ERR_REGEXP_INCOMPAT_CHAR_ENCODING] = { "incompatible character encoding: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
|
|
341
|
-
[
|
|
357
|
+
[PM_ERR_REGEXP_INVALID_CHAR_PROPERTY] = { "invalid character property name {%.*s}: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
|
|
342
358
|
[PM_ERR_REGEXP_INVALID_UNICODE_RANGE] = { "invalid Unicode range: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
|
|
359
|
+
[PM_ERR_REGEXP_NON_ESCAPED_MBC] = { "/.../n has a non escaped non ASCII character in non ASCII-8BIT script: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
|
|
343
360
|
[PM_ERR_REGEXP_PARSE_ERROR] = { "%s", PM_ERROR_LEVEL_SYNTAX },
|
|
344
361
|
[PM_ERR_REGEXP_UNKNOWN_OPTIONS] = { "unknown regexp %s - %.*s", PM_ERROR_LEVEL_SYNTAX },
|
|
345
362
|
[PM_ERR_REGEXP_TERM] = { "unterminated regexp meets end of file; expected a closing delimiter", PM_ERROR_LEVEL_SYNTAX },
|
|
346
|
-
[PM_ERR_REGEXP_UTF8_CHAR_NON_UTF8_REGEXP] = { "UTF-8 character in non UTF-8 regexp:
|
|
363
|
+
[PM_ERR_REGEXP_UTF8_CHAR_NON_UTF8_REGEXP] = { "UTF-8 character in non UTF-8 regexp: /%.*s/", PM_ERROR_LEVEL_SYNTAX },
|
|
347
364
|
[PM_ERR_RESCUE_EXPRESSION] = { "expected a rescued expression", PM_ERROR_LEVEL_SYNTAX },
|
|
348
365
|
[PM_ERR_RESCUE_MODIFIER_VALUE] = { "expected a value after the `rescue` modifier", PM_ERROR_LEVEL_SYNTAX },
|
|
349
366
|
[PM_ERR_RESCUE_TERM] = { "expected a closing delimiter for the `rescue` clause", PM_ERROR_LEVEL_SYNTAX },
|
|
@@ -358,7 +375,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
|
|
|
358
375
|
[PM_ERR_STRING_INTERPOLATED_TERM] = { "unterminated string; expected a closing delimiter for the interpolated string", PM_ERROR_LEVEL_SYNTAX },
|
|
359
376
|
[PM_ERR_STRING_LITERAL_EOF] = { "unterminated string meets end of file", PM_ERROR_LEVEL_SYNTAX },
|
|
360
377
|
[PM_ERR_STRING_LITERAL_TERM] = { "unexpected %s, expected a string literal terminator", PM_ERROR_LEVEL_SYNTAX },
|
|
361
|
-
[PM_ERR_SYMBOL_INVALID] = { "invalid symbol", PM_ERROR_LEVEL_SYNTAX },
|
|
378
|
+
[PM_ERR_SYMBOL_INVALID] = { "invalid symbol", PM_ERROR_LEVEL_SYNTAX }, /* TODO expected symbol? prism.c ~9719 */
|
|
362
379
|
[PM_ERR_SYMBOL_TERM_DYNAMIC] = { "unterminated quoted string; expected a closing delimiter for the dynamic symbol", PM_ERROR_LEVEL_SYNTAX },
|
|
363
380
|
[PM_ERR_SYMBOL_TERM_INTERPOLATED] = { "unterminated symbol; expected a closing delimiter for the interpolated symbol", PM_ERROR_LEVEL_SYNTAX },
|
|
364
381
|
[PM_ERR_TERNARY_COLON] = { "expected a `:` after the true expression of a ternary operator", PM_ERROR_LEVEL_SYNTAX },
|
|
@@ -385,7 +402,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
|
|
|
385
402
|
[PM_ERR_WRITE_TARGET_UNEXPECTED] = { "unexpected write target", PM_ERROR_LEVEL_SYNTAX },
|
|
386
403
|
[PM_ERR_XSTRING_TERM] = { "expected a closing delimiter for the `%x` or backtick string", PM_ERROR_LEVEL_SYNTAX },
|
|
387
404
|
|
|
388
|
-
|
|
405
|
+
/* Warnings */
|
|
389
406
|
[PM_WARN_AMBIGUOUS_BINARY_OPERATOR] = { "'%s' after local variable or literal is interpreted as binary operator even though it seems like %s", PM_WARNING_LEVEL_VERBOSE },
|
|
390
407
|
[PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS] = { "ambiguous first argument; put parentheses or a space even after `-` operator", PM_WARNING_LEVEL_VERBOSE },
|
|
391
408
|
[PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS] = { "ambiguous first argument; put parentheses or a space even after `+` operator", PM_WARNING_LEVEL_VERBOSE },
|
|
@@ -421,8 +438,8 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
|
|
|
421
438
|
/**
|
|
422
439
|
* Get the human-readable name of the given diagnostic ID.
|
|
423
440
|
*/
|
|
424
|
-
const char *
|
|
425
|
-
|
|
441
|
+
static const char *
|
|
442
|
+
pm_diagnostic_id_name(pm_diagnostic_id_t diag_id) {
|
|
426
443
|
switch (diag_id) {
|
|
427
444
|
case PM_ERR_ALIAS_ARGUMENT: return "alias_argument";
|
|
428
445
|
case PM_ERR_ALIAS_ARGUMENT_NUMBERED_REFERENCE: return "alias_argument_numbered_reference";
|
|
@@ -430,7 +447,6 @@ pm_diagnostic_id_human(pm_diagnostic_id_t diag_id) {
|
|
|
430
447
|
case PM_ERR_ARGUMENT_AFTER_BLOCK: return "argument_after_block";
|
|
431
448
|
case PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES: return "argument_after_forwarding_ellipses";
|
|
432
449
|
case PM_ERR_ARGUMENT_BARE_HASH: return "argument_bare_hash";
|
|
433
|
-
case PM_ERR_ARGUMENT_BLOCK_FORWARDING: return "argument_block_forwarding";
|
|
434
450
|
case PM_ERR_ARGUMENT_BLOCK_MULTI: return "argument_block_multi";
|
|
435
451
|
case PM_ERR_ARGUMENT_CONFLICT_AMPERSAND: return "argument_conflict_ampersand";
|
|
436
452
|
case PM_ERR_ARGUMENT_CONFLICT_STAR: return "argument_conflict_star";
|
|
@@ -442,6 +458,8 @@ pm_diagnostic_id_human(pm_diagnostic_id_t diag_id) {
|
|
|
442
458
|
case PM_ERR_ARGUMENT_FORWARDING_UNBOUND: return "argument_forwarding_unbound";
|
|
443
459
|
case PM_ERR_ARGUMENT_NO_FORWARDING_AMPERSAND: return "argument_no_forwarding_ampersand";
|
|
444
460
|
case PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES: return "argument_no_forwarding_ellipses";
|
|
461
|
+
case PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES_LAMBDA: return "argument_no_forwarding_ellipses_lambda";
|
|
462
|
+
case PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES_BLOCK: return "argument_no_forwarding_ellipses_block";
|
|
445
463
|
case PM_ERR_ARGUMENT_NO_FORWARDING_STAR: return "argument_no_forwarding_star";
|
|
446
464
|
case PM_ERR_ARGUMENT_NO_FORWARDING_STAR_STAR: return "argument_no_forwarding_star_star";
|
|
447
465
|
case PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT: return "argument_splat_after_assoc_splat";
|
|
@@ -487,6 +505,7 @@ pm_diagnostic_id_human(pm_diagnostic_id_t diag_id) {
|
|
|
487
505
|
case PM_ERR_DEF_ENDLESS: return "def_endless";
|
|
488
506
|
case PM_ERR_DEF_ENDLESS_PARAMETERS: return "def_endless_parameters";
|
|
489
507
|
case PM_ERR_DEF_ENDLESS_SETTER: return "def_endless_setter";
|
|
508
|
+
case PM_ERR_DEF_ENDLESS_DO_BLOCK: return "def_endless_do_block";
|
|
490
509
|
case PM_ERR_DEF_NAME: return "def_name";
|
|
491
510
|
case PM_ERR_DEF_PARAMS_TERM: return "def_params_term";
|
|
492
511
|
case PM_ERR_DEF_PARAMS_TERM_PAREN: return "def_params_term_paren";
|
|
@@ -520,7 +539,6 @@ pm_diagnostic_id_human(pm_diagnostic_id_t diag_id) {
|
|
|
520
539
|
case PM_ERR_EXPECT_EXPRESSION_AFTER_LPAREN: return "expect_expression_after_lparen";
|
|
521
540
|
case PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR: return "expect_expression_after_operator";
|
|
522
541
|
case PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ: return "expect_expression_after_pipepipeeq";
|
|
523
|
-
case PM_ERR_EXPECT_EXPRESSION_AFTER_QUESTION: return "expect_expression_after_question";
|
|
524
542
|
case PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT: return "expect_expression_after_splat";
|
|
525
543
|
case PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH: return "expect_expression_after_splat_hash";
|
|
526
544
|
case PM_ERR_EXPECT_EXPRESSION_AFTER_STAR: return "expect_expression_after_star";
|
|
@@ -670,7 +688,9 @@ pm_diagnostic_id_human(pm_diagnostic_id_t diag_id) {
|
|
|
670
688
|
case PM_ERR_PATTERN_TERM_PAREN: return "pattern_term_paren";
|
|
671
689
|
case PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN: return "pipepipeeq_multi_assign";
|
|
672
690
|
case PM_ERR_REGEXP_ENCODING_OPTION_MISMATCH: return "regexp_encoding_option_mismatch";
|
|
691
|
+
case PM_ERR_REGEXP_ESCAPED_NON_ASCII_IN_UTF8: return "regexp_escaped_non_ascii_in_utf8";
|
|
673
692
|
case PM_ERR_REGEXP_INCOMPAT_CHAR_ENCODING: return "regexp_incompat_char_encoding";
|
|
693
|
+
case PM_ERR_REGEXP_INVALID_CHAR_PROPERTY: return "regexp_invalid_char_property";
|
|
674
694
|
case PM_ERR_REGEXP_INVALID_UNICODE_RANGE: return "regexp_invalid_unicode_range";
|
|
675
695
|
case PM_ERR_REGEXP_NON_ESCAPED_MBC: return "regexp_non_escaped_mbc";
|
|
676
696
|
case PM_ERR_REGEXP_PARSE_ERROR: return "regexp_parse_error";
|
|
@@ -754,9 +774,10 @@ pm_diagnostic_id_human(pm_diagnostic_id_t diag_id) {
|
|
|
754
774
|
return "";
|
|
755
775
|
}
|
|
756
776
|
|
|
757
|
-
static
|
|
758
|
-
|
|
777
|
+
static PRISM_INLINE const char *
|
|
778
|
+
pm_diagnostic_id_message(pm_diagnostic_id_t diag_id) {
|
|
759
779
|
assert(diag_id < PM_DIAGNOSTIC_ID_MAX);
|
|
780
|
+
PRISM_ASSUME(diag_id < PM_DIAGNOSTIC_ID_MAX);
|
|
760
781
|
|
|
761
782
|
const char *message = diagnostic_messages[diag_id].message;
|
|
762
783
|
assert(message);
|
|
@@ -764,91 +785,122 @@ pm_diagnostic_message(pm_diagnostic_id_t diag_id) {
|
|
|
764
785
|
return message;
|
|
765
786
|
}
|
|
766
787
|
|
|
767
|
-
static
|
|
768
|
-
|
|
788
|
+
static PRISM_INLINE uint8_t
|
|
789
|
+
pm_diagnostic_id_level(pm_diagnostic_id_t diag_id) {
|
|
769
790
|
assert(diag_id < PM_DIAGNOSTIC_ID_MAX);
|
|
791
|
+
PRISM_ASSUME(diag_id < PM_DIAGNOSTIC_ID_MAX);
|
|
770
792
|
|
|
771
793
|
return (uint8_t) diagnostic_messages[diag_id].level;
|
|
772
794
|
}
|
|
773
795
|
|
|
796
|
+
/**
|
|
797
|
+
* Get the type of the given diagnostic.
|
|
798
|
+
*/
|
|
799
|
+
const char *
|
|
800
|
+
pm_diagnostic_type(const pm_diagnostic_t *diagnostic) {
|
|
801
|
+
return pm_diagnostic_id_name(diagnostic->diag_id);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Get the location of the given diagnostic.
|
|
806
|
+
*/
|
|
807
|
+
pm_location_t
|
|
808
|
+
pm_diagnostic_location(const pm_diagnostic_t *diagnostic) {
|
|
809
|
+
return diagnostic->location;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/**
|
|
813
|
+
* Get the message of the given diagnostic.
|
|
814
|
+
*/
|
|
815
|
+
const char *
|
|
816
|
+
pm_diagnostic_message(const pm_diagnostic_t *diagnostic) {
|
|
817
|
+
return diagnostic->message;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Get the error level associated with the given diagnostic.
|
|
822
|
+
*/
|
|
823
|
+
pm_error_level_t
|
|
824
|
+
pm_diagnostic_error_level(const pm_diagnostic_t *diagnostic) {
|
|
825
|
+
return (pm_error_level_t) pm_diagnostic_id_level(diagnostic->diag_id);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Get the warning level associated with the given diagnostic.
|
|
830
|
+
*/
|
|
831
|
+
pm_warning_level_t
|
|
832
|
+
pm_diagnostic_warning_level(const pm_diagnostic_t *diagnostic) {
|
|
833
|
+
return (pm_warning_level_t) pm_diagnostic_id_level(diagnostic->diag_id);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/**
|
|
837
|
+
* Get the diagnostic that follows the given diagnostic.
|
|
838
|
+
*/
|
|
839
|
+
const pm_diagnostic_t *
|
|
840
|
+
pm_diagnostic_next(const pm_diagnostic_t *diagnostic) {
|
|
841
|
+
return (const pm_diagnostic_t *) diagnostic->node.next;
|
|
842
|
+
}
|
|
843
|
+
|
|
774
844
|
/**
|
|
775
845
|
* Append an error to the given list of diagnostic.
|
|
776
846
|
*/
|
|
777
|
-
|
|
778
|
-
pm_diagnostic_list_append(pm_list_t *list,
|
|
779
|
-
pm_diagnostic_t *diagnostic = (pm_diagnostic_t *)
|
|
780
|
-
if (diagnostic == NULL) return false;
|
|
847
|
+
void
|
|
848
|
+
pm_diagnostic_list_append(pm_arena_t *arena, pm_list_t *list, uint32_t start, uint32_t length, pm_diagnostic_id_t diag_id) {
|
|
849
|
+
pm_diagnostic_t *diagnostic = (pm_diagnostic_t *) pm_arena_zalloc(arena, sizeof(pm_diagnostic_t), PRISM_ALIGNOF(pm_diagnostic_t));
|
|
781
850
|
|
|
782
851
|
*diagnostic = (pm_diagnostic_t) {
|
|
783
|
-
.location = { start,
|
|
852
|
+
.location = { .start = start, .length = length },
|
|
784
853
|
.diag_id = diag_id,
|
|
785
|
-
.message =
|
|
786
|
-
.
|
|
787
|
-
.level = pm_diagnostic_level(diag_id)
|
|
854
|
+
.message = pm_diagnostic_id_message(diag_id),
|
|
855
|
+
.level = pm_diagnostic_id_level(diag_id)
|
|
788
856
|
};
|
|
789
857
|
|
|
790
858
|
pm_list_append(list, (pm_list_node_t *) diagnostic);
|
|
791
|
-
return true;
|
|
792
859
|
}
|
|
793
860
|
|
|
794
861
|
/**
|
|
795
862
|
* Append a diagnostic to the given list of diagnostics that is using a format
|
|
796
863
|
* string for its message.
|
|
797
864
|
*/
|
|
798
|
-
|
|
799
|
-
pm_diagnostic_list_append_format(pm_list_t *list,
|
|
865
|
+
void
|
|
866
|
+
pm_diagnostic_list_append_format(pm_arena_t *arena, pm_list_t *list, uint32_t start, uint32_t length, pm_diagnostic_id_t diag_id, ...) {
|
|
867
|
+
/* Format the message into a buffer on the stack, which nearly every message
|
|
868
|
+
* fits in. The result is the length of the whole message whether or not it
|
|
869
|
+
* fit, so a single pass both formats the message and sizes it. */
|
|
870
|
+
char stack[256];
|
|
871
|
+
|
|
800
872
|
va_list arguments;
|
|
801
873
|
va_start(arguments, diag_id);
|
|
802
874
|
|
|
803
|
-
const char *format =
|
|
804
|
-
int result = vsnprintf(
|
|
875
|
+
const char *format = pm_diagnostic_id_message(diag_id);
|
|
876
|
+
int result = vsnprintf(stack, sizeof(stack), format, arguments);
|
|
805
877
|
va_end(arguments);
|
|
806
878
|
|
|
807
879
|
if (result < 0) {
|
|
808
|
-
return
|
|
880
|
+
return;
|
|
809
881
|
}
|
|
810
882
|
|
|
811
|
-
pm_diagnostic_t *diagnostic = (pm_diagnostic_t *)
|
|
812
|
-
if (diagnostic == NULL) {
|
|
813
|
-
return false;
|
|
814
|
-
}
|
|
883
|
+
pm_diagnostic_t *diagnostic = (pm_diagnostic_t *) pm_arena_zalloc(arena, sizeof(pm_diagnostic_t), PRISM_ALIGNOF(pm_diagnostic_t));
|
|
815
884
|
|
|
816
|
-
size_t
|
|
817
|
-
char *message = (char *)
|
|
818
|
-
if (message == NULL) {
|
|
819
|
-
xfree(diagnostic);
|
|
820
|
-
return false;
|
|
821
|
-
}
|
|
885
|
+
size_t message_length = (size_t) (result + 1);
|
|
886
|
+
char *message = (char *) pm_arena_alloc(arena, message_length, 1);
|
|
822
887
|
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
888
|
+
if (message_length <= sizeof(stack)) {
|
|
889
|
+
memcpy(message, stack, message_length);
|
|
890
|
+
} else {
|
|
891
|
+
/* The message was cut off on the stack, so format it again into an
|
|
892
|
+
* allocation of the right size. */
|
|
893
|
+
va_start(arguments, diag_id);
|
|
894
|
+
vsnprintf(message, message_length, format, arguments);
|
|
895
|
+
va_end(arguments);
|
|
896
|
+
}
|
|
826
897
|
|
|
827
898
|
*diagnostic = (pm_diagnostic_t) {
|
|
828
|
-
.location = { start,
|
|
899
|
+
.location = { .start = start, .length = length },
|
|
829
900
|
.diag_id = diag_id,
|
|
830
901
|
.message = message,
|
|
831
|
-
.
|
|
832
|
-
.level = pm_diagnostic_level(diag_id)
|
|
902
|
+
.level = pm_diagnostic_id_level(diag_id)
|
|
833
903
|
};
|
|
834
904
|
|
|
835
905
|
pm_list_append(list, (pm_list_node_t *) diagnostic);
|
|
836
|
-
return true;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
/**
|
|
840
|
-
* Deallocate the internal state of the given diagnostic list.
|
|
841
|
-
*/
|
|
842
|
-
void
|
|
843
|
-
pm_diagnostic_list_free(pm_list_t *list) {
|
|
844
|
-
pm_diagnostic_t *node = (pm_diagnostic_t *) list->head;
|
|
845
|
-
|
|
846
|
-
while (node != NULL) {
|
|
847
|
-
pm_diagnostic_t *next = (pm_diagnostic_t *) node->node.next;
|
|
848
|
-
|
|
849
|
-
if (node->owned) xfree((void *) node->message);
|
|
850
|
-
xfree(node);
|
|
851
|
-
|
|
852
|
-
node = next;
|
|
853
|
-
}
|
|
854
906
|
}
|
data/vendor/prism/src/encoding.c
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
#include "prism/encoding.h"
|
|
1
|
+
#include "prism/internal/encoding.h"
|
|
2
|
+
|
|
3
|
+
#include "prism/compiler/unused.h"
|
|
4
|
+
#include "prism/internal/strncasecmp.h"
|
|
5
|
+
|
|
6
|
+
#include <assert.h>
|
|
2
7
|
|
|
3
8
|
typedef uint32_t pm_unicode_codepoint_t;
|
|
4
9
|
|
|
@@ -4089,7 +4094,7 @@ pm_encoding_ascii_isupper_char(const uint8_t *b, ptrdiff_t n) {
|
|
|
4089
4094
|
* matter what the codepoint, so this function is shared between them.
|
|
4090
4095
|
*/
|
|
4091
4096
|
static size_t
|
|
4092
|
-
pm_encoding_single_char_width(
|
|
4097
|
+
pm_encoding_single_char_width(PRISM_UNUSED const uint8_t *b, PRISM_UNUSED ptrdiff_t n) {
|
|
4093
4098
|
return 1;
|
|
4094
4099
|
}
|
|
4095
4100
|
|
|
@@ -4110,7 +4115,7 @@ pm_encoding_euc_jp_char_width(const uint8_t *b, ptrdiff_t n) {
|
|
|
4110
4115
|
}
|
|
4111
4116
|
|
|
4112
4117
|
// These are the triple byte characters.
|
|
4113
|
-
if ((n > 2) && (b[0] == 0x8F) && (b[1] >= 0xA1 && b[
|
|
4118
|
+
if ((n > 2) && (b[0] == 0x8F) && (b[1] >= 0xA1 && b[1] <= 0xFE) && (b[2] >= 0xA1 && b[2] <= 0xFE)) {
|
|
4114
4119
|
return 3;
|
|
4115
4120
|
}
|
|
4116
4121
|
|