prism 0.17.1 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -1
  3. data/Makefile +5 -5
  4. data/README.md +2 -2
  5. data/config.yml +26 -13
  6. data/docs/build_system.md +6 -6
  7. data/docs/building.md +1 -1
  8. data/docs/configuration.md +1 -0
  9. data/docs/encoding.md +68 -32
  10. data/docs/heredocs.md +1 -1
  11. data/docs/javascript.md +29 -1
  12. data/docs/ruby_api.md +14 -0
  13. data/ext/prism/api_node.c +74 -45
  14. data/ext/prism/extconf.rb +91 -127
  15. data/ext/prism/extension.c +1 -1
  16. data/ext/prism/extension.h +1 -1
  17. data/include/prism/ast.h +148 -133
  18. data/include/prism/diagnostic.h +27 -1
  19. data/include/prism/enc/pm_encoding.h +42 -1
  20. data/include/prism/parser.h +6 -0
  21. data/include/prism/version.h +3 -3
  22. data/lib/prism/compiler.rb +3 -3
  23. data/lib/prism/debug.rb +4 -0
  24. data/lib/prism/desugar_compiler.rb +1 -0
  25. data/lib/prism/dispatcher.rb +14 -14
  26. data/lib/prism/dot_visitor.rb +4334 -0
  27. data/lib/prism/dsl.rb +11 -11
  28. data/lib/prism/ffi.rb +3 -3
  29. data/lib/prism/mutation_compiler.rb +6 -6
  30. data/lib/prism/node.rb +182 -113
  31. data/lib/prism/node_ext.rb +61 -3
  32. data/lib/prism/parse_result.rb +46 -12
  33. data/lib/prism/serialize.rb +125 -131
  34. data/lib/prism/visitor.rb +3 -3
  35. data/lib/prism.rb +1 -0
  36. data/prism.gemspec +5 -1
  37. data/rbi/prism.rbi +83 -54
  38. data/sig/prism.rbs +47 -32
  39. data/src/diagnostic.c +61 -3
  40. data/src/enc/pm_big5.c +63 -0
  41. data/src/enc/pm_cp51932.c +57 -0
  42. data/src/enc/pm_euc_jp.c +10 -0
  43. data/src/enc/pm_gbk.c +5 -2
  44. data/src/enc/pm_tables.c +1478 -148
  45. data/src/node.c +33 -21
  46. data/src/prettyprint.c +1027 -925
  47. data/src/prism.c +925 -374
  48. data/src/regexp.c +12 -12
  49. data/src/serialize.c +36 -9
  50. metadata +6 -2
@@ -14,16 +14,16 @@
14
14
  /**
15
15
  * The minor version of the Prism library as an int.
16
16
  */
17
- #define PRISM_VERSION_MINOR 17
17
+ #define PRISM_VERSION_MINOR 18
18
18
 
19
19
  /**
20
20
  * The patch version of the Prism library as an int.
21
21
  */
22
- #define PRISM_VERSION_PATCH 1
22
+ #define PRISM_VERSION_PATCH 0
23
23
 
24
24
  /**
25
25
  * The version of the Prism library as a constant string.
26
26
  */
27
- #define PRISM_VERSION "0.17.1"
27
+ #define PRISM_VERSION "0.18.0"
28
28
 
29
29
  #endif
@@ -105,6 +105,9 @@ module Prism
105
105
  # Compile a CapturePatternNode node
106
106
  alias visit_capture_pattern_node visit_child_nodes
107
107
 
108
+ # Compile a CaseMatchNode node
109
+ alias visit_case_match_node visit_child_nodes
110
+
108
111
  # Compile a CaseNode node
109
112
  alias visit_case_node visit_child_nodes
110
113
 
@@ -435,9 +438,6 @@ module Prism
435
438
  # Compile a StatementsNode node
436
439
  alias visit_statements_node visit_child_nodes
437
440
 
438
- # Compile a StringConcatNode node
439
- alias visit_string_concat_node visit_child_nodes
440
-
441
441
  # Compile a StringNode node
442
442
  alias visit_string_node visit_child_nodes
443
443
 
data/lib/prism/debug.rb CHANGED
@@ -133,6 +133,10 @@ module Prism
133
133
  *params.keywords.grep(OptionalKeywordParameterNode).map(&:name),
134
134
  ]
135
135
 
136
+ if params.keyword_rest.is_a?(ForwardingParameterNode)
137
+ sorted.push(:*, :&, :"...")
138
+ end
139
+
136
140
  sorted << AnonymousLocal if params.keywords.any?
137
141
 
138
142
  # Recurse down the parameter tree to find any destructured
@@ -188,6 +188,7 @@ module Prism
188
188
  IfNode.new(
189
189
  node.operator_loc,
190
190
  DefinedNode.new(nil, read_class.new(*arguments, node.name_loc), nil, node.operator_loc, node.name_loc),
191
+ node.operator_loc,
191
192
  StatementsNode.new([read_class.new(*arguments, node.name_loc)], node.location),
192
193
  ElseNode.new(
193
194
  node.operator_loc,
@@ -241,6 +241,14 @@ module Prism
241
241
  listeners[:on_capture_pattern_node_leave]&.each { |listener| listener.on_capture_pattern_node_leave(node) }
242
242
  end
243
243
 
244
+ # Dispatch enter and leave events for CaseMatchNode nodes and continue
245
+ # walking the tree.
246
+ def visit_case_match_node(node)
247
+ listeners[:on_case_match_node_enter]&.each { |listener| listener.on_case_match_node_enter(node) }
248
+ super
249
+ listeners[:on_case_match_node_leave]&.each { |listener| listener.on_case_match_node_leave(node) }
250
+ end
251
+
244
252
  # Dispatch enter and leave events for CaseNode nodes and continue
245
253
  # walking the tree.
246
254
  def visit_case_node(node)
@@ -1121,14 +1129,6 @@ module Prism
1121
1129
  listeners[:on_statements_node_leave]&.each { |listener| listener.on_statements_node_leave(node) }
1122
1130
  end
1123
1131
 
1124
- # Dispatch enter and leave events for StringConcatNode nodes and continue
1125
- # walking the tree.
1126
- def visit_string_concat_node(node)
1127
- listeners[:on_string_concat_node_enter]&.each { |listener| listener.on_string_concat_node_enter(node) }
1128
- super
1129
- listeners[:on_string_concat_node_leave]&.each { |listener| listener.on_string_concat_node_leave(node) }
1130
- end
1131
-
1132
1132
  # Dispatch enter and leave events for StringNode nodes and continue
1133
1133
  # walking the tree.
1134
1134
  def visit_string_node(node)
@@ -1356,6 +1356,12 @@ module Prism
1356
1356
  listeners[:on_capture_pattern_node_leave]&.each { |listener| listener.on_capture_pattern_node_leave(node) }
1357
1357
  end
1358
1358
 
1359
+ # Dispatch enter and leave events for CaseMatchNode nodes.
1360
+ def visit_case_match_node(node)
1361
+ listeners[:on_case_match_node_enter]&.each { |listener| listener.on_case_match_node_enter(node) }
1362
+ listeners[:on_case_match_node_leave]&.each { |listener| listener.on_case_match_node_leave(node) }
1363
+ end
1364
+
1359
1365
  # Dispatch enter and leave events for CaseNode nodes.
1360
1366
  def visit_case_node(node)
1361
1367
  listeners[:on_case_node_enter]&.each { |listener| listener.on_case_node_enter(node) }
@@ -2016,12 +2022,6 @@ module Prism
2016
2022
  listeners[:on_statements_node_leave]&.each { |listener| listener.on_statements_node_leave(node) }
2017
2023
  end
2018
2024
 
2019
- # Dispatch enter and leave events for StringConcatNode nodes.
2020
- def visit_string_concat_node(node)
2021
- listeners[:on_string_concat_node_enter]&.each { |listener| listener.on_string_concat_node_enter(node) }
2022
- listeners[:on_string_concat_node_leave]&.each { |listener| listener.on_string_concat_node_leave(node) }
2023
- end
2024
-
2025
2025
  # Dispatch enter and leave events for StringNode nodes.
2026
2026
  def visit_string_node(node)
2027
2027
  listeners[:on_string_node_enter]&.each { |listener| listener.on_string_node_enter(node) }