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
data/src/node.c CHANGED
@@ -244,6 +244,18 @@ pm_node_destroy(pm_parser_t *parser, pm_node_t *node) {
244
244
  pm_node_destroy(parser, (pm_node_t *)cast->target);
245
245
  break;
246
246
  }
247
+ #line 58 "node.c.erb"
248
+ case PM_CASE_MATCH_NODE: {
249
+ pm_case_match_node_t *cast = (pm_case_match_node_t *) node;
250
+ if (cast->predicate != NULL) {
251
+ pm_node_destroy(parser, (pm_node_t *)cast->predicate);
252
+ }
253
+ pm_node_list_free(parser, &cast->conditions);
254
+ if (cast->consequent != NULL) {
255
+ pm_node_destroy(parser, (pm_node_t *)cast->consequent);
256
+ }
257
+ break;
258
+ }
247
259
  #line 58 "node.c.erb"
248
260
  case PM_CASE_NODE: {
249
261
  pm_case_node_t *cast = (pm_case_node_t *) node;
@@ -758,7 +770,7 @@ pm_node_destroy(pm_parser_t *parser, pm_node_t *node) {
758
770
  case PM_MATCH_WRITE_NODE: {
759
771
  pm_match_write_node_t *cast = (pm_match_write_node_t *) node;
760
772
  pm_node_destroy(parser, (pm_node_t *)cast->call);
761
- pm_constant_id_list_free(&cast->locals);
773
+ pm_node_list_free(parser, &cast->targets);
762
774
  break;
763
775
  }
764
776
  #line 58 "node.c.erb"
@@ -1011,13 +1023,6 @@ pm_node_destroy(pm_parser_t *parser, pm_node_t *node) {
1011
1023
  pm_node_list_free(parser, &cast->body);
1012
1024
  break;
1013
1025
  }
1014
- #line 58 "node.c.erb"
1015
- case PM_STRING_CONCAT_NODE: {
1016
- pm_string_concat_node_t *cast = (pm_string_concat_node_t *) node;
1017
- pm_node_destroy(parser, (pm_node_t *)cast->left);
1018
- pm_node_destroy(parser, (pm_node_t *)cast->right);
1019
- break;
1020
- }
1021
1026
  #line 58 "node.c.erb"
1022
1027
  case PM_STRING_NODE: {
1023
1028
  pm_string_node_t *cast = (pm_string_node_t *) node;
@@ -1340,6 +1345,21 @@ pm_node_memsize_node(pm_node_t *node, pm_memsize_t *memsize) {
1340
1345
  pm_node_memsize_node((pm_node_t *)cast->target, memsize);
1341
1346
  break;
1342
1347
  }
1348
+ #line 103 "node.c.erb"
1349
+ case PM_CASE_MATCH_NODE: {
1350
+ pm_case_match_node_t *cast = (pm_case_match_node_t *) node;
1351
+ memsize->memsize += sizeof(*cast);
1352
+ // Node lists will add in their own sizes below.
1353
+ memsize->memsize -= sizeof(pm_node_list_t) * 1;
1354
+ if (cast->predicate != NULL) {
1355
+ pm_node_memsize_node((pm_node_t *)cast->predicate, memsize);
1356
+ }
1357
+ memsize->memsize += pm_node_list_memsize(&cast->conditions, memsize);
1358
+ if (cast->consequent != NULL) {
1359
+ pm_node_memsize_node((pm_node_t *)cast->consequent, memsize);
1360
+ }
1361
+ break;
1362
+ }
1343
1363
  #line 103 "node.c.erb"
1344
1364
  case PM_CASE_NODE: {
1345
1365
  pm_case_node_t *cast = (pm_case_node_t *) node;
@@ -1969,10 +1989,10 @@ pm_node_memsize_node(pm_node_t *node, pm_memsize_t *memsize) {
1969
1989
  case PM_MATCH_WRITE_NODE: {
1970
1990
  pm_match_write_node_t *cast = (pm_match_write_node_t *) node;
1971
1991
  memsize->memsize += sizeof(*cast);
1972
- // Constant id lists will add in their own sizes below.
1973
- memsize->memsize -= sizeof(pm_constant_id_list_t) * 1;
1992
+ // Node lists will add in their own sizes below.
1993
+ memsize->memsize -= sizeof(pm_node_list_t) * 1;
1974
1994
  pm_node_memsize_node((pm_node_t *)cast->call, memsize);
1975
- memsize->memsize += pm_constant_id_list_memsize(&cast->locals);
1995
+ memsize->memsize += pm_node_list_memsize(&cast->targets, memsize);
1976
1996
  break;
1977
1997
  }
1978
1998
  #line 103 "node.c.erb"
@@ -2289,14 +2309,6 @@ pm_node_memsize_node(pm_node_t *node, pm_memsize_t *memsize) {
2289
2309
  memsize->memsize += pm_node_list_memsize(&cast->body, memsize);
2290
2310
  break;
2291
2311
  }
2292
- #line 103 "node.c.erb"
2293
- case PM_STRING_CONCAT_NODE: {
2294
- pm_string_concat_node_t *cast = (pm_string_concat_node_t *) node;
2295
- memsize->memsize += sizeof(*cast);
2296
- pm_node_memsize_node((pm_node_t *)cast->left, memsize);
2297
- pm_node_memsize_node((pm_node_t *)cast->right, memsize);
2298
- break;
2299
- }
2300
2312
  #line 103 "node.c.erb"
2301
2313
  case PM_STRING_NODE: {
2302
2314
  pm_string_node_t *cast = (pm_string_node_t *) node;
@@ -2463,6 +2475,8 @@ pm_node_type_to_str(pm_node_type_t node_type)
2463
2475
  return "PM_CALL_OR_WRITE_NODE";
2464
2476
  case PM_CAPTURE_PATTERN_NODE:
2465
2477
  return "PM_CAPTURE_PATTERN_NODE";
2478
+ case PM_CASE_MATCH_NODE:
2479
+ return "PM_CASE_MATCH_NODE";
2466
2480
  case PM_CASE_NODE:
2467
2481
  return "PM_CASE_NODE";
2468
2482
  case PM_CLASS_NODE:
@@ -2683,8 +2697,6 @@ pm_node_type_to_str(pm_node_type_t node_type)
2683
2697
  return "PM_SPLAT_NODE";
2684
2698
  case PM_STATEMENTS_NODE:
2685
2699
  return "PM_STATEMENTS_NODE";
2686
- case PM_STRING_CONCAT_NODE:
2687
- return "PM_STRING_CONCAT_NODE";
2688
2700
  case PM_STRING_NODE:
2689
2701
  return "PM_STRING_NODE";
2690
2702
  case PM_SUPER_NODE: