prism 0.24.0 → 0.26.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BSDmakefile +58 -0
- data/CHANGELOG.md +69 -1
- data/Makefile +22 -16
- data/README.md +45 -6
- data/config.yml +510 -4
- data/docs/build_system.md +31 -0
- data/docs/configuration.md +3 -0
- data/docs/cruby_compilation.md +1 -1
- data/docs/parser_translation.md +14 -9
- data/docs/releasing.md +7 -9
- data/docs/ripper_translation.md +50 -0
- data/docs/ruby_api.md +1 -0
- data/docs/serialization.md +26 -5
- data/ext/prism/api_node.c +911 -815
- data/ext/prism/api_pack.c +9 -0
- data/ext/prism/extconf.rb +34 -13
- data/ext/prism/extension.c +341 -68
- data/ext/prism/extension.h +5 -4
- data/include/prism/ast.h +213 -64
- data/include/prism/defines.h +106 -2
- data/include/prism/diagnostic.h +146 -72
- data/include/prism/encoding.h +22 -4
- data/include/prism/node.h +93 -0
- data/include/prism/options.h +82 -7
- data/include/prism/pack.h +11 -0
- data/include/prism/parser.h +203 -54
- data/include/prism/prettyprint.h +8 -0
- data/include/prism/static_literals.h +118 -0
- data/include/prism/util/pm_buffer.h +65 -2
- data/include/prism/util/pm_constant_pool.h +18 -1
- data/include/prism/util/pm_integer.h +119 -0
- data/include/prism/util/pm_list.h +1 -1
- data/include/prism/util/pm_newline_list.h +8 -0
- data/include/prism/util/pm_string.h +26 -2
- data/include/prism/version.h +2 -2
- data/include/prism.h +59 -1
- data/lib/prism/compiler.rb +8 -1
- data/lib/prism/debug.rb +46 -3
- data/lib/prism/desugar_compiler.rb +4 -2
- data/lib/prism/dispatcher.rb +29 -0
- data/lib/prism/dot_visitor.rb +87 -16
- data/lib/prism/dsl.rb +24 -12
- data/lib/prism/ffi.rb +77 -12
- data/lib/prism/lex_compat.rb +17 -15
- data/lib/prism/mutation_compiler.rb +11 -0
- data/lib/prism/node.rb +2112 -2499
- data/lib/prism/node_ext.rb +77 -29
- data/lib/prism/pack.rb +4 -0
- data/lib/prism/parse_result/comments.rb +34 -17
- data/lib/prism/parse_result/newlines.rb +3 -1
- data/lib/prism/parse_result.rb +83 -32
- data/lib/prism/pattern.rb +16 -4
- data/lib/prism/polyfill/string.rb +12 -0
- data/lib/prism/reflection.rb +421 -0
- data/lib/prism/serialize.rb +450 -102
- data/lib/prism/translation/parser/compiler.rb +189 -50
- data/lib/prism/translation/parser/lexer.rb +103 -22
- data/lib/prism/translation/parser/rubocop.rb +41 -13
- data/lib/prism/translation/parser.rb +119 -7
- data/lib/prism/translation/parser33.rb +1 -1
- data/lib/prism/translation/parser34.rb +1 -1
- data/lib/prism/translation/ripper/sexp.rb +125 -0
- data/lib/prism/translation/ripper/shim.rb +5 -0
- data/lib/prism/translation/ripper.rb +3212 -462
- data/lib/prism/translation/ruby_parser.rb +35 -18
- data/lib/prism/translation.rb +3 -1
- data/lib/prism/visitor.rb +10 -0
- data/lib/prism.rb +9 -18
- data/prism.gemspec +39 -6
- data/rbi/prism/compiler.rbi +14 -0
- data/rbi/prism/desugar_compiler.rbi +5 -0
- data/rbi/prism/mutation_compiler.rbi +5 -0
- data/rbi/prism/node.rbi +8674 -0
- data/rbi/prism/node_ext.rbi +102 -0
- data/rbi/prism/parse_result.rbi +307 -0
- data/rbi/prism/reflection.rbi +64 -0
- data/rbi/prism/translation/parser/compiler.rbi +13 -0
- data/rbi/prism/translation/parser.rbi +11 -0
- data/rbi/prism/translation/parser33.rbi +6 -0
- data/rbi/prism/translation/parser34.rbi +6 -0
- data/rbi/prism/translation/ripper/ripper_compiler.rbi +5 -0
- data/rbi/prism/translation/ripper.rbi +25 -0
- data/rbi/prism/translation/ruby_parser.rbi +11 -0
- data/rbi/prism/visitor.rbi +470 -0
- data/rbi/prism.rbi +38 -7748
- data/sig/prism/compiler.rbs +9 -0
- data/sig/prism/dispatcher.rbs +16 -0
- data/sig/prism/dot_visitor.rbs +6 -0
- data/sig/prism/dsl.rbs +462 -0
- data/sig/prism/mutation_compiler.rbs +158 -0
- data/sig/prism/node.rbs +3538 -0
- data/sig/prism/node_ext.rbs +78 -0
- data/sig/prism/pack.rbs +43 -0
- data/sig/prism/parse_result.rbs +128 -0
- data/sig/prism/pattern.rbs +13 -0
- data/sig/prism/reflection.rbs +56 -0
- data/sig/prism/serialize.rbs +7 -0
- data/sig/prism/visitor.rbs +168 -0
- data/sig/prism.rbs +188 -4767
- data/src/diagnostic.c +597 -230
- data/src/encoding.c +211 -108
- data/src/node.c +7526 -447
- data/src/options.c +66 -31
- data/src/pack.c +33 -17
- data/src/prettyprint.c +1294 -1385
- data/src/prism.c +4015 -1149
- data/src/regexp.c +17 -2
- data/src/serialize.c +47 -28
- data/src/static_literals.c +552 -0
- data/src/token_type.c +4 -3
- data/src/util/pm_buffer.c +147 -20
- data/src/util/pm_char.c +4 -4
- data/src/util/pm_constant_pool.c +35 -11
- data/src/util/pm_integer.c +635 -0
- data/src/util/pm_list.c +1 -1
- data/src/util/pm_newline_list.c +14 -5
- data/src/util/pm_string.c +134 -5
- data/src/util/pm_string_list.c +2 -2
- metadata +41 -8
- data/docs/ripper.md +0 -36
- data/include/prism/util/pm_state_stack.h +0 -42
- data/rbi/prism_static.rbi +0 -207
- data/sig/prism_static.rbs +0 -201
- data/src/util/pm_state_stack.c +0 -25
data/ext/prism/api_pack.c
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
#include "prism/extension.h"
|
2
2
|
|
3
|
+
#ifdef PRISM_EXCLUDE_PACK
|
4
|
+
|
5
|
+
void
|
6
|
+
Init_prism_pack(void) {}
|
7
|
+
|
8
|
+
#else
|
9
|
+
|
3
10
|
static VALUE rb_cPrism;
|
4
11
|
static VALUE rb_cPrismPack;
|
5
12
|
static VALUE rb_cPrismPackDirective;
|
@@ -265,3 +272,5 @@ Init_prism_pack(void) {
|
|
265
272
|
pack_symbol = ID2SYM(rb_intern("pack"));
|
266
273
|
unpack_symbol = ID2SYM(rb_intern("unpack"));
|
267
274
|
}
|
275
|
+
|
276
|
+
#endif
|
data/ext/prism/extconf.rb
CHANGED
@@ -6,17 +6,24 @@ if ARGV.delete("--help")
|
|
6
6
|
|
7
7
|
Flags that are always valid:
|
8
8
|
|
9
|
-
--enable-debug
|
10
|
-
Enable debug
|
11
|
-
You may also
|
9
|
+
--enable-build-debug
|
10
|
+
Enable debug build.
|
11
|
+
You may also set the PRISM_BUILD_DEBUG environment variable.
|
12
|
+
|
13
|
+
--enable-build-minimal
|
14
|
+
Enable minimal build.
|
15
|
+
You may also set the PRISM_BUILD_MINIMAL environment variable.
|
12
16
|
|
13
17
|
--help
|
14
18
|
Display this message.
|
15
19
|
|
16
20
|
Environment variables used:
|
17
21
|
|
18
|
-
|
19
|
-
Equivalent to `--enable-debug
|
22
|
+
PRISM_BUILD_DEBUG
|
23
|
+
Equivalent to `--enable-build-debug` when set, even if nil or blank.
|
24
|
+
|
25
|
+
PRISM_BUILD_MINIMAL
|
26
|
+
Equivalent to `--enable-build-minimal` when set, even if nil or blank.
|
20
27
|
|
21
28
|
TEXT
|
22
29
|
exit!(0)
|
@@ -33,17 +40,22 @@ def generate_templates
|
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
43
|
+
require "rbconfig"
|
44
|
+
|
36
45
|
# Runs `make` in the root directory of the project. Note that this is the
|
37
46
|
# `Makefile` for the overall project, not the `Makefile` that is being generated
|
38
47
|
# by this script.`
|
39
48
|
def make(target)
|
40
49
|
Dir.chdir(File.expand_path("../..", __dir__)) do
|
41
|
-
system(
|
50
|
+
system(
|
51
|
+
RbConfig::CONFIG.slice(*%w[SOEXT CPPFLAGS CFLAGS CC AR ARFLAGS MAKEDIRS RMALL]), # env
|
52
|
+
RUBY_PLATFORM.include?("openbsd") ? "gmake" : "make",
|
53
|
+
target,
|
54
|
+
exception: true
|
55
|
+
)
|
42
56
|
end
|
43
57
|
end
|
44
58
|
|
45
|
-
require "rbconfig"
|
46
|
-
|
47
59
|
# On non-CRuby we only need the shared library since we'll interface with it
|
48
60
|
# through FFI, so we'll build only that and not the C extension. We also avoid
|
49
61
|
# `require "mkmf"` as that prepends the LLVM toolchain to PATH on TruffleRuby,
|
@@ -71,13 +83,22 @@ unless find_header("prism/extension.h", File.expand_path("..", __dir__))
|
|
71
83
|
raise "prism/extension.h is required"
|
72
84
|
end
|
73
85
|
|
74
|
-
# If `--enable-debug
|
75
|
-
# `
|
76
|
-
# `
|
86
|
+
# If `--enable-build-debug` is passed to this script or the
|
87
|
+
# `PRISM_BUILD_DEBUG` environment variable is defined, we'll build with the
|
88
|
+
# `PRISM_BUILD_DEBUG` macro defined. This causes parse functions to
|
77
89
|
# duplicate their input so that they have clearly set bounds, which is useful
|
78
90
|
# for finding bugs that cause the parser to read off the end of the input.
|
79
|
-
if enable_config("debug
|
80
|
-
append_cflags("-
|
91
|
+
if enable_config("build-debug", ENV["PRISM_BUILD_DEBUG"] || false)
|
92
|
+
append_cflags("-DPRISM_BUILD_DEBUG")
|
93
|
+
end
|
94
|
+
|
95
|
+
# If `--enable-build-minimal` is passed to this script or the
|
96
|
+
# `PRISM_BUILD_MINIMAL` environment variable is defined, we'll build with the
|
97
|
+
# set of defines that comprise the minimal set. This causes the parser to be
|
98
|
+
# built with minimal features, necessary for stripping out functionality when
|
99
|
+
# the size of the final built artifact is a concern.
|
100
|
+
if enable_config("build-minimal", ENV["PRISM_BUILD_MINIMAL"] || false)
|
101
|
+
append_cflags("-DPRISM_BUILD_MINIMAL")
|
81
102
|
end
|
82
103
|
|
83
104
|
# By default, all symbols are hidden in the shared library.
|