prism 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -1
  3. data/Makefile +5 -0
  4. data/README.md +8 -6
  5. data/config.yml +236 -38
  6. data/docs/build_system.md +19 -2
  7. data/docs/cruby_compilation.md +27 -0
  8. data/docs/parser_translation.md +34 -0
  9. data/docs/parsing_rules.md +19 -0
  10. data/docs/releasing.md +3 -3
  11. data/docs/ruby_api.md +1 -1
  12. data/docs/serialization.md +17 -5
  13. data/ext/prism/api_node.c +101 -81
  14. data/ext/prism/extension.c +74 -11
  15. data/ext/prism/extension.h +1 -1
  16. data/include/prism/ast.h +1699 -504
  17. data/include/prism/defines.h +8 -0
  18. data/include/prism/diagnostic.h +39 -2
  19. data/include/prism/encoding.h +10 -0
  20. data/include/prism/options.h +40 -14
  21. data/include/prism/parser.h +33 -17
  22. data/include/prism/util/pm_buffer.h +9 -0
  23. data/include/prism/util/pm_constant_pool.h +7 -0
  24. data/include/prism/util/pm_newline_list.h +0 -11
  25. data/include/prism/version.h +2 -2
  26. data/include/prism.h +19 -2
  27. data/lib/prism/debug.rb +11 -5
  28. data/lib/prism/dot_visitor.rb +36 -14
  29. data/lib/prism/dsl.rb +22 -22
  30. data/lib/prism/ffi.rb +2 -2
  31. data/lib/prism/node.rb +1020 -737
  32. data/lib/prism/node_ext.rb +2 -2
  33. data/lib/prism/parse_result.rb +17 -9
  34. data/lib/prism/serialize.rb +53 -29
  35. data/lib/prism/translation/parser/compiler.rb +1831 -0
  36. data/lib/prism/translation/parser/lexer.rb +335 -0
  37. data/lib/prism/translation/parser/rubocop.rb +37 -0
  38. data/lib/prism/translation/parser.rb +163 -0
  39. data/lib/prism/translation.rb +11 -0
  40. data/lib/prism.rb +1 -0
  41. data/prism.gemspec +12 -5
  42. data/rbi/prism.rbi +150 -88
  43. data/rbi/prism_static.rbi +15 -3
  44. data/sig/prism.rbs +996 -961
  45. data/sig/prism_static.rbs +123 -46
  46. data/src/diagnostic.c +259 -219
  47. data/src/encoding.c +4 -8
  48. data/src/node.c +2 -6
  49. data/src/options.c +24 -5
  50. data/src/prettyprint.c +174 -42
  51. data/src/prism.c +1136 -328
  52. data/src/serialize.c +12 -9
  53. data/src/token_type.c +353 -4
  54. data/src/util/pm_buffer.c +11 -0
  55. data/src/util/pm_constant_pool.c +12 -11
  56. data/src/util/pm_newline_list.c +2 -14
  57. metadata +10 -3
  58. data/docs/building.md +0 -29
data/lib/prism/dsl.rb CHANGED
@@ -103,18 +103,18 @@ module Prism
103
103
  end
104
104
 
105
105
  # Create a new BlockLocalVariableNode node
106
- def BlockLocalVariableNode(name, location = Location())
107
- BlockLocalVariableNode.new(name, location)
106
+ def BlockLocalVariableNode(flags, name, location = Location())
107
+ BlockLocalVariableNode.new(flags, name, location)
108
108
  end
109
109
 
110
110
  # Create a new BlockNode node
111
- def BlockNode(locals, locals_body_index, parameters, body, opening_loc, closing_loc, location = Location())
112
- BlockNode.new(locals, locals_body_index, parameters, body, opening_loc, closing_loc, location)
111
+ def BlockNode(locals, parameters, body, opening_loc, closing_loc, location = Location())
112
+ BlockNode.new(locals, parameters, body, opening_loc, closing_loc, location)
113
113
  end
114
114
 
115
115
  # Create a new BlockParameterNode node
116
- def BlockParameterNode(name, name_loc, operator_loc, location = Location())
117
- BlockParameterNode.new(name, name_loc, operator_loc, location)
116
+ def BlockParameterNode(flags, name, name_loc, operator_loc, location = Location())
117
+ BlockParameterNode.new(flags, name, name_loc, operator_loc, location)
118
118
  end
119
119
 
120
120
  # Create a new BlockParametersNode node
@@ -263,8 +263,8 @@ module Prism
263
263
  end
264
264
 
265
265
  # Create a new DefNode node
266
- def DefNode(name, name_loc, receiver, parameters, body, locals, locals_body_index, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc, location = Location())
267
- DefNode.new(name, name_loc, receiver, parameters, body, locals, locals_body_index, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc, location)
266
+ def DefNode(name, name_loc, receiver, parameters, body, locals, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc, location = Location())
267
+ DefNode.new(name, name_loc, receiver, parameters, body, locals, def_keyword_loc, operator_loc, lparen_loc, rparen_loc, equal_loc, end_keyword_loc, location)
268
268
  end
269
269
 
270
270
  # Create a new DefinedNode node
@@ -483,13 +483,13 @@ module Prism
483
483
  end
484
484
 
485
485
  # Create a new KeywordRestParameterNode node
486
- def KeywordRestParameterNode(name, name_loc, operator_loc, location = Location())
487
- KeywordRestParameterNode.new(name, name_loc, operator_loc, location)
486
+ def KeywordRestParameterNode(flags, name, name_loc, operator_loc, location = Location())
487
+ KeywordRestParameterNode.new(flags, name, name_loc, operator_loc, location)
488
488
  end
489
489
 
490
490
  # Create a new LambdaNode node
491
- def LambdaNode(locals, locals_body_index, operator_loc, opening_loc, closing_loc, parameters, body, location = Location())
492
- LambdaNode.new(locals, locals_body_index, operator_loc, opening_loc, closing_loc, parameters, body, location)
491
+ def LambdaNode(locals, operator_loc, opening_loc, closing_loc, parameters, body, location = Location())
492
+ LambdaNode.new(locals, operator_loc, opening_loc, closing_loc, parameters, body, location)
493
493
  end
494
494
 
495
495
  # Create a new LocalVariableAndWriteNode node
@@ -588,13 +588,13 @@ module Prism
588
588
  end
589
589
 
590
590
  # Create a new OptionalKeywordParameterNode node
591
- def OptionalKeywordParameterNode(name, name_loc, value, location = Location())
592
- OptionalKeywordParameterNode.new(name, name_loc, value, location)
591
+ def OptionalKeywordParameterNode(flags, name, name_loc, value, location = Location())
592
+ OptionalKeywordParameterNode.new(flags, name, name_loc, value, location)
593
593
  end
594
594
 
595
595
  # Create a new OptionalParameterNode node
596
- def OptionalParameterNode(name, name_loc, operator_loc, value, location = Location())
597
- OptionalParameterNode.new(name, name_loc, operator_loc, value, location)
596
+ def OptionalParameterNode(flags, name, name_loc, operator_loc, value, location = Location())
597
+ OptionalParameterNode.new(flags, name, name_loc, operator_loc, value, location)
598
598
  end
599
599
 
600
600
  # Create a new OrNode node
@@ -658,13 +658,13 @@ module Prism
658
658
  end
659
659
 
660
660
  # Create a new RequiredKeywordParameterNode node
661
- def RequiredKeywordParameterNode(name, name_loc, location = Location())
662
- RequiredKeywordParameterNode.new(name, name_loc, location)
661
+ def RequiredKeywordParameterNode(flags, name, name_loc, location = Location())
662
+ RequiredKeywordParameterNode.new(flags, name, name_loc, location)
663
663
  end
664
664
 
665
665
  # Create a new RequiredParameterNode node
666
- def RequiredParameterNode(name, location = Location())
667
- RequiredParameterNode.new(name, location)
666
+ def RequiredParameterNode(flags, name, location = Location())
667
+ RequiredParameterNode.new(flags, name, location)
668
668
  end
669
669
 
670
670
  # Create a new RescueModifierNode node
@@ -678,8 +678,8 @@ module Prism
678
678
  end
679
679
 
680
680
  # Create a new RestParameterNode node
681
- def RestParameterNode(name, name_loc, operator_loc, location = Location())
682
- RestParameterNode.new(name, name_loc, operator_loc, location)
681
+ def RestParameterNode(flags, name, name_loc, operator_loc, location = Location())
682
+ RestParameterNode.new(flags, name, name_loc, operator_loc, location)
683
683
  end
684
684
 
685
685
  # Create a new RetryNode node
data/lib/prism/ffi.rb CHANGED
@@ -296,7 +296,7 @@ module Prism
296
296
  values << 0
297
297
  end
298
298
 
299
- template << "L"
299
+ template << "l"
300
300
  values << options.fetch(:line, 1)
301
301
 
302
302
  template << "L"
@@ -312,7 +312,7 @@ module Prism
312
312
  values << (options.fetch(:frozen_string_literal, false) ? 1 : 0)
313
313
 
314
314
  template << "C"
315
- values << (options.fetch(:verbose, true) ? 0 : 1)
315
+ values << { nil => 0, "3.3.0" => 1, "latest" => 0 }.fetch(options[:version])
316
316
 
317
317
  template << "L"
318
318
  if (scopes = options[:scopes])