prism 0.24.0 → 0.25.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 +50 -1
- data/Makefile +5 -2
- data/README.md +45 -6
- data/config.yml +499 -4
- data/docs/build_system.md +31 -0
- data/docs/configuration.md +2 -0
- data/docs/cruby_compilation.md +1 -1
- data/docs/parser_translation.md +14 -9
- data/docs/releasing.md +2 -2
- 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 +27 -11
- data/ext/prism/extension.c +313 -66
- 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 +134 -71
- 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 +198 -53
- 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 +1 -1
- 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 +67 -12
- data/lib/prism/lex_compat.rb +17 -15
- data/lib/prism/mutation_compiler.rb +11 -0
- data/lib/prism/node.rb +2096 -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 +78 -32
- data/lib/prism/pattern.rb +16 -4
- data/lib/prism/polyfill/string.rb +12 -0
- data/lib/prism/serialize.rb +439 -102
- data/lib/prism/translation/parser/compiler.rb +152 -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 +8 -2
- data/prism.gemspec +33 -4
- 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 +8221 -0
- data/rbi/prism/node_ext.rbi +102 -0
- data/rbi/prism/parse_result.rbi +304 -0
- data/rbi/prism/translation/parser/compiler.rbi +13 -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 +39 -7749
- 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 +3529 -0
- data/sig/prism/node_ext.rbs +78 -0
- data/sig/prism/pack.rbs +43 -0
- data/sig/prism/parse_result.rbs +127 -0
- data/sig/prism/pattern.rbs +13 -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 +575 -230
- data/src/encoding.c +211 -108
- data/src/node.c +7526 -447
- data/src/options.c +36 -12
- data/src/pack.c +33 -17
- data/src/prettyprint.c +1294 -1385
- data/src/prism.c +3628 -1099
- data/src/regexp.c +17 -2
- data/src/serialize.c +47 -28
- data/src/static_literals.c +552 -0
- data/src/token_type.c +1 -0
- 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 +629 -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 +35 -6
- data/docs/ripper.md +0 -36
- data/rbi/prism_static.rbi +0 -207
- data/sig/prism_static.rbs +0 -201
data/sig/prism_static.rbs
DELETED
@@ -1,201 +0,0 @@
|
|
1
|
-
module Prism
|
2
|
-
BACKEND: :CEXT | :FFI
|
3
|
-
VERSION: String
|
4
|
-
|
5
|
-
def self.parse: (String source, ?filepath: String, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> ParseResult[ProgramNode]
|
6
|
-
def self.lex: (String source, ?filepath: String, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> ParseResult[Array[[Token, Integer]]]
|
7
|
-
def self.parse_lex: (String source, ?filepath: String, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> ParseResult[[ProgramNode, Array[[Token, Integer]]]]
|
8
|
-
def self.dump: (String source, ?filepath: String, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> String
|
9
|
-
def self.parse_comments: (String source, ?filepath: String, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> Array[Comment]
|
10
|
-
def self.parse_success?: (String source, ?filepath: String, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> bool
|
11
|
-
def self.parse_failure?: (String source, ?filepath: String, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> bool
|
12
|
-
|
13
|
-
def self.parse_file: (String filepath, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> ParseResult[ProgramNode]
|
14
|
-
def self.lex_file: (String filepath, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> ParseResult[Array[[Token, Integer]]]
|
15
|
-
def self.parse_lex_file: (String filepath, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> ParseResult[[ProgramNode, Array[[Token, Integer]]]]
|
16
|
-
def self.dump_file: (String filepath, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> String
|
17
|
-
def self.parse_file_comments: (String filepath, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> Array[Comment]
|
18
|
-
def self.parse_file_failure?: (String filepath, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> bool
|
19
|
-
def self.parse_file_success?: (String filepath, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> bool
|
20
|
-
|
21
|
-
def self.load: (String source, String serialized) -> ParseResult[ProgramNode]
|
22
|
-
|
23
|
-
type ripper_token = [[Integer, Integer], Symbol, String, untyped]
|
24
|
-
def self.lex_compat: (String source, ?filepath: String, ?line: Integer, ?encoding: Encoding, ?frozen_string_literal: bool, ?scopes: Array[Array[Symbol]]) -> ParseResult[Array[ripper_token]]
|
25
|
-
def self.lex_ripper: (String source) -> Array[ripper_token]
|
26
|
-
|
27
|
-
class ParseResult[T]
|
28
|
-
attr_reader value: T
|
29
|
-
attr_reader comments: Array[Comment]
|
30
|
-
attr_reader magic_comments: Array[MagicComment]
|
31
|
-
attr_reader data_loc: Location?
|
32
|
-
attr_reader errors: Array[ParseError]
|
33
|
-
attr_reader warnings: Array[ParseWarning]
|
34
|
-
attr_reader source: Source
|
35
|
-
|
36
|
-
def initialize: (T value, Array[Comment] comments, Array[MagicComment] magic_comments, Location? data_loc, Array[ParseError] errors, Array[ParseWarning] warnings, Source source) -> void
|
37
|
-
def deconstruct_keys: (Array[Symbol] keys) -> { value: T, comments: Array[Comment], magic_comments: Array[MagicComment], data_loc: Location?, errors: Array[ParseError], warnings: Array[ParseWarning] }
|
38
|
-
def success?: () -> bool
|
39
|
-
def failure?: () -> bool
|
40
|
-
end
|
41
|
-
|
42
|
-
class ParseError
|
43
|
-
attr_reader message: String
|
44
|
-
attr_reader location: Location
|
45
|
-
|
46
|
-
def initialize: (String message, Location location) -> void
|
47
|
-
def deconstruct_keys: (Array[Symbol] keys) -> { message: String, location: Location }
|
48
|
-
end
|
49
|
-
|
50
|
-
class ParseWarning
|
51
|
-
attr_reader message: String
|
52
|
-
attr_reader location: Location
|
53
|
-
|
54
|
-
def initialize: (String message, Location location) -> void
|
55
|
-
def deconstruct_keys: (Array[Symbol] keys) -> { message: String, location: Location }
|
56
|
-
end
|
57
|
-
|
58
|
-
class Node
|
59
|
-
@newline: bool
|
60
|
-
|
61
|
-
attr_reader location: Location
|
62
|
-
|
63
|
-
def child_nodes: () -> Array[Node?]
|
64
|
-
def newline?: () -> bool
|
65
|
-
def set_newline_flag: (Array[bool] newline_marked) -> void
|
66
|
-
def slice: () -> String
|
67
|
-
def pretty_print: (untyped q) -> untyped
|
68
|
-
def inspect: (?NodeInspector inspector) -> String # TODO: not right, only is defined on subclasses
|
69
|
-
def to_dot: () -> String
|
70
|
-
end
|
71
|
-
|
72
|
-
class Comment
|
73
|
-
attr_reader location: Location
|
74
|
-
|
75
|
-
def initialize: (Location location) -> void
|
76
|
-
def deconstruct_keys: (Array[Symbol] keys) -> { location: Location }
|
77
|
-
end
|
78
|
-
|
79
|
-
class InlineComment < Comment
|
80
|
-
def trailing?: () -> bool
|
81
|
-
end
|
82
|
-
|
83
|
-
class EmbDocComment < Comment
|
84
|
-
def trailing?: () -> false
|
85
|
-
end
|
86
|
-
|
87
|
-
class MagicComment
|
88
|
-
attr_reader key_loc: Location
|
89
|
-
attr_reader value_loc: Location
|
90
|
-
|
91
|
-
def initialize: (Location key_loc, Location value_loc) -> void
|
92
|
-
|
93
|
-
def key: () -> String
|
94
|
-
def value: () -> String
|
95
|
-
|
96
|
-
def deconstruct_keys: (Array[Symbol] keys) -> { key_loc: Location, value_loc: Location }
|
97
|
-
end
|
98
|
-
|
99
|
-
class Location
|
100
|
-
attr_reader source: Source | nil
|
101
|
-
attr_reader start_offset: Integer
|
102
|
-
attr_reader length: Integer
|
103
|
-
attr_reader comments: Array[Comment]
|
104
|
-
|
105
|
-
def initialize: (Source? source, Integer start_offset, Integer length) -> void
|
106
|
-
def copy: (?source: Source, ?start_offset: Integer, ?length: Integer) -> Location
|
107
|
-
def slice: () -> String
|
108
|
-
def start_character_offset: () -> Integer
|
109
|
-
def end_offset: () -> Integer
|
110
|
-
def end_character_offset: () -> Integer
|
111
|
-
def start_line: () -> Integer
|
112
|
-
def start_line_slice: () -> String
|
113
|
-
def end_line: () -> Integer
|
114
|
-
def start_column: () -> Integer
|
115
|
-
def start_character_column: () -> Integer
|
116
|
-
def end_column: () -> Integer
|
117
|
-
def end_character_column: () -> Integer
|
118
|
-
def deconstruct_keys: (Array[Symbol] keys) -> { start_offset: Integer, end_offset: Integer }
|
119
|
-
def pretty_print: (untyped q) -> untyped
|
120
|
-
def join: (Location other) -> Location
|
121
|
-
|
122
|
-
def self.null: () -> Location
|
123
|
-
end
|
124
|
-
|
125
|
-
class Source
|
126
|
-
attr_reader source: String
|
127
|
-
attr_reader start_line: Integer
|
128
|
-
attr_reader offsets: Array[Integer]
|
129
|
-
|
130
|
-
def initialize: (String source, ?Integer start_line, ?Array[Integer] offsets) -> void
|
131
|
-
def slice: (Integer byte_offset, Integer length) -> String
|
132
|
-
def line: (Integer byte_offset) -> Integer
|
133
|
-
def line_offset: (Integer byte_offset) -> Integer
|
134
|
-
def column: (Integer byte_offset) -> Integer
|
135
|
-
def character_offset: (Integer byte_offset) -> Integer
|
136
|
-
def character_column: (Integer byte_offset) -> Integer
|
137
|
-
end
|
138
|
-
|
139
|
-
class Token
|
140
|
-
attr_reader type: Symbol
|
141
|
-
attr_reader value: String
|
142
|
-
attr_reader location: Location
|
143
|
-
|
144
|
-
def initialize: (Symbol type, String value, Location location) -> void
|
145
|
-
def deconstruct_keys: (Array[Symbol] keys) -> { type: Symbol, value: String, location: Location }
|
146
|
-
def pretty_print: (untyped q) -> untyped
|
147
|
-
def ==: (untyped other) -> bool
|
148
|
-
end
|
149
|
-
|
150
|
-
class NodeInspector
|
151
|
-
attr_reader prefix: String
|
152
|
-
attr_reader output: String
|
153
|
-
|
154
|
-
@prefix: String
|
155
|
-
@output: String
|
156
|
-
|
157
|
-
def initialize: (?String prefix) -> void
|
158
|
-
|
159
|
-
# Appends a line to the output with the current prefix.
|
160
|
-
def <<: (String line) -> void
|
161
|
-
|
162
|
-
# This generates a string that is used as the header of the inspect output
|
163
|
-
# for any given node.
|
164
|
-
def header: (Node node) -> String
|
165
|
-
|
166
|
-
# Generates a string that represents a list of nodes. It handles properly
|
167
|
-
# using the box drawing characters to make the output look nice.
|
168
|
-
def list: (String prefix, Array[Node] nodes) -> String
|
169
|
-
|
170
|
-
# Generates a string that represents a location field on a node.
|
171
|
-
def location: (Location? value) -> String
|
172
|
-
|
173
|
-
# Generates a string that represents a child node.
|
174
|
-
def child_node: (Node node, String append) -> String
|
175
|
-
|
176
|
-
# Returns a new inspector that can be used to inspect a child node.
|
177
|
-
def child_inspector: (String append) -> NodeInspector
|
178
|
-
|
179
|
-
# Returns the output as a string.
|
180
|
-
def to_str: () -> String
|
181
|
-
end
|
182
|
-
|
183
|
-
class BasicVisitor
|
184
|
-
def visit: (Node? node) -> void
|
185
|
-
def visit_all: (Array[Node?] nodes) -> void
|
186
|
-
def visit_child_nodes: (Node node) -> void
|
187
|
-
end
|
188
|
-
|
189
|
-
class Pattern
|
190
|
-
class CompilationError < StandardError
|
191
|
-
end
|
192
|
-
|
193
|
-
attr_reader query: String
|
194
|
-
|
195
|
-
@compiled: Proc
|
196
|
-
|
197
|
-
def initialize: (String query) -> void
|
198
|
-
def compile: () -> Proc
|
199
|
-
def scan: (Node root) -> void
|
200
|
-
end
|
201
|
-
end
|