prism 0.29.0 → 1.3.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 +115 -1
- data/CONTRIBUTING.md +0 -4
- data/Makefile +1 -1
- data/README.md +4 -0
- data/config.yml +920 -148
- data/docs/build_system.md +8 -11
- data/docs/fuzzing.md +1 -1
- data/docs/parsing_rules.md +4 -1
- data/docs/relocation.md +34 -0
- data/docs/ripper_translation.md +22 -0
- data/docs/serialization.md +3 -0
- data/ext/prism/api_node.c +2863 -2079
- data/ext/prism/extconf.rb +14 -37
- data/ext/prism/extension.c +241 -391
- data/ext/prism/extension.h +2 -2
- data/include/prism/ast.h +2156 -453
- data/include/prism/defines.h +58 -7
- data/include/prism/diagnostic.h +24 -6
- data/include/prism/node.h +0 -21
- data/include/prism/options.h +94 -3
- data/include/prism/parser.h +82 -40
- data/include/prism/regexp.h +18 -8
- data/include/prism/static_literals.h +3 -2
- data/include/prism/util/pm_char.h +1 -2
- data/include/prism/util/pm_constant_pool.h +0 -8
- data/include/prism/util/pm_integer.h +22 -15
- data/include/prism/util/pm_newline_list.h +11 -0
- data/include/prism/util/pm_string.h +28 -12
- data/include/prism/version.h +3 -3
- data/include/prism.h +47 -11
- data/lib/prism/compiler.rb +3 -0
- data/lib/prism/desugar_compiler.rb +111 -74
- data/lib/prism/dispatcher.rb +16 -1
- data/lib/prism/dot_visitor.rb +55 -34
- data/lib/prism/dsl.rb +660 -468
- data/lib/prism/ffi.rb +113 -8
- data/lib/prism/inspect_visitor.rb +296 -64
- data/lib/prism/lex_compat.rb +1 -1
- data/lib/prism/mutation_compiler.rb +11 -6
- data/lib/prism/node.rb +4262 -5023
- data/lib/prism/node_ext.rb +91 -14
- data/lib/prism/parse_result/comments.rb +0 -7
- data/lib/prism/parse_result/errors.rb +65 -0
- data/lib/prism/parse_result/newlines.rb +101 -11
- data/lib/prism/parse_result.rb +183 -6
- data/lib/prism/reflection.rb +12 -10
- data/lib/prism/relocation.rb +504 -0
- data/lib/prism/serialize.rb +496 -609
- data/lib/prism/string_query.rb +30 -0
- data/lib/prism/translation/parser/compiler.rb +185 -155
- data/lib/prism/translation/parser/lexer.rb +26 -4
- data/lib/prism/translation/parser.rb +9 -4
- data/lib/prism/translation/ripper.rb +23 -25
- data/lib/prism/translation/ruby_parser.rb +86 -17
- data/lib/prism/visitor.rb +3 -0
- data/lib/prism.rb +6 -8
- data/prism.gemspec +9 -5
- data/rbi/prism/dsl.rbi +521 -0
- data/rbi/prism/node.rbi +1115 -1120
- data/rbi/prism/parse_result.rbi +29 -0
- data/rbi/prism/string_query.rbi +12 -0
- data/rbi/prism/visitor.rbi +3 -0
- data/rbi/prism.rbi +36 -30
- data/sig/prism/dsl.rbs +190 -303
- data/sig/prism/mutation_compiler.rbs +1 -0
- data/sig/prism/node.rbs +678 -632
- data/sig/prism/parse_result.rbs +22 -0
- data/sig/prism/relocation.rbs +185 -0
- data/sig/prism/string_query.rbs +11 -0
- data/sig/prism/visitor.rbs +1 -0
- data/sig/prism.rbs +103 -64
- data/src/diagnostic.c +64 -28
- data/src/node.c +502 -1739
- data/src/options.c +76 -27
- data/src/prettyprint.c +188 -112
- data/src/prism.c +3376 -2293
- data/src/regexp.c +208 -71
- data/src/serialize.c +182 -50
- data/src/static_literals.c +64 -85
- data/src/token_type.c +4 -4
- data/src/util/pm_char.c +1 -1
- data/src/util/pm_constant_pool.c +0 -8
- data/src/util/pm_integer.c +53 -25
- data/src/util/pm_newline_list.c +29 -0
- data/src/util/pm_string.c +131 -80
- data/src/util/pm_strpbrk.c +32 -6
- metadata +11 -7
- data/include/prism/util/pm_string_list.h +0 -44
- data/lib/prism/debug.rb +0 -249
- data/lib/prism/translation/parser/rubocop.rb +0 -73
- data/src/util/pm_string_list.c +0 -28
data/ext/prism/extconf.rb
CHANGED
@@ -50,7 +50,7 @@ def make(env, target)
|
|
50
50
|
Dir.chdir(File.expand_path("../..", __dir__)) do
|
51
51
|
system(
|
52
52
|
env,
|
53
|
-
RUBY_PLATFORM.
|
53
|
+
RUBY_PLATFORM.match?(/openbsd|freebsd/) ? "gmake" : "make",
|
54
54
|
target,
|
55
55
|
exception: true
|
56
56
|
)
|
@@ -70,26 +70,6 @@ if RUBY_ENGINE != "ruby"
|
|
70
70
|
return
|
71
71
|
end
|
72
72
|
|
73
|
-
# We're going to need to run `make` using prism's `Makefile`.
|
74
|
-
# We want to use the same toolchain (compiler, flags, etc) to compile libprism.a and
|
75
|
-
# the C extension since they will be linked together.
|
76
|
-
# The C extension uses RbConfig, which contains values from the toolchain that built the running Ruby.
|
77
|
-
env = RbConfig::CONFIG.slice("SOEXT", "CPPFLAGS", "CFLAGS", "CC", "AR", "ARFLAGS", "MAKEDIRS", "RMALL")
|
78
|
-
|
79
|
-
# It's possible that the Ruby that is being run wasn't actually compiled on this
|
80
|
-
# machine, in which case parts of RbConfig might be incorrect. In this case
|
81
|
-
# we'll need to do some additional checks and potentially fall back to defaults.
|
82
|
-
if env.key?("CC") && !File.exist?(env["CC"])
|
83
|
-
env.delete("CC")
|
84
|
-
env.delete("CFLAGS")
|
85
|
-
env.delete("CPPFLAGS")
|
86
|
-
end
|
87
|
-
|
88
|
-
if env.key?("AR") && !File.exist?(env["AR"])
|
89
|
-
env.delete("AR")
|
90
|
-
env.delete("ARFLAGS")
|
91
|
-
end
|
92
|
-
|
93
73
|
require "mkmf"
|
94
74
|
|
95
75
|
# First, ensure that we can find the header for the prism library.
|
@@ -127,24 +107,21 @@ end
|
|
127
107
|
# By default, all symbols are hidden in the shared library.
|
128
108
|
append_cflags("-fvisibility=hidden")
|
129
109
|
|
130
|
-
|
131
|
-
|
132
|
-
#
|
133
|
-
|
134
|
-
|
110
|
+
def src_list(path)
|
111
|
+
srcdir = path.dup
|
112
|
+
RbConfig.expand(srcdir) # mutates srcdir :-/
|
113
|
+
Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
|
114
|
+
end
|
135
115
|
|
136
|
-
|
137
|
-
$
|
116
|
+
def add_libprism_source(path)
|
117
|
+
$VPATH << path
|
118
|
+
src_list path
|
119
|
+
end
|
120
|
+
|
121
|
+
$srcs = src_list("$(srcdir)") +
|
122
|
+
add_libprism_source("$(srcdir)/../../src") +
|
123
|
+
add_libprism_source("$(srcdir)/../../src/util")
|
138
124
|
|
139
125
|
# Finally, we'll create the `Makefile` that is going to be used to configure and
|
140
126
|
# build the C extension.
|
141
127
|
create_makefile("prism/prism")
|
142
|
-
|
143
|
-
# Now that the `Makefile` for the C extension is built, we'll append on an extra
|
144
|
-
# rule that dictates that the extension should be rebuilt if the archive is
|
145
|
-
# updated.
|
146
|
-
File.open("Makefile", "a") do |mf|
|
147
|
-
mf.puts
|
148
|
-
mf.puts("# Automatically rebuild the extension if libprism.a changed")
|
149
|
-
mf.puts("$(TARGET_SO): $(LOCAL_LIBS)")
|
150
|
-
end
|