prism 0.17.1 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +60 -1
- data/Makefile +5 -5
- data/README.md +4 -3
- data/config.yml +214 -68
- data/docs/build_system.md +6 -6
- data/docs/building.md +10 -3
- data/docs/configuration.md +11 -9
- data/docs/encoding.md +92 -88
- data/docs/heredocs.md +1 -1
- data/docs/javascript.md +29 -1
- data/docs/local_variable_depth.md +229 -0
- data/docs/ruby_api.md +16 -0
- data/docs/serialization.md +18 -13
- data/ext/prism/api_node.c +411 -240
- data/ext/prism/extconf.rb +97 -127
- data/ext/prism/extension.c +97 -33
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +377 -159
- data/include/prism/defines.h +17 -0
- data/include/prism/diagnostic.h +38 -6
- data/include/prism/{enc/pm_encoding.h → encoding.h} +126 -64
- data/include/prism/options.h +2 -2
- data/include/prism/parser.h +62 -36
- data/include/prism/regexp.h +2 -2
- data/include/prism/util/pm_buffer.h +9 -1
- data/include/prism/util/pm_memchr.h +2 -2
- data/include/prism/util/pm_strpbrk.h +3 -3
- data/include/prism/version.h +3 -3
- data/include/prism.h +13 -15
- data/lib/prism/compiler.rb +15 -3
- data/lib/prism/debug.rb +13 -4
- data/lib/prism/desugar_compiler.rb +4 -3
- data/lib/prism/dispatcher.rb +70 -14
- data/lib/prism/dot_visitor.rb +4612 -0
- data/lib/prism/dsl.rb +77 -57
- data/lib/prism/ffi.rb +19 -6
- data/lib/prism/lex_compat.rb +19 -9
- data/lib/prism/mutation_compiler.rb +26 -6
- data/lib/prism/node.rb +1314 -522
- data/lib/prism/node_ext.rb +102 -19
- data/lib/prism/parse_result.rb +58 -27
- data/lib/prism/ripper_compat.rb +49 -34
- data/lib/prism/serialize.rb +251 -227
- data/lib/prism/visitor.rb +15 -3
- data/lib/prism.rb +21 -4
- data/prism.gemspec +7 -9
- data/rbi/prism.rbi +688 -284
- data/rbi/prism_static.rbi +3 -0
- data/sig/prism.rbs +426 -156
- data/sig/prism_static.rbs +1 -0
- data/src/diagnostic.c +280 -216
- data/src/encoding.c +5137 -0
- data/src/node.c +99 -21
- data/src/options.c +21 -2
- data/src/prettyprint.c +1743 -1241
- data/src/prism.c +1774 -831
- data/src/regexp.c +15 -15
- data/src/serialize.c +261 -164
- data/src/util/pm_buffer.c +10 -1
- data/src/util/pm_memchr.c +1 -1
- data/src/util/pm_strpbrk.c +4 -4
- metadata +8 -10
- data/src/enc/pm_big5.c +0 -53
- data/src/enc/pm_euc_jp.c +0 -59
- data/src/enc/pm_gbk.c +0 -62
- data/src/enc/pm_shift_jis.c +0 -57
- data/src/enc/pm_tables.c +0 -743
- data/src/enc/pm_unicode.c +0 -2369
- data/src/enc/pm_windows_31j.c +0 -57
data/src/regexp.c
CHANGED
@@ -20,14 +20,14 @@ typedef struct {
|
|
20
20
|
bool encoding_changed;
|
21
21
|
|
22
22
|
/** The encoding of the source. */
|
23
|
-
pm_encoding_t *encoding;
|
23
|
+
const pm_encoding_t *encoding;
|
24
24
|
} pm_regexp_parser_t;
|
25
25
|
|
26
26
|
/**
|
27
27
|
* This initializes a new parser with the given source.
|
28
28
|
*/
|
29
29
|
static void
|
30
|
-
pm_regexp_parser_init(pm_regexp_parser_t *parser, const uint8_t *start, const uint8_t *end, pm_string_list_t *named_captures, bool encoding_changed, pm_encoding_t *encoding) {
|
30
|
+
pm_regexp_parser_init(pm_regexp_parser_t *parser, const uint8_t *start, const uint8_t *end, pm_string_list_t *named_captures, bool encoding_changed, const pm_encoding_t *encoding) {
|
31
31
|
*parser = (pm_regexp_parser_t) {
|
32
32
|
.start = start,
|
33
33
|
.cursor = start,
|
@@ -116,18 +116,18 @@ pm_regexp_char_find(pm_regexp_parser_t *parser, uint8_t value) {
|
|
116
116
|
* The properly track everything, we're going to build a little state machine.
|
117
117
|
* It looks something like the following:
|
118
118
|
*
|
119
|
-
*
|
120
|
-
*
|
121
|
-
*
|
122
|
-
*
|
123
|
-
*
|
124
|
-
*
|
125
|
-
*
|
126
|
-
*
|
127
|
-
*
|
128
|
-
*
|
129
|
-
*
|
130
|
-
*
|
119
|
+
* +-------+ +---------+ ------------+
|
120
|
+
* ---- lbrace ---> | start | ---- digit ---> | minimum | |
|
121
|
+
* +-------+ +---------+ <--- digit -+
|
122
|
+
* | | |
|
123
|
+
* +-------+ | | rbrace
|
124
|
+
* | comma | <----- comma +---- comma -------+ |
|
125
|
+
* +-------+ V V
|
126
|
+
* | +---------+ +---------+
|
127
|
+
* +-- digit --> | maximum | -- rbrace --> || final ||
|
128
|
+
* +---------+ +---------+
|
129
|
+
* | ^
|
130
|
+
* +- digit -+
|
131
131
|
*
|
132
132
|
* Note that by the time we've hit this function, the lbrace has already been
|
133
133
|
* consumed so we're in the start state.
|
@@ -631,7 +631,7 @@ pm_regexp_parse_pattern(pm_regexp_parser_t *parser) {
|
|
631
631
|
* groups.
|
632
632
|
*/
|
633
633
|
PRISM_EXPORTED_FUNCTION bool
|
634
|
-
pm_regexp_named_capture_group_names(const uint8_t *source, size_t size, pm_string_list_t *named_captures, bool encoding_changed, pm_encoding_t *encoding) {
|
634
|
+
pm_regexp_named_capture_group_names(const uint8_t *source, size_t size, pm_string_list_t *named_captures, bool encoding_changed, const pm_encoding_t *encoding) {
|
635
635
|
pm_regexp_parser_t parser;
|
636
636
|
pm_regexp_parser_init(&parser, source, source + size, named_captures, encoding_changed, encoding);
|
637
637
|
return pm_regexp_parse_pattern(&parser);
|