prism 0.17.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +60 -1
  3. data/Makefile +5 -5
  4. data/README.md +4 -3
  5. data/config.yml +214 -68
  6. data/docs/build_system.md +6 -6
  7. data/docs/building.md +10 -3
  8. data/docs/configuration.md +11 -9
  9. data/docs/encoding.md +92 -88
  10. data/docs/heredocs.md +1 -1
  11. data/docs/javascript.md +29 -1
  12. data/docs/local_variable_depth.md +229 -0
  13. data/docs/ruby_api.md +16 -0
  14. data/docs/serialization.md +18 -13
  15. data/ext/prism/api_node.c +411 -240
  16. data/ext/prism/extconf.rb +97 -127
  17. data/ext/prism/extension.c +97 -33
  18. data/ext/prism/extension.h +1 -1
  19. data/include/prism/ast.h +377 -159
  20. data/include/prism/defines.h +17 -0
  21. data/include/prism/diagnostic.h +38 -6
  22. data/include/prism/{enc/pm_encoding.h → encoding.h} +126 -64
  23. data/include/prism/options.h +2 -2
  24. data/include/prism/parser.h +62 -36
  25. data/include/prism/regexp.h +2 -2
  26. data/include/prism/util/pm_buffer.h +9 -1
  27. data/include/prism/util/pm_memchr.h +2 -2
  28. data/include/prism/util/pm_strpbrk.h +3 -3
  29. data/include/prism/version.h +3 -3
  30. data/include/prism.h +13 -15
  31. data/lib/prism/compiler.rb +15 -3
  32. data/lib/prism/debug.rb +13 -4
  33. data/lib/prism/desugar_compiler.rb +4 -3
  34. data/lib/prism/dispatcher.rb +70 -14
  35. data/lib/prism/dot_visitor.rb +4612 -0
  36. data/lib/prism/dsl.rb +77 -57
  37. data/lib/prism/ffi.rb +19 -6
  38. data/lib/prism/lex_compat.rb +19 -9
  39. data/lib/prism/mutation_compiler.rb +26 -6
  40. data/lib/prism/node.rb +1314 -522
  41. data/lib/prism/node_ext.rb +102 -19
  42. data/lib/prism/parse_result.rb +58 -27
  43. data/lib/prism/ripper_compat.rb +49 -34
  44. data/lib/prism/serialize.rb +251 -227
  45. data/lib/prism/visitor.rb +15 -3
  46. data/lib/prism.rb +21 -4
  47. data/prism.gemspec +7 -9
  48. data/rbi/prism.rbi +688 -284
  49. data/rbi/prism_static.rbi +3 -0
  50. data/sig/prism.rbs +426 -156
  51. data/sig/prism_static.rbs +1 -0
  52. data/src/diagnostic.c +280 -216
  53. data/src/encoding.c +5137 -0
  54. data/src/node.c +99 -21
  55. data/src/options.c +21 -2
  56. data/src/prettyprint.c +1743 -1241
  57. data/src/prism.c +1774 -831
  58. data/src/regexp.c +15 -15
  59. data/src/serialize.c +261 -164
  60. data/src/util/pm_buffer.c +10 -1
  61. data/src/util/pm_memchr.c +1 -1
  62. data/src/util/pm_strpbrk.c +4 -4
  63. metadata +8 -10
  64. data/src/enc/pm_big5.c +0 -53
  65. data/src/enc/pm_euc_jp.c +0 -59
  66. data/src/enc/pm_gbk.c +0 -62
  67. data/src/enc/pm_shift_jis.c +0 -57
  68. data/src/enc/pm_tables.c +0 -743
  69. data/src/enc/pm_unicode.c +0 -2369
  70. data/src/enc/pm_windows_31j.c +0 -57
data/src/regexp.c CHANGED
@@ -20,14 +20,14 @@ typedef struct {
20
20
  bool encoding_changed;
21
21
 
22
22
  /** The encoding of the source. */
23
- pm_encoding_t *encoding;
23
+ const pm_encoding_t *encoding;
24
24
  } pm_regexp_parser_t;
25
25
 
26
26
  /**
27
27
  * This initializes a new parser with the given source.
28
28
  */
29
29
  static void
30
- pm_regexp_parser_init(pm_regexp_parser_t *parser, const uint8_t *start, const uint8_t *end, pm_string_list_t *named_captures, bool encoding_changed, pm_encoding_t *encoding) {
30
+ pm_regexp_parser_init(pm_regexp_parser_t *parser, const uint8_t *start, const uint8_t *end, pm_string_list_t *named_captures, bool encoding_changed, const pm_encoding_t *encoding) {
31
31
  *parser = (pm_regexp_parser_t) {
32
32
  .start = start,
33
33
  .cursor = start,
@@ -116,18 +116,18 @@ pm_regexp_char_find(pm_regexp_parser_t *parser, uint8_t value) {
116
116
  * The properly track everything, we're going to build a little state machine.
117
117
  * It looks something like the following:
118
118
  *
119
- * ┌───────┐ ┌─────────┐ ────────────┐
120
- * ──── lbrace ───> start ──── digit ───> minimum
121
- * └───────┘ └─────────┘ <─── digit ─┘
122
- *
123
- * ┌───────┐ rbrace
124
- * comma <───── comma ┌──── comma ───────┘
125
- * └───────┘ V V
126
- * ┌─────────┐ ┌─────────┐
127
- * └── digit ──> maximum ── rbrace ──> │| final |│
128
- * └─────────┘ └─────────┘
129
- * ^
130
- * └─ digit ─┘
119
+ * +-------+ +---------+ ------------+
120
+ * ---- lbrace ---> | start | ---- digit ---> | minimum | |
121
+ * +-------+ +---------+ <--- digit -+
122
+ * | | |
123
+ * +-------+ | | rbrace
124
+ * | comma | <----- comma +---- comma -------+ |
125
+ * +-------+ V V
126
+ * | +---------+ +---------+
127
+ * +-- digit --> | maximum | -- rbrace --> || final ||
128
+ * +---------+ +---------+
129
+ * | ^
130
+ * +- digit -+
131
131
  *
132
132
  * Note that by the time we've hit this function, the lbrace has already been
133
133
  * consumed so we're in the start state.
@@ -631,7 +631,7 @@ pm_regexp_parse_pattern(pm_regexp_parser_t *parser) {
631
631
  * groups.
632
632
  */
633
633
  PRISM_EXPORTED_FUNCTION bool
634
- pm_regexp_named_capture_group_names(const uint8_t *source, size_t size, pm_string_list_t *named_captures, bool encoding_changed, pm_encoding_t *encoding) {
634
+ pm_regexp_named_capture_group_names(const uint8_t *source, size_t size, pm_string_list_t *named_captures, bool encoding_changed, const pm_encoding_t *encoding) {
635
635
  pm_regexp_parser_t parser;
636
636
  pm_regexp_parser_init(&parser, source, source + size, named_captures, encoding_changed, encoding);
637
637
  return pm_regexp_parse_pattern(&parser);