prism 2.0.0.rc2-x86_64-linux-gnu → 2.1.0-x86_64-linux-gnu

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 (72) 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/3.3/prism.so +0 -0
  51. data/lib/prism/3.4/prism.so +0 -0
  52. data/lib/prism/4.0/prism.so +0 -0
  53. data/lib/prism/serialize.rb +2550 -3282
  54. data/prism.gemspec +14 -1
  55. data/rbi/generated/prism/node.rbi +736 -0
  56. data/rbi/generated/prism/serialize.rbi +6 -5
  57. data/sig/generated/prism/node.rbs +736 -0
  58. data/sig/generated/prism/serialize.rbs +7 -5
  59. data/src/arena.c +6 -1
  60. data/src/comments.c +11 -10
  61. data/src/diagnostic.c +24 -4
  62. data/src/integer.c +6 -1
  63. data/src/node.c +216 -368
  64. data/src/options.c +7 -13
  65. data/src/parser.c +52 -48
  66. data/src/prism.c +222 -240
  67. data/src/regexp.c +0 -1
  68. data/src/serialize.c +2300 -1950
  69. data/src/source.c +8 -2
  70. data/src/static_literals.c +280 -405
  71. data/src/stringy.c +3 -33
  72. metadata +14 -1
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @file stringy.hpp
3
+ *
4
+ * Access to the contents of strings from C++.
5
+ */
6
+ #ifndef PRISM_STRINGY_HPP
7
+ #define PRISM_STRINGY_HPP
8
+
9
+ #include "prism/compiler/cplusplus.hpp"
10
+ #include "prism/compiler/lifetimebound.hpp"
11
+
12
+ #include "prism/stringy.h"
13
+
14
+ #include <string_view>
15
+
16
+ namespace prism {
17
+
18
+ /**
19
+ * The bytes of the given string.
20
+ *
21
+ * @param string The string to view.
22
+ * @return A view of the bytes of the string.
23
+ */
24
+ [[nodiscard]] inline std::string_view
25
+ view(const pm_string_t &string PRISM_LIFETIMEBOUND) noexcept {
26
+ return std::string_view(reinterpret_cast<const char *>(pm_string_source(&string)), pm_string_length(&string));
27
+ }
28
+
29
+ }
30
+
31
+ #endif
@@ -8,6 +8,10 @@
8
8
 
9
9
  #include "prism/compiler/exported.h"
10
10
 
11
+ #ifdef __cplusplus
12
+ extern "C" {
13
+ #endif
14
+
11
15
  /**
12
16
  * The major version of the Prism library as an int.
13
17
  */
@@ -16,7 +20,7 @@
16
20
  /**
17
21
  * The minor version of the Prism library as an int.
18
22
  */
19
- #define PRISM_VERSION_MINOR 0
23
+ #define PRISM_VERSION_MINOR 1
20
24
 
21
25
  /**
22
26
  * The patch version of the Prism library as an int.
@@ -26,7 +30,7 @@
26
30
  /**
27
31
  * The version of the Prism library as a constant string.
28
32
  */
29
- #define PRISM_VERSION "2.0.0.rc2"
33
+ #define PRISM_VERSION "2.1.0"
30
34
 
31
35
  /**
32
36
  * The prism version and the serialization format.
@@ -35,4 +39,8 @@
35
39
  */
36
40
  PRISM_EXPORTED_FUNCTION const char * pm_version(void);
37
41
 
42
+ #ifdef __cplusplus
43
+ }
44
+ #endif
45
+
38
46
  #endif
data/include/prism.h CHANGED
@@ -6,10 +6,6 @@
6
6
  #ifndef PRISM_H
7
7
  #define PRISM_H
8
8
 
9
- #ifdef __cplusplus
10
- extern "C" {
11
- #endif
12
-
13
9
  #include "prism/arena.h"
14
10
  #include "prism/ast.h"
15
11
  #include "prism/buffer.h"
@@ -124,8 +120,4 @@ extern "C" {
124
120
  * ```
125
121
  */
126
122
 
127
- #ifdef __cplusplus
128
- }
129
- #endif
130
-
131
123
  #endif
data/include/prism.hpp ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @file prism.hpp
3
+ *
4
+ * The main header file for the C++ interface to the prism parser. It adds
5
+ * ownership, checked casts between node types, and callable-based iteration on
6
+ * top of the C API. It never wraps the C structs: every function in it takes
7
+ * and returns the same pm_*_t types that prism.h declares, so the two can be
8
+ * mixed freely. It requires C++17 or later.
9
+ */
10
+ #ifndef PRISM_HPP
11
+ #define PRISM_HPP
12
+
13
+ #include "prism.h"
14
+
15
+ #include "prism/arena.hpp"
16
+ #include "prism/ast.hpp"
17
+ #include "prism/buffer.hpp"
18
+ #include "prism/node.hpp"
19
+ #include "prism/node_type.hpp"
20
+ #include "prism/options.hpp"
21
+ #include "prism/parser.hpp"
22
+ #include "prism/stringy.hpp"
23
+
24
+ #endif
Binary file
Binary file
Binary file