prism 2.0.0.rc2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -41
  3. data/Makefile +8 -8
  4. data/README.md +3 -1
  5. data/docs/fuzzing.md +5 -5
  6. data/docs/serialization.md +19 -6
  7. data/ext/prism/api_node.c +80 -80
  8. data/ext/prism/extension.c +34 -67
  9. data/ext/prism/extension.h +1 -1
  10. data/include/prism/arena.h +8 -0
  11. data/include/prism/arena.hpp +42 -0
  12. data/include/prism/ast.h +11 -1
  13. data/include/prism/ast.hpp +641 -0
  14. data/include/prism/buffer.h +8 -0
  15. data/include/prism/buffer.hpp +55 -0
  16. data/include/prism/comments.h +17 -0
  17. data/include/prism/compiler/branch.h +26 -0
  18. data/include/prism/compiler/cplusplus.hpp +16 -0
  19. data/include/prism/compiler/exceptions.hpp +17 -0
  20. data/include/prism/compiler/format.h +2 -0
  21. data/include/prism/compiler/lifetimebound.hpp +25 -0
  22. data/include/prism/constant_pool.h +25 -0
  23. data/include/prism/diagnostic.h +18 -0
  24. data/include/prism/errors_format.h +8 -0
  25. data/include/prism/internal/comments.h +2 -1
  26. data/include/prism/internal/node.h +8 -4
  27. data/include/prism/internal/parser.h +26 -15
  28. data/include/prism/internal/static_literals.h +24 -64
  29. data/include/prism/internal/stringy.h +1 -6
  30. data/include/prism/json.h +8 -0
  31. data/include/prism/line_offset_list.h +8 -0
  32. data/include/prism/magic_comments.h +18 -0
  33. data/include/prism/node.h +55 -10
  34. data/include/prism/node.hpp +272 -0
  35. data/include/prism/node_type.hpp +38 -0
  36. data/include/prism/options.h +10 -1
  37. data/include/prism/options.hpp +43 -0
  38. data/include/prism/parser.h +72 -64
  39. data/include/prism/parser.hpp +274 -0
  40. data/include/prism/prettyprint.h +8 -0
  41. data/include/prism/serialize.h +8 -0
  42. data/include/prism/source.h +8 -0
  43. data/include/prism/stream.h +8 -0
  44. data/include/prism/string_query.h +8 -0
  45. data/include/prism/stringy.h +16 -27
  46. data/include/prism/stringy.hpp +31 -0
  47. data/include/prism/version.h +10 -2
  48. data/include/prism.h +0 -8
  49. data/include/prism.hpp +24 -0
  50. data/lib/prism/serialize.rb +2550 -3282
  51. data/prism.gemspec +14 -1
  52. data/rbi/generated/prism/node.rbi +736 -0
  53. data/rbi/generated/prism/serialize.rbi +6 -5
  54. data/sig/generated/prism/node.rbs +736 -0
  55. data/sig/generated/prism/serialize.rbs +7 -5
  56. data/src/arena.c +6 -1
  57. data/src/comments.c +11 -10
  58. data/src/diagnostic.c +24 -4
  59. data/src/integer.c +6 -1
  60. data/src/node.c +216 -368
  61. data/src/options.c +7 -13
  62. data/src/parser.c +52 -48
  63. data/src/prism.c +222 -240
  64. data/src/regexp.c +0 -1
  65. data/src/serialize.c +2300 -1950
  66. data/src/source.c +8 -2
  67. data/src/static_literals.c +280 -405
  68. data/src/stringy.c +3 -33
  69. metadata +14 -1
data/src/source.c CHANGED
@@ -377,7 +377,13 @@ pm_source_stream_read(pm_source_t *source) {
377
377
  */
378
378
  #define LINE_FILL 0xff
379
379
 
380
- while (memset(line, LINE_FILL, LINE_SIZE), source->stream.fgets(line, LINE_SIZE, source->stream.stream) != NULL) {
380
+ /*
381
+ * The fgets and feof members share their names with standard library
382
+ * functions, which <stdio.h> may define as function-like macros (newlib on
383
+ * Cygwin does this for feof). Parenthesizing the member access keeps those
384
+ * macros from expanding at the call sites.
385
+ */
386
+ while (memset(line, LINE_FILL, LINE_SIZE), (source->stream.fgets)(line, LINE_SIZE, source->stream.stream) != NULL) {
381
387
  /*
382
388
  * Locate the NUL terminator written by fgets (the last NUL in the
383
389
  * buffer) to recover the length of the chunk, then drop the terminator.
@@ -408,7 +414,7 @@ pm_source_stream_read(pm_source_t *source) {
408
414
  * EOF. A newline-terminated line needs no such check: if it happens to
409
415
  * be the last line, the next fgets returns NULL and ends the loop.
410
416
  */
411
- if (!newline && !source->stream.feof(source->stream.stream)) {
417
+ if (!newline && !(source->stream.feof)(source->stream.stream)) {
412
418
  continue;
413
419
  }
414
420