prism 0.29.0 → 0.30.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -1
  3. data/CONTRIBUTING.md +0 -4
  4. data/README.md +1 -0
  5. data/config.yml +66 -9
  6. data/docs/fuzzing.md +1 -1
  7. data/docs/ripper_translation.md +22 -0
  8. data/ext/prism/api_node.c +30 -12
  9. data/ext/prism/extension.c +107 -372
  10. data/ext/prism/extension.h +1 -1
  11. data/include/prism/ast.h +138 -70
  12. data/include/prism/diagnostic.h +7 -2
  13. data/include/prism/node.h +0 -21
  14. data/include/prism/parser.h +23 -25
  15. data/include/prism/regexp.h +17 -8
  16. data/include/prism/static_literals.h +3 -2
  17. data/include/prism/util/pm_char.h +1 -2
  18. data/include/prism/util/pm_constant_pool.h +0 -8
  19. data/include/prism/util/pm_integer.h +16 -9
  20. data/include/prism/util/pm_string.h +0 -8
  21. data/include/prism/version.h +2 -2
  22. data/include/prism.h +0 -11
  23. data/lib/prism/compiler.rb +3 -0
  24. data/lib/prism/dispatcher.rb +14 -0
  25. data/lib/prism/dot_visitor.rb +22 -3
  26. data/lib/prism/dsl.rb +7 -2
  27. data/lib/prism/ffi.rb +24 -3
  28. data/lib/prism/inspect_visitor.rb +10 -8
  29. data/lib/prism/mutation_compiler.rb +6 -1
  30. data/lib/prism/node.rb +166 -241
  31. data/lib/prism/node_ext.rb +21 -5
  32. data/lib/prism/parse_result/comments.rb +0 -7
  33. data/lib/prism/parse_result/newlines.rb +101 -11
  34. data/lib/prism/parse_result.rb +17 -0
  35. data/lib/prism/reflection.rb +3 -1
  36. data/lib/prism/serialize.rb +80 -67
  37. data/lib/prism/translation/parser/compiler.rb +134 -114
  38. data/lib/prism/translation/parser.rb +6 -1
  39. data/lib/prism/translation/ripper.rb +8 -6
  40. data/lib/prism/translation/ruby_parser.rb +23 -5
  41. data/lib/prism/visitor.rb +3 -0
  42. data/lib/prism.rb +0 -4
  43. data/prism.gemspec +1 -4
  44. data/rbi/prism/node.rbi +63 -6
  45. data/rbi/prism/visitor.rbi +3 -0
  46. data/rbi/prism.rbi +6 -0
  47. data/sig/prism/dsl.rbs +4 -1
  48. data/sig/prism/mutation_compiler.rbs +1 -0
  49. data/sig/prism/node.rbs +28 -4
  50. data/sig/prism/visitor.rbs +1 -0
  51. data/sig/prism.rbs +21 -0
  52. data/src/diagnostic.c +27 -17
  53. data/src/node.c +408 -1666
  54. data/src/prettyprint.c +49 -6
  55. data/src/prism.c +958 -991
  56. data/src/regexp.c +133 -68
  57. data/src/serialize.c +6 -1
  58. data/src/static_literals.c +63 -84
  59. data/src/token_type.c +2 -2
  60. data/src/util/pm_constant_pool.c +0 -8
  61. data/src/util/pm_integer.c +39 -11
  62. data/src/util/pm_string.c +0 -12
  63. data/src/util/pm_strpbrk.c +32 -6
  64. metadata +2 -5
  65. data/include/prism/util/pm_string_list.h +0 -44
  66. data/lib/prism/debug.rb +0 -249
  67. data/src/util/pm_string_list.c +0 -28
data/src/prettyprint.c CHANGED
@@ -5465,6 +5465,13 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
5465
5465
 
5466
5466
  break;
5467
5467
  }
5468
+ case PM_IT_LOCAL_VARIABLE_READ_NODE: {
5469
+ pm_buffer_append_string(output_buffer, "@ ItLocalVariableReadNode (location: ", 37);
5470
+ prettyprint_location(output_buffer, parser, &node->location);
5471
+ pm_buffer_append_string(output_buffer, ")\n", 2);
5472
+
5473
+ break;
5474
+ }
5468
5475
  case PM_IT_PARAMETERS_NODE: {
5469
5476
  pm_buffer_append_string(output_buffer, "@ ItParametersNode (location: ", 30);
5470
5477
  prettyprint_location(output_buffer, parser, &node->location);
@@ -7290,17 +7297,53 @@ prettyprint_node(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm
7290
7297
  prettyprint_location(output_buffer, parser, &node->location);
7291
7298
  pm_buffer_append_string(output_buffer, ")\n", 2);
7292
7299
 
7293
- // numeric
7300
+ // flags
7294
7301
  {
7295
7302
  pm_buffer_concat(output_buffer, prefix_buffer);
7296
- pm_buffer_append_string(output_buffer, "+-- numeric:", 12);
7303
+ pm_buffer_append_string(output_buffer, "+-- flags:", 10);
7304
+ bool found = false;
7305
+ if (cast->base.flags & PM_INTEGER_BASE_FLAGS_BINARY) {
7306
+ if (found) pm_buffer_append_byte(output_buffer, ',');
7307
+ pm_buffer_append_string(output_buffer, " binary", 7);
7308
+ found = true;
7309
+ }
7310
+ if (cast->base.flags & PM_INTEGER_BASE_FLAGS_DECIMAL) {
7311
+ if (found) pm_buffer_append_byte(output_buffer, ',');
7312
+ pm_buffer_append_string(output_buffer, " decimal", 8);
7313
+ found = true;
7314
+ }
7315
+ if (cast->base.flags & PM_INTEGER_BASE_FLAGS_OCTAL) {
7316
+ if (found) pm_buffer_append_byte(output_buffer, ',');
7317
+ pm_buffer_append_string(output_buffer, " octal", 6);
7318
+ found = true;
7319
+ }
7320
+ if (cast->base.flags & PM_INTEGER_BASE_FLAGS_HEXADECIMAL) {
7321
+ if (found) pm_buffer_append_byte(output_buffer, ',');
7322
+ pm_buffer_append_string(output_buffer, " hexadecimal", 12);
7323
+ found = true;
7324
+ }
7325
+ if (!found) pm_buffer_append_string(output_buffer, " nil", 4);
7297
7326
  pm_buffer_append_byte(output_buffer, '\n');
7327
+ }
7298
7328
 
7299
- size_t prefix_length = prefix_buffer->length;
7300
- pm_buffer_append_string(prefix_buffer, " ", 4);
7329
+ // numerator
7330
+ {
7301
7331
  pm_buffer_concat(output_buffer, prefix_buffer);
7302
- prettyprint_node(output_buffer, parser, (pm_node_t *) cast->numeric, prefix_buffer);
7303
- prefix_buffer->length = prefix_length;
7332
+ pm_buffer_append_string(output_buffer, "+-- numerator:", 14);
7333
+ const pm_integer_t *integer = &cast->numerator;
7334
+ pm_buffer_append_byte(output_buffer, ' ');
7335
+ pm_integer_string(output_buffer, integer);
7336
+ pm_buffer_append_byte(output_buffer, '\n');
7337
+ }
7338
+
7339
+ // denominator
7340
+ {
7341
+ pm_buffer_concat(output_buffer, prefix_buffer);
7342
+ pm_buffer_append_string(output_buffer, "+-- denominator:", 16);
7343
+ const pm_integer_t *integer = &cast->denominator;
7344
+ pm_buffer_append_byte(output_buffer, ' ');
7345
+ pm_integer_string(output_buffer, integer);
7346
+ pm_buffer_append_byte(output_buffer, '\n');
7304
7347
  }
7305
7348
 
7306
7349
  break;