prism 0.15.1 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/Makefile +6 -0
  4. data/README.md +2 -0
  5. data/config.yml +21 -20
  6. data/docs/configuration.md +2 -0
  7. data/docs/javascript.md +90 -0
  8. data/docs/releasing.md +27 -0
  9. data/docs/ruby_api.md +2 -0
  10. data/ext/prism/api_node.c +66 -68
  11. data/ext/prism/extension.c +73 -0
  12. data/ext/prism/extension.h +1 -1
  13. data/include/prism/ast.h +40 -40
  14. data/include/prism/defines.h +9 -0
  15. data/include/prism/enc/pm_encoding.h +1 -0
  16. data/include/prism/node.h +0 -17
  17. data/include/prism/parser.h +1 -0
  18. data/include/prism/prettyprint.h +15 -0
  19. data/include/prism/util/pm_buffer.h +10 -4
  20. data/include/prism/util/pm_constant_pool.h +1 -1
  21. data/include/prism/util/pm_newline_list.h +1 -1
  22. data/include/prism/version.h +3 -3
  23. data/include/prism.h +11 -11
  24. data/lib/prism/compiler.rb +0 -3
  25. data/lib/prism/debug.rb +20 -6
  26. data/lib/prism/desugar_compiler.rb +1 -1
  27. data/lib/prism/dispatcher.rb +0 -14
  28. data/lib/prism/dsl.rb +8 -13
  29. data/lib/prism/ffi.rb +25 -0
  30. data/lib/prism/lex_compat.rb +1 -1
  31. data/lib/prism/mutation_compiler.rb +3 -8
  32. data/lib/prism/node.rb +123 -159
  33. data/lib/prism/node_ext.rb +23 -16
  34. data/lib/prism/parse_result.rb +21 -5
  35. data/lib/prism/pattern.rb +3 -3
  36. data/lib/prism/serialize.rb +901 -305
  37. data/lib/prism/visitor.rb +0 -3
  38. data/prism.gemspec +8 -1
  39. data/rbi/prism.rbi +7261 -0
  40. data/rbi/prism_static.rbi +182 -0
  41. data/sig/prism.rbs +4439 -0
  42. data/sig/prism_static.rbs +110 -0
  43. data/src/enc/pm_unicode.c +1 -1
  44. data/src/node.c +28 -29
  45. data/src/prettyprint.c +7674 -1647
  46. data/src/prism.c +353 -300
  47. data/src/regexp.c +2 -0
  48. data/src/serialize.c +392 -381
  49. data/src/util/pm_buffer.c +47 -12
  50. data/src/util/pm_constant_pool.c +1 -1
  51. data/src/util/pm_newline_list.c +8 -54
  52. metadata +9 -2
@@ -0,0 +1,182 @@
1
+ # typed: true
2
+
3
+ module Prism
4
+ class ParseResult
5
+ sig { returns(ProgramNode) }
6
+ def value; end
7
+
8
+ sig { returns(T::Array[Comment]) }
9
+ def comments; end
10
+
11
+ sig { returns(T::Array[ParseError]) }
12
+ def errors; end
13
+
14
+ sig { returns(T::Array[ParseWarning]) }
15
+ def warnings; end
16
+
17
+ sig { returns(Source) }
18
+ def source; end
19
+ end
20
+
21
+ class ParseError
22
+ sig { returns(String) }
23
+ def message; end
24
+
25
+ sig { returns(Location) }
26
+ def location; end
27
+ end
28
+
29
+ class ParseWarning
30
+ sig { returns(String) }
31
+ def message; end
32
+
33
+ sig { returns(Location) }
34
+ def location; end
35
+ end
36
+
37
+ class Node
38
+ sig { returns(T::Array[T.nilable(Node)]) }
39
+ def child_nodes; end
40
+
41
+ sig { returns(Location) }
42
+ def location; end
43
+
44
+ sig { returns(String) }
45
+ def slice; end
46
+ end
47
+
48
+ class Comment
49
+ sig { returns(Location) }
50
+ def location; end
51
+ end
52
+
53
+ class Location
54
+ sig { params(source: Source, start_offset: Integer, length: Integer).void }
55
+ def initialize(source, start_offset, length); end
56
+
57
+ sig { returns(String) }
58
+ def slice; end
59
+
60
+ sig { returns(T::Array[Comment]) }
61
+ def comments; end
62
+
63
+ sig { params(options: T.untyped).returns(Location) }
64
+ def copy(**options); end
65
+
66
+ sig { returns(Integer) }
67
+ def start_offset; end
68
+
69
+ sig { returns(Integer) }
70
+ def end_offset; end
71
+
72
+ sig { returns(Integer) }
73
+ def start_line; end
74
+
75
+ sig { returns(Integer) }
76
+ def end_line; end
77
+
78
+ sig { returns(Integer) }
79
+ def start_column; end
80
+
81
+ sig { returns(Integer) }
82
+ def end_column; end
83
+ end
84
+
85
+ class Source
86
+ sig { params(source: String, offsets: T::Array[Integer]).void }
87
+ def initialize(source, offsets); end
88
+
89
+ sig { params(offset: Integer, length: Integer).returns(String) }
90
+ def slice(offset, length); end
91
+
92
+ sig { params(value: Integer).returns(Integer) }
93
+ def line(value); end
94
+
95
+ sig { params(value: Integer).returns(Integer) }
96
+ def line_offset(value); end
97
+
98
+ sig { params(value: Integer).returns(Integer) }
99
+ def column(value); end
100
+
101
+ sig { returns(String) }
102
+ def source; end
103
+
104
+ sig { returns(T::Array[Integer]) }
105
+ def offsets; end
106
+ end
107
+
108
+ class Token
109
+ sig { params(type: T.untyped, value: String, location: Location).void }
110
+ def initialize(type, value, location); end
111
+
112
+ sig { params(keys: T.untyped).returns(T.untyped) }
113
+ def deconstruct_keys(keys); end
114
+
115
+ sig { params(q: T.untyped).returns(T.untyped) }
116
+ def pretty_print(q); end
117
+
118
+ sig { params(other: T.untyped).returns(T::Boolean) }
119
+ def ==(other); end
120
+
121
+ sig { returns(T.untyped) }
122
+ def type; end
123
+
124
+ sig { returns(String) }
125
+ def value; end
126
+
127
+ sig { returns(Location) }
128
+ def location; end
129
+ end
130
+
131
+ class NodeInspector
132
+ sig { params(prefix: String).void }
133
+ def initialize(prefix); end
134
+
135
+ sig { returns(String) }
136
+ def prefix; end
137
+
138
+ sig { returns(String) }
139
+ def output; end
140
+
141
+ # Appends a line to the output with the current prefix.
142
+ sig { params(line: String).void }
143
+ def <<(line); end
144
+
145
+ # This generates a string that is used as the header of the inspect output
146
+ # for any given node.
147
+ sig { params(node: Node).returns(String) }
148
+ def header(node); end
149
+
150
+ # Generates a string that represents a list of nodes. It handles properly
151
+ # using the box drawing characters to make the output look nice.
152
+ sig { params(prefix: String, nodes: T::Array[Node]).returns(String) }
153
+ def list(prefix, nodes); end
154
+
155
+ # Generates a string that represents a location field on a node.
156
+ sig { params(value: Location).returns(String) }
157
+ def location(value); end
158
+
159
+ # Generates a string that represents a child node.
160
+ sig { params(node: Node, append: String).returns(String) }
161
+ def child_node(node, append); end
162
+
163
+ # Returns a new inspector that can be used to inspect a child node.
164
+ sig { params(append: String).returns(NodeInspector) }
165
+ def child_inspector(append); end
166
+
167
+ # Returns the output as a string.
168
+ sig { returns(String) }
169
+ def to_str; end
170
+ end
171
+
172
+ class BasicVisitor
173
+ sig { params(node: T.nilable(Node)).void }
174
+ def visit(node); end
175
+
176
+ sig { params(nodes: T::Array[T.nilable(Node)]).void }
177
+ def visit_all(nodes); end
178
+
179
+ sig { params(node: Node).void }
180
+ def visit_child_nodes(node); end
181
+ end
182
+ end