datadog-ruby_core_source 3.5.4 → 3.5.6

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 (198) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -2
  3. data/datadog-ruby_core_source.gemspec +1 -1
  4. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/build_assert/build_assert.h +40 -0
  5. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/check_type/check_type.h +63 -0
  6. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/container_of/container_of.h +142 -0
  7. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/list/list.h +788 -0
  8. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ccan/str/str.h +16 -0
  9. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/id.h +252 -0
  10. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/internal.h +2465 -0
  11. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/iseq.h +304 -0
  12. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/method.h +229 -0
  13. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/node.h +449 -0
  14. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_assert.h +60 -0
  15. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/ruby_atomic.h +244 -0
  16. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_pthread.h +75 -0
  17. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/thread_win32.h +36 -0
  18. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_core.h +1902 -0
  19. data/lib/datadog/ruby_core_source/ruby-2.6.0-p0/vm_opts.h +70 -0
  20. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/build_assert/build_assert.h +40 -0
  21. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/check_type/check_type.h +63 -0
  22. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/container_of/container_of.h +142 -0
  23. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/list/list.h +788 -0
  24. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ccan/str/str.h +16 -0
  25. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/id.h +290 -0
  26. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/internal.h +2697 -0
  27. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/iseq.h +312 -0
  28. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/method.h +229 -0
  29. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/node.h +476 -0
  30. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_assert.h +15 -0
  31. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/ruby_atomic.h +244 -0
  32. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_pthread.h +75 -0
  33. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/thread_win32.h +36 -0
  34. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_core.h +1968 -0
  35. data/lib/datadog/ruby_core_source/ruby-2.7.0-p0/vm_opts.h +72 -0
  36. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/build_assert/build_assert.h +40 -0
  37. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/check_type/check_type.h +63 -0
  38. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/container_of/container_of.h +142 -0
  39. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/list/list.h +788 -0
  40. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ccan/str/str.h +16 -0
  41. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id.h +290 -0
  42. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/id_table.h +36 -0
  43. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/array.h +119 -0
  44. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/class.h +174 -0
  45. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/compilers.h +108 -0
  46. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/gc.h +161 -0
  47. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/imemo.h +243 -0
  48. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/serial.h +24 -0
  49. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/static_assert.h +17 -0
  50. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/vm.h +136 -0
  51. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal/warnings.h +17 -0
  52. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/internal.h +107 -0
  53. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/iseq.h +305 -0
  54. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/method.h +245 -0
  55. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/node.h +484 -0
  56. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ractor_core.h +343 -0
  57. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_assert.h +15 -0
  58. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/ruby_atomic.h +23 -0
  59. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_pthread.h +115 -0
  60. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/thread_win32.h +61 -0
  61. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_core.h +2023 -0
  62. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_debug.h +116 -0
  63. data/lib/datadog/ruby_core_source/ruby-3.0.0-p0/vm_opts.h +73 -0
  64. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/build_assert/build_assert.h +40 -0
  65. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/check_type/check_type.h +63 -0
  66. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/container_of/container_of.h +142 -0
  67. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/list/list.h +788 -0
  68. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ccan/str/str.h +16 -0
  69. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/darray.h +198 -0
  70. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id.h +293 -0
  71. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/id_table.h +36 -0
  72. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/array.h +113 -0
  73. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/class.h +196 -0
  74. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/compilers.h +107 -0
  75. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/gc.h +186 -0
  76. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/imemo.h +243 -0
  77. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/serial.h +23 -0
  78. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/static_assert.h +16 -0
  79. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/vm.h +133 -0
  80. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal/warnings.h +16 -0
  81. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/internal.h +109 -0
  82. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/iseq.h +322 -0
  83. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/method.h +253 -0
  84. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/node.h +510 -0
  85. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ractor_core.h +346 -0
  86. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_assert.h +14 -0
  87. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/ruby_atomic.h +23 -0
  88. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/thread_pthread.h +115 -0
  89. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_core.h +2107 -0
  90. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_debug.h +124 -0
  91. data/lib/datadog/ruby_core_source/ruby-3.1.0-p0/vm_opts.h +73 -0
  92. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/build_assert/build_assert.h +40 -0
  93. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/check_type/check_type.h +63 -0
  94. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/container_of/container_of.h +142 -0
  95. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/list/list.h +789 -0
  96. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ccan/str/str.h +17 -0
  97. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id.h +299 -0
  98. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/id_table.h +39 -0
  99. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/array.h +163 -0
  100. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/basic_operators.h +64 -0
  101. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/class.h +182 -0
  102. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/compilers.h +107 -0
  103. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/gc.h +192 -0
  104. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/imemo.h +242 -0
  105. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/serial.h +23 -0
  106. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/static_assert.h +16 -0
  107. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/vm.h +134 -0
  108. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal/warnings.h +16 -0
  109. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/internal.h +113 -0
  110. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/iseq.h +329 -0
  111. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/method.h +254 -0
  112. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/node.h +514 -0
  113. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ractor_core.h +342 -0
  114. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_assert.h +14 -0
  115. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/ruby_atomic.h +23 -0
  116. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/shape.h +232 -0
  117. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_none.h +20 -0
  118. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/thread_pthread.h +133 -0
  119. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_core.h +2106 -0
  120. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_debug.h +122 -0
  121. data/lib/datadog/ruby_core_source/ruby-3.2.0-p0/vm_opts.h +73 -0
  122. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/build_assert/build_assert.h +40 -0
  123. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/check_type/check_type.h +63 -0
  124. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/container_of/container_of.h +142 -0
  125. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/list/list.h +791 -0
  126. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ccan/str/str.h +17 -0
  127. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/constant.h +53 -0
  128. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/debug_counter.h +428 -0
  129. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/hrtime.h +237 -0
  130. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/id.h +365 -0
  131. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/id_table.h +74 -0
  132. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/array.h +158 -0
  133. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/basic_operators.h +67 -0
  134. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/bits.h +647 -0
  135. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/box.h +103 -0
  136. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/class.h +797 -0
  137. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/compilers.h +104 -0
  138. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/coverage.h +51 -0
  139. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/gc.h +411 -0
  140. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/imemo.h +302 -0
  141. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/sanitizers.h +346 -0
  142. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/serial.h +23 -0
  143. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/set_table.h +77 -0
  144. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/static_assert.h +16 -0
  145. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/time.h +34 -0
  146. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/variable.h +81 -0
  147. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/vm.h +144 -0
  148. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal/warnings.h +16 -0
  149. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/internal.h +106 -0
  150. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/iseq.h +439 -0
  151. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/method.h +279 -0
  152. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/node.h +122 -0
  153. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/parser_st.h +161 -0
  154. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/parser_value.h +116 -0
  155. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/arena.h +37 -0
  156. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/ast.h +10371 -0
  157. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/buffer.h +52 -0
  158. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/comments.h +43 -0
  159. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/align.h +36 -0
  160. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/exported.h +24 -0
  161. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/filesystem.h +32 -0
  162. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nodiscard.h +22 -0
  163. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nonnull.h +18 -0
  164. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/constant_pool.h +81 -0
  165. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/diagnostic.h +93 -0
  166. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/errors_format.h +53 -0
  167. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/excludes.h +29 -0
  168. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/integer.h +41 -0
  169. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/json.h +32 -0
  170. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/line_offset_list.h +61 -0
  171. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/magic_comments.h +35 -0
  172. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/node.h +94 -0
  173. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/options.h +335 -0
  174. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/parser.h +348 -0
  175. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/prettyprint.h +31 -0
  176. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/prism.h +131 -0
  177. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/serialize.h +115 -0
  178. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/source.h +155 -0
  179. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/stream.h +28 -0
  180. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/string_query.h +63 -0
  181. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/stringy.h +72 -0
  182. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism/version.h +38 -0
  183. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/prism_compile.h +204 -0
  184. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ractor_core.h +421 -0
  185. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ruby_assert.h +14 -0
  186. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/ruby_atomic.h +115 -0
  187. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/rubyparser.h +1389 -0
  188. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/shape.h +733 -0
  189. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_none.h +25 -0
  190. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_pthread.h +63 -0
  191. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/thread_sched.h +271 -0
  192. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_core.h +2509 -0
  193. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_debug.h +124 -0
  194. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_opts.h +65 -0
  195. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/vm_sync.h +160 -0
  196. data/lib/datadog/ruby_core_source/ruby-4.1.0-preview1/zjit.h +221 -0
  197. data/lib/datadog/ruby_core_source/version.rb +1 -1
  198. metadata +197 -4
@@ -0,0 +1,348 @@
1
+ /**
2
+ * @file parser.h
3
+ *
4
+ * The parser used to parse Ruby source.
5
+ */
6
+ #ifndef PRISM_PARSER_H
7
+ #define PRISM_PARSER_H
8
+
9
+ #include "prism/compiler/nodiscard.h"
10
+ #include "prism/compiler/nonnull.h"
11
+
12
+ #include "prism/ast.h"
13
+ #include "prism/comments.h"
14
+ #include "prism/diagnostic.h"
15
+ #include "prism/line_offset_list.h"
16
+ #include "prism/magic_comments.h"
17
+ #include "prism/options.h"
18
+
19
+ /**
20
+ * The parser used to parse Ruby source.
21
+ */
22
+ typedef struct pm_parser_t pm_parser_t;
23
+
24
+ /**
25
+ * Allocate and initialize a parser with the given start and end pointers.
26
+ *
27
+ * @param arena The arena to use for all AST-lifetime allocations. It is caller-
28
+ * owned and must outlive the parser.
29
+ * @param source The source to parse.
30
+ * @param size The size of the source.
31
+ * @param options The optional options to use when parsing. These options must
32
+ * live for the whole lifetime of this parser.
33
+ * @returns The initialized parser. It is the responsibility of the caller to
34
+ * free the parser with `pm_parser_free()`.
35
+ */
36
+ PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_parser_t * pm_parser_new(pm_arena_t *arena, const uint8_t *source, size_t size, const pm_options_t *options) PRISM_NONNULL(1);
37
+
38
+ /**
39
+ * Free both the memory held by the given parser and the parser itself.
40
+ *
41
+ * @param parser The parser to free.
42
+ */
43
+ PRISM_EXPORTED_FUNCTION void pm_parser_free(pm_parser_t *parser) PRISM_NONNULL(1);
44
+
45
+ /**
46
+ * When the encoding that is being used to parse the source is changed by prism,
47
+ * we provide the ability here to call out to a user-defined function.
48
+ */
49
+ typedef void (*pm_encoding_changed_callback_t)(pm_parser_t *parser);
50
+
51
+ /**
52
+ * This is the callback that is called when a token is lexed. It is passed
53
+ * the opaque data pointer, the parser, and the token that was lexed.
54
+ */
55
+ typedef void (*pm_lex_callback_t)(pm_parser_t *parser, pm_token_t *token, void *data);
56
+
57
+ /**
58
+ * Register a callback that will be called whenever prism changes the encoding
59
+ * it is using to parse based on the magic comment.
60
+ *
61
+ * @param parser The parser to register the callback with.
62
+ * @param callback The callback to register.
63
+ */
64
+ PRISM_EXPORTED_FUNCTION void pm_parser_encoding_changed_callback_set(pm_parser_t *parser, pm_encoding_changed_callback_t callback) PRISM_NONNULL(1);
65
+
66
+ /**
67
+ * Register a callback that will be called whenever a token is lexed.
68
+ *
69
+ * @param parser The parser to register the callback with.
70
+ * @param data The opaque data to pass to the callback when it is called.
71
+ * @param callback The callback to register.
72
+ */
73
+ PRISM_EXPORTED_FUNCTION void pm_parser_lex_callback_set(pm_parser_t *parser, pm_lex_callback_t callback, void *data) PRISM_NONNULL(1);
74
+
75
+ /**
76
+ * Returns the opaque data that is passed to the lex callback when it is called.
77
+ *
78
+ * @param parser The parser whose lex callback data we want to get.
79
+ * @returns The opaque data that is passed to the lex callback when it is called.
80
+ */
81
+ PRISM_EXPORTED_FUNCTION void * pm_parser_lex_callback_data(const pm_parser_t *parser) PRISM_NONNULL(1);
82
+
83
+ /**
84
+ * Returns the raw pointer to the start of the source that is being parsed.
85
+ *
86
+ * @param parser the parser whose start pointer we want to get
87
+ * @returns the raw pointer to the start of the source that is being parsed
88
+ */
89
+ PRISM_EXPORTED_FUNCTION const uint8_t * pm_parser_start(const pm_parser_t *parser) PRISM_NONNULL(1);
90
+
91
+ /**
92
+ * Returns the raw pointer to the end of the source that is being parsed.
93
+ *
94
+ * @param parser the parser whose end pointer we want to get
95
+ * @returns the raw pointer to the end of the source that is being parsed
96
+ */
97
+ PRISM_EXPORTED_FUNCTION const uint8_t * pm_parser_end(const pm_parser_t *parser) PRISM_NONNULL(1);
98
+
99
+ /**
100
+ * Returns the line that the parser was considered to have started on.
101
+ *
102
+ * @param parser the parser whose start line we want to get
103
+ * @returns the line that the parser was considered to have started on
104
+ */
105
+ PRISM_EXPORTED_FUNCTION int32_t pm_parser_start_line(const pm_parser_t *parser) PRISM_NONNULL(1);
106
+
107
+ /**
108
+ * Returns the name of the encoding that is being used to parse the source.
109
+ *
110
+ * @param parser the parser whose encoding name we want to get
111
+ * @returns the name of the encoding that is being used to parse the source
112
+ */
113
+ PRISM_EXPORTED_FUNCTION const char * pm_parser_encoding_name(const pm_parser_t *parser) PRISM_NONNULL(1);
114
+
115
+ /**
116
+ * Returns the width of the character at the given pointer in the encoding that
117
+ * is being used to parse the source.
118
+ *
119
+ * @param parser the parser whose encoding we want to use
120
+ * @param start a pointer to the start of the character
121
+ * @param remaining the number of bytes remaining in the source
122
+ * @returns the width of the character in bytes
123
+ */
124
+ PRISM_EXPORTED_FUNCTION size_t pm_parser_encoding_char_width(const pm_parser_t *parser, const uint8_t *start, ptrdiff_t remaining) PRISM_NONNULL(1, 2);
125
+
126
+ /**
127
+ * Returns whether or not the parser is using the US-ASCII encoding.
128
+ *
129
+ * @param parser the parser to check
130
+ * @returns true if the parser is using US-ASCII encoding, false otherwise
131
+ */
132
+ PRISM_EXPORTED_FUNCTION bool pm_parser_encoding_us_ascii(const pm_parser_t *parser) PRISM_NONNULL(1);
133
+
134
+ /**
135
+ * Returns the filepath that is being used to parse the source.
136
+ *
137
+ * @param parser the parser whose filepath we want to get
138
+ * @returns a pointer to the filepath string
139
+ */
140
+ PRISM_EXPORTED_FUNCTION const pm_string_t * pm_parser_filepath(const pm_parser_t *parser) PRISM_NONNULL(1);
141
+
142
+ /**
143
+ * Find a constant in the parser's constant pool. Returns the id of the
144
+ * constant, or 0 if the constant is not found.
145
+ *
146
+ * @param parser the parser whose constant pool we want to search
147
+ * @param start a pointer to the start of the string to search for
148
+ * @param length the length of the string to search for
149
+ * @returns the id of the constant, or 0 if the constant is not found
150
+ */
151
+ PRISM_EXPORTED_FUNCTION pm_constant_id_t pm_parser_constant_find(const pm_parser_t *parser, const uint8_t *start, size_t length) PRISM_NONNULL(1, 2);
152
+
153
+ /**
154
+ * Returns the frozen string literal value of the parser, as determined by the
155
+ * frozen_string_literal magic comment or the option set on the parser.
156
+ *
157
+ * @param parser the parser whose frozen string literal value we want to get
158
+ * @returns -1 if disabled, 0 if unset, 1 if enabled
159
+ */
160
+ PRISM_EXPORTED_FUNCTION int8_t pm_parser_frozen_string_literal(const pm_parser_t *parser) PRISM_NONNULL(1);
161
+
162
+ /**
163
+ * Returns the line offsets that are associated with the given parser.
164
+ *
165
+ * @param parser the parser whose line offsets we want to get
166
+ * @returns the line offsets that are associated with the given parser
167
+ */
168
+ PRISM_EXPORTED_FUNCTION const pm_line_offset_list_t * pm_parser_line_offsets(const pm_parser_t *parser) PRISM_NONNULL(1);
169
+
170
+ /**
171
+ * Returns the location of the __DATA__ section that is associated with the
172
+ * given parser.
173
+ *
174
+ * @param parser the parser whose data location we want to get
175
+ * @returns the location of the __DATA__ section that is associated with the
176
+ * given parser. If it is unset, then the length will be set to 0.
177
+ */
178
+ PRISM_EXPORTED_FUNCTION const pm_location_t * pm_parser_data_loc(const pm_parser_t *parser) PRISM_NONNULL(1);
179
+
180
+ /**
181
+ * Returns whether the given parser is continuable, meaning that it could become
182
+ * valid if more input were appended, as opposed to being definitively invalid.
183
+ *
184
+ * @param parser the parser whose continuable status we want to get
185
+ * @returns whether the given parser is continuable
186
+ */
187
+ PRISM_EXPORTED_FUNCTION bool pm_parser_continuable(const pm_parser_t *parser) PRISM_NONNULL(1);
188
+
189
+ /**
190
+ * Returns the lex state of the parser. Note that this is an internal detail,
191
+ * and we are purposefully not returning an instance of the internal enum that
192
+ * we use to track this. This is only exposed because we need it for some very
193
+ * niche use cases. Most consumers should avoid this function.
194
+ *
195
+ * @param parser the parser whose lex state we want to get
196
+ * @returns the lex state of the parser
197
+ */
198
+ PRISM_EXPORTED_FUNCTION int pm_parser_lex_state(const pm_parser_t *parser) PRISM_NONNULL(1);
199
+
200
+ /**
201
+ * Returns the number of comments associated with the given parser.
202
+ *
203
+ * @param parser the parser whose comments we want to get the size of
204
+ * @returns the number of comments associated with the given parser
205
+ */
206
+ PRISM_EXPORTED_FUNCTION size_t pm_parser_comments_size(const pm_parser_t *parser) PRISM_NONNULL(1);
207
+
208
+ /**
209
+ * A callback function that can be used to process comments found while parsing.
210
+ */
211
+ typedef void (*pm_comment_callback_t)(const pm_comment_t *comment, void *data);
212
+
213
+ /**
214
+ * Iterates over the comments associated with the given parser and calls the
215
+ * given callback for each comment.
216
+ *
217
+ * @param parser the parser whose comments we want to iterate over
218
+ * @param callback the callback function to call for each comment. This function
219
+ * will be passed a pointer to the comment and the data parameter passed to
220
+ * this function.
221
+ * @param data the data to pass to the callback function for each comment. This
222
+ * can be NULL if no data needs to be passed to the callback function.
223
+ */
224
+ PRISM_EXPORTED_FUNCTION void pm_parser_comments_each(const pm_parser_t *parser, pm_comment_callback_t callback, void *data) PRISM_NONNULL(1);
225
+
226
+ /**
227
+ * Returns the number of magic comments associated with the given parser.
228
+ *
229
+ * @param parser the parser whose magic comments we want to get the size of
230
+ * @returns the number of magic comments associated with the given parser
231
+ */
232
+ PRISM_EXPORTED_FUNCTION size_t pm_parser_magic_comments_size(const pm_parser_t *parser) PRISM_NONNULL(1);
233
+
234
+ /**
235
+ * A callback function that can be used to process magic comments found while parsing.
236
+ */
237
+ typedef void (*pm_magic_comment_callback_t)(const pm_magic_comment_t *magic_comment, void *data);
238
+
239
+ /**
240
+ * Iterates over the magic comments associated with the given parser and calls the
241
+ * given callback for each magic comment.
242
+ *
243
+ * @param parser the parser whose magic comments we want to iterate over
244
+ * @param callback the callback function to call for each magic comment. This
245
+ * function will be passed a pointer to the magic comment and the data
246
+ * parameter passed to this function.
247
+ * @param data the data to pass to the callback function for each magic comment.
248
+ * This can be NULL if no data needs to be passed to the callback function.
249
+ */
250
+ PRISM_EXPORTED_FUNCTION void pm_parser_magic_comments_each(const pm_parser_t *parser, pm_magic_comment_callback_t callback, void *data) PRISM_NONNULL(1);
251
+
252
+ /**
253
+ * Returns the number of errors associated with the given parser.
254
+ *
255
+ * @param parser the parser whose errors we want to get the size of
256
+ * @returns the number of errors associated with the given parser
257
+ */
258
+ PRISM_EXPORTED_FUNCTION size_t pm_parser_errors_size(const pm_parser_t *parser) PRISM_NONNULL(1);
259
+
260
+ /**
261
+ * Returns the number of warnings associated with the given parser.
262
+ *
263
+ * @param parser the parser whose warnings we want to get the size of
264
+ * @returns the number of warnings associated with the given parser
265
+ */
266
+ PRISM_EXPORTED_FUNCTION size_t pm_parser_warnings_size(const pm_parser_t *parser) PRISM_NONNULL(1);
267
+
268
+ /**
269
+ * A callback function that can be used to process diagnostics found while
270
+ * parsing.
271
+ */
272
+ typedef void (*pm_diagnostic_callback_t)(const pm_diagnostic_t *diagnostic, void *data);
273
+
274
+ /**
275
+ * Iterates over the errors associated with the given parser and calls the
276
+ * given callback for each error.
277
+ *
278
+ * @param parser the parser whose errors we want to iterate over
279
+ * @param callback the callback function to call for each error. This function
280
+ * will be passed a pointer to the error and the data parameter passed to
281
+ * this function.
282
+ * @param data the data to pass to the callback function for each error. This
283
+ * can be NULL if no data needs to be passed to the callback function.
284
+ */
285
+ PRISM_EXPORTED_FUNCTION void pm_parser_errors_each(const pm_parser_t *parser, pm_diagnostic_callback_t callback, void *data) PRISM_NONNULL(1);
286
+
287
+ /**
288
+ * Iterates over the warnings associated with the given parser and calls the
289
+ * given callback for each warning.
290
+ *
291
+ * @param parser the parser whose warnings we want to iterate over
292
+ * @param callback the callback function to call for each warning. This function
293
+ * will be passed a pointer to the warning and the data parameter passed to
294
+ * this function.
295
+ * @param data the data to pass to the callback function for each warning. This
296
+ * can be NULL if no data needs to be passed to the callback function.
297
+ */
298
+ PRISM_EXPORTED_FUNCTION void pm_parser_warnings_each(const pm_parser_t *parser, pm_diagnostic_callback_t callback, void *data) PRISM_NONNULL(1);
299
+
300
+ /**
301
+ * Returns the number of constants in the constant pool associated with the
302
+ * given parser.
303
+ *
304
+ * @param parser the parser whose constant pool constants we want to get the
305
+ * size of
306
+ * @returns the number of constants in the constant pool associated with the
307
+ * given parser
308
+ */
309
+ PRISM_EXPORTED_FUNCTION size_t pm_parser_constants_size(const pm_parser_t *parser) PRISM_NONNULL(1);
310
+
311
+ /**
312
+ * A callback function that can be used to process constants found while
313
+ * parsing.
314
+ */
315
+ typedef void (*pm_constant_callback_t)(const pm_constant_t *constant, void *data);
316
+
317
+ /**
318
+ * Iterates over the constants in the constant pool associated with the given
319
+ * parser and calls the given callback for each constant.
320
+ *
321
+ * @param parser the parser whose constants we want to iterate over
322
+ * @param callback the callback function to call for each constant. This function
323
+ * will be passed a pointer to the constant and the data parameter passed to
324
+ * this function.
325
+ * @param data the data to pass to the callback function for each constant. This
326
+ * can be NULL if no data needs to be passed to the callback function.
327
+ */
328
+ PRISM_EXPORTED_FUNCTION void pm_parser_constants_each(const pm_parser_t *parser, pm_constant_callback_t callback, void *data) PRISM_NONNULL(1);
329
+
330
+ /**
331
+ * Returns a pointer to the constant at the given id in the constant pool
332
+ * associated with the given parser.
333
+ *
334
+ * @param parser the parser whose constant pool we want to look up from
335
+ * @param constant_id the id of the constant to look up (1-based)
336
+ * @returns a pointer to the constant at the given id
337
+ */
338
+ PRISM_EXPORTED_FUNCTION const pm_constant_t * pm_parser_constant(const pm_parser_t *parser, pm_constant_id_t constant_id) PRISM_NONNULL(1);
339
+
340
+ /**
341
+ * Initiate the parser with the given parser.
342
+ *
343
+ * @param parser The parser to use.
344
+ * @returns The AST representing the source.
345
+ */
346
+ PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse(pm_parser_t *parser) PRISM_NONNULL(1);
347
+
348
+ #endif
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @file prettyprint.h
3
+ *
4
+ * An AST node pretty-printer.
5
+ */
6
+ #ifndef PRISM_PRETTYPRINT_H
7
+ #define PRISM_PRETTYPRINT_H
8
+
9
+ #include "prism/excludes.h"
10
+
11
+ #ifndef PRISM_EXCLUDE_PRETTYPRINT
12
+
13
+ #include "prism/compiler/exported.h"
14
+ #include "prism/compiler/nonnull.h"
15
+
16
+ #include "prism/ast.h"
17
+ #include "prism/buffer.h"
18
+ #include "prism/parser.h"
19
+
20
+ /**
21
+ * Pretty-prints the AST represented by the given node to the given buffer.
22
+ *
23
+ * @param output_buffer The buffer to write the pretty-printed AST to.
24
+ * @param parser The parser that parsed the AST.
25
+ * @param node The root node of the AST to pretty-print.
26
+ */
27
+ PRISM_EXPORTED_FUNCTION void pm_prettyprint(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm_node_t *node) PRISM_NONNULL(1, 2, 3);
28
+
29
+ #endif
30
+
31
+ #endif
@@ -0,0 +1,131 @@
1
+ /**
2
+ * @file prism.h
3
+ *
4
+ * The main header file for the prism parser.
5
+ */
6
+ #ifndef PRISM_H
7
+ #define PRISM_H
8
+
9
+ #ifdef __cplusplus
10
+ extern "C" {
11
+ #endif
12
+
13
+ #include "prism/arena.h"
14
+ #include "prism/ast.h"
15
+ #include "prism/buffer.h"
16
+ #include "prism/diagnostic.h"
17
+ #include "prism/errors_format.h"
18
+ #include "prism/json.h"
19
+ #include "prism/node.h"
20
+ #include "prism/options.h"
21
+ #include "prism/parser.h"
22
+ #include "prism/prettyprint.h"
23
+ #include "prism/serialize.h"
24
+ #include "prism/source.h"
25
+ #include "prism/stream.h"
26
+ #include "prism/string_query.h"
27
+ #include "prism/version.h"
28
+
29
+ /**
30
+ * @mainpage
31
+ *
32
+ * Prism is a parser for the Ruby programming language. It is designed to be
33
+ * portable, error tolerant, and maintainable. It is written in C99 and has no
34
+ * dependencies. It is currently being integrated into
35
+ * [CRuby](https://github.com/ruby/ruby),
36
+ * [JRuby](https://github.com/jruby/jruby),
37
+ * [TruffleRuby](https://github.com/truffleruby/truffleruby),
38
+ * [Sorbet](https://github.com/sorbet/sorbet), and
39
+ * [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree).
40
+ *
41
+ * @section getting-started Getting started
42
+ *
43
+ * If you're vendoring this project and compiling it statically then as long as
44
+ * you have a C99 compiler you will be fine. If you're linking against it as
45
+ * shared library, then you should compile with `-fvisibility=hidden` and
46
+ * `-DPRISM_EXPORT_SYMBOLS` to tell prism to make only its public interface
47
+ * visible.
48
+ *
49
+ * @section parsing Parsing
50
+ *
51
+ * In order to parse Ruby code, the functions that you are going to want to use
52
+ * and be aware of are:
53
+ *
54
+ * * `pm_arena_new()` - create a new arena to hold all AST-lifetime allocations
55
+ * * `pm_parser_new()` - allocate and initialize a new parser
56
+ * * `pm_parse()` - parse and return the root node
57
+ * * `pm_parser_free()` - free the parser and its internal memory
58
+ * * `pm_arena_free()` - free all AST-lifetime memory
59
+ *
60
+ * Putting all of this together would look something like:
61
+ *
62
+ * ```c
63
+ * void parse(const uint8_t *source, size_t length) {
64
+ * pm_arena_t *arena = pm_arena_new();
65
+ * pm_parser_t *parser = pm_parser_new(arena, source, length, NULL);
66
+ *
67
+ * pm_node_t *root = pm_parse(parser);
68
+ * printf("PARSED!\n");
69
+ *
70
+ * pm_parser_free(parser);
71
+ * pm_arena_free(arena);
72
+ * }
73
+ * ```
74
+ *
75
+ * All of the nodes "inherit" from `pm_node_t` by embedding those structures
76
+ * as their first member. This means you can downcast and upcast any node in the
77
+ * tree to a `pm_node_t`.
78
+ *
79
+ * @section serializing Serializing
80
+ *
81
+ * Prism provides the ability to serialize the AST and its related metadata into
82
+ * a binary format. This format is designed to be portable to different
83
+ * languages and runtimes so that you only need to make one FFI call in order to
84
+ * parse Ruby code. The functions that you are going to want to use and be
85
+ * aware of are:
86
+ *
87
+ * * `pm_buffer_new()` - create a new buffer
88
+ * * `pm_buffer_free()` - free the buffer and its internal memory
89
+ * * `pm_serialize_parse()` - parse and serialize the AST into a buffer
90
+ *
91
+ * Putting all of this together would look something like:
92
+ *
93
+ * ```c
94
+ * void serialize(const uint8_t *source, size_t length) {
95
+ * pm_buffer_t *buffer = pm_buffer_new();
96
+ *
97
+ * pm_serialize_parse(buffer, source, length, NULL);
98
+ * printf("SERIALIZED!\n");
99
+ *
100
+ * pm_buffer_free(buffer);
101
+ * }
102
+ * ```
103
+ *
104
+ * @section inspecting Inspecting
105
+ *
106
+ * Prism provides the ability to inspect the AST by pretty-printing nodes. You
107
+ * can do this with the `pm_prettyprint()` function, which you would use like:
108
+ *
109
+ * ```c
110
+ * void prettyprint(const uint8_t *source, size_t length) {
111
+ * pm_arena_t *arena = pm_arena_new();
112
+ * pm_parser_t *parser = pm_parser_new(arena, source, length, NULL);
113
+ *
114
+ * pm_node_t *root = pm_parse(parser);
115
+ * pm_buffer_t *buffer = pm_buffer_new();
116
+ *
117
+ * pm_prettyprint(buffer, parser, root);
118
+ * printf("%*.s\n", (int) pm_buffer_length(buffer), pm_buffer_value(buffer));
119
+ *
120
+ * pm_buffer_free(buffer);
121
+ * pm_parser_free(parser);
122
+ * pm_arena_free(arena);
123
+ * }
124
+ * ```
125
+ */
126
+
127
+ #ifdef __cplusplus
128
+ }
129
+ #endif
130
+
131
+ #endif
@@ -0,0 +1,115 @@
1
+ /**
2
+ * @file serialize.h
3
+ *
4
+ * The functions related to serializing the AST to a binary format.
5
+ */
6
+ #ifndef PRISM_SERIALIZE_H
7
+ #define PRISM_SERIALIZE_H
8
+
9
+ #include "prism/excludes.h"
10
+
11
+ /* We optionally support serializing to a binary string. For systems that do not
12
+ * want or need this functionality, it can be turned off with the
13
+ * PRISM_EXCLUDE_SERIALIZATION define. */
14
+ #ifndef PRISM_EXCLUDE_SERIALIZATION
15
+
16
+ #include "prism/compiler/exported.h"
17
+ #include "prism/compiler/nonnull.h"
18
+
19
+ #include "prism/buffer.h"
20
+ #include "prism/errors_format.h"
21
+ #include "prism/parser.h"
22
+ #include "prism/source.h"
23
+ #include "prism/stream.h"
24
+
25
+ /**
26
+ * Serialize the AST represented by the given node to the given buffer.
27
+ *
28
+ * @param parser The parser to serialize.
29
+ * @param node The node to serialize.
30
+ * @param buffer The buffer to serialize to.
31
+ */
32
+ PRISM_EXPORTED_FUNCTION void pm_serialize(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) PRISM_NONNULL(1, 2, 3);
33
+
34
+ /**
35
+ * Parse the given source to the AST and dump the AST to the given buffer.
36
+ *
37
+ * @param buffer The buffer to serialize to.
38
+ * @param source The source to parse.
39
+ * @param size The size of the source.
40
+ * @param data The optional data to pass to the parser.
41
+ */
42
+ PRISM_EXPORTED_FUNCTION void pm_serialize_parse(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
43
+
44
+ /**
45
+ * Parse and serialize the AST represented by the given source into the given
46
+ * buffer.
47
+ *
48
+ * @param buffer The buffer to serialize to.
49
+ * @param source The source to parse.
50
+ * @param data The optional data to pass to the parser.
51
+ */
52
+ PRISM_EXPORTED_FUNCTION void pm_serialize_parse_stream(pm_buffer_t *buffer, pm_source_t *source, const char *data) PRISM_NONNULL(1, 2);
53
+
54
+ /**
55
+ * Parse and serialize the comments in the given source to the given buffer.
56
+ *
57
+ * @param buffer The buffer to serialize to.
58
+ * @param source The source to parse.
59
+ * @param size The size of the source.
60
+ * @param data The optional data to pass to the parser.
61
+ */
62
+ PRISM_EXPORTED_FUNCTION void pm_serialize_parse_comments(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
63
+
64
+ /**
65
+ * Lex the given source and serialize to the given buffer.
66
+ *
67
+ * @param source The source to lex.
68
+ * @param size The size of the source.
69
+ * @param buffer The buffer to serialize to.
70
+ * @param data The optional data to pass to the lexer.
71
+ */
72
+ PRISM_EXPORTED_FUNCTION void pm_serialize_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
73
+
74
+ /**
75
+ * Parse and serialize both the AST and the tokens represented by the given
76
+ * source to the given buffer.
77
+ *
78
+ * @param buffer The buffer to serialize to.
79
+ * @param source The source to parse.
80
+ * @param size The size of the source.
81
+ * @param data The optional data to pass to the parser.
82
+ */
83
+ PRISM_EXPORTED_FUNCTION void pm_serialize_parse_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
84
+
85
+ /**
86
+ * Parse the source and return true if it parses without errors or warnings.
87
+ *
88
+ * @param source The source to parse.
89
+ * @param size The size of the source.
90
+ * @param data The optional data to pass to the parser.
91
+ * @returns True if the source parses without errors or warnings.
92
+ */
93
+ PRISM_EXPORTED_FUNCTION bool pm_serialize_parse_success_p(const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1);
94
+
95
+ /**
96
+ * Parse the given source and format any errors that are encountered into the
97
+ * given buffer using the given format type. If the source parses without any
98
+ * errors, then -1 is returned and the buffer is left empty. Otherwise, the
99
+ * name of the encoding of the source is written to the buffer, followed by a
100
+ * null byte, followed by the formatted errors, and the error level of the
101
+ * error with the highest precedence is returned.
102
+ *
103
+ * @param buffer The buffer to write the encoding name and formatted errors to.
104
+ * @param source The source to parse.
105
+ * @param size The size of the source.
106
+ * @param data The optional data to pass to the parser.
107
+ * @param format_type The type of formatting to use when formatting the errors.
108
+ * @returns The error level of the error with the highest precedence, or -1 if
109
+ * the source parsed without errors.
110
+ */
111
+ PRISM_EXPORTED_FUNCTION int8_t pm_serialize_parse_errors_format(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data, pm_errors_format_type_t format_type) PRISM_NONNULL(1, 2);
112
+
113
+ #endif
114
+
115
+ #endif