jruby-prism-parser 0.23.0.pre.SNAPSHOT-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +401 -0
  3. data/CODE_OF_CONDUCT.md +76 -0
  4. data/CONTRIBUTING.md +62 -0
  5. data/LICENSE.md +7 -0
  6. data/Makefile +101 -0
  7. data/README.md +98 -0
  8. data/config.yml +2902 -0
  9. data/docs/build_system.md +91 -0
  10. data/docs/configuration.md +64 -0
  11. data/docs/cruby_compilation.md +27 -0
  12. data/docs/design.md +53 -0
  13. data/docs/encoding.md +121 -0
  14. data/docs/fuzzing.md +88 -0
  15. data/docs/heredocs.md +36 -0
  16. data/docs/javascript.md +118 -0
  17. data/docs/local_variable_depth.md +229 -0
  18. data/docs/mapping.md +117 -0
  19. data/docs/parser_translation.md +34 -0
  20. data/docs/parsing_rules.md +19 -0
  21. data/docs/releasing.md +98 -0
  22. data/docs/ripper.md +36 -0
  23. data/docs/ruby_api.md +43 -0
  24. data/docs/ruby_parser_translation.md +19 -0
  25. data/docs/serialization.md +209 -0
  26. data/docs/testing.md +55 -0
  27. data/ext/prism/api_node.c +5098 -0
  28. data/ext/prism/api_pack.c +267 -0
  29. data/ext/prism/extconf.rb +110 -0
  30. data/ext/prism/extension.c +1155 -0
  31. data/ext/prism/extension.h +18 -0
  32. data/include/prism/ast.h +5807 -0
  33. data/include/prism/defines.h +102 -0
  34. data/include/prism/diagnostic.h +339 -0
  35. data/include/prism/encoding.h +265 -0
  36. data/include/prism/node.h +57 -0
  37. data/include/prism/options.h +230 -0
  38. data/include/prism/pack.h +152 -0
  39. data/include/prism/parser.h +732 -0
  40. data/include/prism/prettyprint.h +26 -0
  41. data/include/prism/regexp.h +33 -0
  42. data/include/prism/util/pm_buffer.h +155 -0
  43. data/include/prism/util/pm_char.h +205 -0
  44. data/include/prism/util/pm_constant_pool.h +209 -0
  45. data/include/prism/util/pm_list.h +97 -0
  46. data/include/prism/util/pm_memchr.h +29 -0
  47. data/include/prism/util/pm_newline_list.h +93 -0
  48. data/include/prism/util/pm_state_stack.h +42 -0
  49. data/include/prism/util/pm_string.h +150 -0
  50. data/include/prism/util/pm_string_list.h +44 -0
  51. data/include/prism/util/pm_strncasecmp.h +32 -0
  52. data/include/prism/util/pm_strpbrk.h +46 -0
  53. data/include/prism/version.h +29 -0
  54. data/include/prism.h +289 -0
  55. data/jruby-prism.jar +0 -0
  56. data/lib/prism/compiler.rb +486 -0
  57. data/lib/prism/debug.rb +206 -0
  58. data/lib/prism/desugar_compiler.rb +207 -0
  59. data/lib/prism/dispatcher.rb +2150 -0
  60. data/lib/prism/dot_visitor.rb +4634 -0
  61. data/lib/prism/dsl.rb +785 -0
  62. data/lib/prism/ffi.rb +346 -0
  63. data/lib/prism/lex_compat.rb +908 -0
  64. data/lib/prism/mutation_compiler.rb +753 -0
  65. data/lib/prism/node.rb +17864 -0
  66. data/lib/prism/node_ext.rb +212 -0
  67. data/lib/prism/node_inspector.rb +68 -0
  68. data/lib/prism/pack.rb +224 -0
  69. data/lib/prism/parse_result/comments.rb +177 -0
  70. data/lib/prism/parse_result/newlines.rb +64 -0
  71. data/lib/prism/parse_result.rb +498 -0
  72. data/lib/prism/pattern.rb +250 -0
  73. data/lib/prism/serialize.rb +1354 -0
  74. data/lib/prism/translation/parser/compiler.rb +1838 -0
  75. data/lib/prism/translation/parser/lexer.rb +335 -0
  76. data/lib/prism/translation/parser/rubocop.rb +37 -0
  77. data/lib/prism/translation/parser.rb +178 -0
  78. data/lib/prism/translation/ripper.rb +577 -0
  79. data/lib/prism/translation/ruby_parser.rb +1521 -0
  80. data/lib/prism/translation.rb +11 -0
  81. data/lib/prism/version.rb +3 -0
  82. data/lib/prism/visitor.rb +495 -0
  83. data/lib/prism.rb +99 -0
  84. data/prism.gemspec +135 -0
  85. data/rbi/prism.rbi +7767 -0
  86. data/rbi/prism_static.rbi +207 -0
  87. data/sig/prism.rbs +4773 -0
  88. data/sig/prism_static.rbs +201 -0
  89. data/src/diagnostic.c +400 -0
  90. data/src/encoding.c +5132 -0
  91. data/src/node.c +2786 -0
  92. data/src/options.c +213 -0
  93. data/src/pack.c +493 -0
  94. data/src/prettyprint.c +8881 -0
  95. data/src/prism.c +18406 -0
  96. data/src/regexp.c +638 -0
  97. data/src/serialize.c +1554 -0
  98. data/src/token_type.c +700 -0
  99. data/src/util/pm_buffer.c +190 -0
  100. data/src/util/pm_char.c +318 -0
  101. data/src/util/pm_constant_pool.c +322 -0
  102. data/src/util/pm_list.c +49 -0
  103. data/src/util/pm_memchr.c +35 -0
  104. data/src/util/pm_newline_list.c +84 -0
  105. data/src/util/pm_state_stack.c +25 -0
  106. data/src/util/pm_string.c +203 -0
  107. data/src/util/pm_string_list.c +28 -0
  108. data/src/util/pm_strncasecmp.c +24 -0
  109. data/src/util/pm_strpbrk.c +180 -0
  110. metadata +156 -0
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @file pm_list.h
3
+ *
4
+ * An abstract linked list.
5
+ */
6
+ #ifndef PRISM_LIST_H
7
+ #define PRISM_LIST_H
8
+
9
+ #include "prism/defines.h"
10
+
11
+ #include <stdbool.h>
12
+ #include <stddef.h>
13
+ #include <stdint.h>
14
+ #include <stdlib.h>
15
+
16
+ /**
17
+ * This struct represents an abstract linked list that provides common
18
+ * functionality. It is meant to be used any time a linked list is necessary to
19
+ * store data.
20
+ *
21
+ * The linked list itself operates off a set of pointers. Because the pointers
22
+ * are not necessarily sequential, they can be of any size. We use this fact to
23
+ * allow the consumer of this linked list to extend the node struct to include
24
+ * any data they want. This is done by using the pm_list_node_t as the first
25
+ * member of the struct.
26
+ *
27
+ * For example, if we want to store a list of integers, we can do the following:
28
+ *
29
+ * ```c
30
+ * typedef struct {
31
+ * pm_list_node_t node;
32
+ * int value;
33
+ * } pm_int_node_t;
34
+ *
35
+ * pm_list_t list = { 0 };
36
+ * pm_int_node_t *node = malloc(sizeof(pm_int_node_t));
37
+ * node->value = 5;
38
+ *
39
+ * pm_list_append(&list, &node->node);
40
+ * ```
41
+ *
42
+ * The pm_list_t struct is used to represent the overall linked list. It
43
+ * contains a pointer to the head and tail of the list. This allows for easy
44
+ * iteration and appending of new nodes.
45
+ */
46
+ typedef struct pm_list_node {
47
+ /** A pointer to the next node in the list. */
48
+ struct pm_list_node *next;
49
+ } pm_list_node_t;
50
+
51
+ /**
52
+ * This represents the overall linked list. It keeps a pointer to the head and
53
+ * tail so that iteration is easy and pushing new nodes is easy.
54
+ */
55
+ typedef struct {
56
+ /** The size of the list. */
57
+ size_t size;
58
+
59
+ /** A pointer to the head of the list. */
60
+ pm_list_node_t *head;
61
+
62
+ /** A pointer to the tail of the list. */
63
+ pm_list_node_t *tail;
64
+ } pm_list_t;
65
+
66
+ /**
67
+ * Returns true if the given list is empty.
68
+ *
69
+ * @param list The list to check.
70
+ * @return True if the given list is empty, otherwise false.
71
+ */
72
+ PRISM_EXPORTED_FUNCTION bool pm_list_empty_p(pm_list_t *list);
73
+
74
+ /**
75
+ * Returns the size of the list.
76
+ *
77
+ * @param list The list to check.
78
+ * @return The size of the list.
79
+ */
80
+ PRISM_EXPORTED_FUNCTION size_t pm_list_size(pm_list_t *list);
81
+
82
+ /**
83
+ * Append a node to the given list.
84
+ *
85
+ * @param list The list to append to.
86
+ * @param node The node to append.
87
+ */
88
+ void pm_list_append(pm_list_t *list, pm_list_node_t *node);
89
+
90
+ /**
91
+ * Deallocate the internal state of the given list.
92
+ *
93
+ * @param list The list to free.
94
+ */
95
+ PRISM_EXPORTED_FUNCTION void pm_list_free(pm_list_t *list);
96
+
97
+ #endif
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @file pm_memchr.h
3
+ *
4
+ * A custom memchr implementation.
5
+ */
6
+ #ifndef PRISM_MEMCHR_H
7
+ #define PRISM_MEMCHR_H
8
+
9
+ #include "prism/defines.h"
10
+ #include "prism/encoding.h"
11
+
12
+ #include <stddef.h>
13
+
14
+ /**
15
+ * We need to roll our own memchr to handle cases where the encoding changes and
16
+ * we need to search for a character in a buffer that could be the trailing byte
17
+ * of a multibyte character.
18
+ *
19
+ * @param source The source string.
20
+ * @param character The character to search for.
21
+ * @param number The maximum number of bytes to search.
22
+ * @param encoding_changed Whether the encoding changed.
23
+ * @param encoding A pointer to the encoding.
24
+ * @return A pointer to the first occurrence of the character in the source
25
+ * string, or NULL if no such character exists.
26
+ */
27
+ void * pm_memchr(const void *source, int character, size_t number, bool encoding_changed, const pm_encoding_t *encoding);
28
+
29
+ #endif
@@ -0,0 +1,93 @@
1
+ /**
2
+ * @file pm_newline_list.h
3
+ *
4
+ * A list of byte offsets of newlines in a string.
5
+ *
6
+ * When compiling the syntax tree, it's necessary to know the line and column
7
+ * of many nodes. This is necessary to support things like error messages,
8
+ * tracepoints, etc.
9
+ *
10
+ * It's possible that we could store the start line, start column, end line, and
11
+ * end column on every node in addition to the offsets that we already store,
12
+ * but that would be quite a lot of memory overhead.
13
+ */
14
+ #ifndef PRISM_NEWLINE_LIST_H
15
+ #define PRISM_NEWLINE_LIST_H
16
+
17
+ #include "prism/defines.h"
18
+
19
+ #include <assert.h>
20
+ #include <stdbool.h>
21
+ #include <stddef.h>
22
+ #include <stdlib.h>
23
+
24
+ /**
25
+ * A list of offsets of newlines in a string. The offsets are assumed to be
26
+ * sorted/inserted in ascending order.
27
+ */
28
+ typedef struct {
29
+ /** A pointer to the start of the source string. */
30
+ const uint8_t *start;
31
+
32
+ /** The number of offsets in the list. */
33
+ size_t size;
34
+
35
+ /** The capacity of the list that has been allocated. */
36
+ size_t capacity;
37
+
38
+ /** The list of offsets. */
39
+ size_t *offsets;
40
+ } pm_newline_list_t;
41
+
42
+ /**
43
+ * A line and column in a string.
44
+ */
45
+ typedef struct {
46
+ /** The line number. */
47
+ size_t line;
48
+
49
+ /** The column number. */
50
+ size_t column;
51
+ } pm_line_column_t;
52
+
53
+ /**
54
+ * Initialize a new newline list with the given capacity. Returns true if the
55
+ * allocation of the offsets succeeds, otherwise returns false.
56
+ *
57
+ * @param list The list to initialize.
58
+ * @param start A pointer to the start of the source string.
59
+ * @param capacity The initial capacity of the list.
60
+ * @return True if the allocation of the offsets succeeds, otherwise false.
61
+ */
62
+ bool pm_newline_list_init(pm_newline_list_t *list, const uint8_t *start, size_t capacity);
63
+
64
+ /**
65
+ * Append a new offset to the newline list. Returns true if the reallocation of
66
+ * the offsets succeeds (if one was necessary), otherwise returns false.
67
+ *
68
+ * @param list The list to append to.
69
+ * @param cursor A pointer to the offset to append.
70
+ * @return True if the reallocation of the offsets succeeds (if one was
71
+ * necessary), otherwise false.
72
+ */
73
+ bool pm_newline_list_append(pm_newline_list_t *list, const uint8_t *cursor);
74
+
75
+ /**
76
+ * Returns the line and column of the given offset. If the offset is not in the
77
+ * list, the line and column of the closest offset less than the given offset
78
+ * are returned.
79
+ *
80
+ * @param list The list to search.
81
+ * @param cursor A pointer to the offset to search for.
82
+ * @return The line and column of the given offset.
83
+ */
84
+ pm_line_column_t pm_newline_list_line_column(const pm_newline_list_t *list, const uint8_t *cursor);
85
+
86
+ /**
87
+ * Free the internal memory allocated for the newline list.
88
+ *
89
+ * @param list The list to free.
90
+ */
91
+ void pm_newline_list_free(pm_newline_list_t *list);
92
+
93
+ #endif
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @file pm_state_stack.h
3
+ *
4
+ * A stack of boolean values.
5
+ */
6
+ #ifndef PRISM_STATE_STACK_H
7
+ #define PRISM_STATE_STACK_H
8
+
9
+ #include "prism/defines.h"
10
+
11
+ #include <stdbool.h>
12
+ #include <stdint.h>
13
+
14
+ /**
15
+ * A struct that represents a stack of boolean values.
16
+ */
17
+ typedef uint32_t pm_state_stack_t;
18
+
19
+ /**
20
+ * Pushes a value onto the stack.
21
+ *
22
+ * @param stack The stack to push the value onto.
23
+ * @param value The value to push onto the stack.
24
+ */
25
+ void pm_state_stack_push(pm_state_stack_t *stack, bool value);
26
+
27
+ /**
28
+ * Pops a value off the stack.
29
+ *
30
+ * @param stack The stack to pop the value off of.
31
+ */
32
+ void pm_state_stack_pop(pm_state_stack_t *stack);
33
+
34
+ /**
35
+ * Returns the value at the top of the stack.
36
+ *
37
+ * @param stack The stack to get the value from.
38
+ * @return The value at the top of the stack.
39
+ */
40
+ bool pm_state_stack_p(pm_state_stack_t *stack);
41
+
42
+ #endif
@@ -0,0 +1,150 @@
1
+ /**
2
+ * @file pm_string.h
3
+ *
4
+ * A generic string type that can have various ownership semantics.
5
+ */
6
+ #ifndef PRISM_STRING_H
7
+ #define PRISM_STRING_H
8
+
9
+ #include "prism/defines.h"
10
+
11
+ #include <assert.h>
12
+ #include <stdbool.h>
13
+ #include <stddef.h>
14
+ #include <stdlib.h>
15
+ #include <string.h>
16
+
17
+ // The following headers are necessary to read files using demand paging.
18
+ #ifdef _WIN32
19
+ #include <windows.h>
20
+ #else
21
+ #include <fcntl.h>
22
+ #include <sys/mman.h>
23
+ #include <sys/stat.h>
24
+ #include <unistd.h>
25
+ #endif
26
+
27
+ /**
28
+ * A generic string type that can have various ownership semantics.
29
+ */
30
+ typedef struct {
31
+ /** A pointer to the start of the string. */
32
+ const uint8_t *source;
33
+
34
+ /** The length of the string in bytes of memory. */
35
+ size_t length;
36
+
37
+ /** The type of the string. This field determines how the string should be freed. */
38
+ enum {
39
+ /** This string is a constant string, and should not be freed. */
40
+ PM_STRING_CONSTANT,
41
+
42
+ /** This is a slice of another string, and should not be freed. */
43
+ PM_STRING_SHARED,
44
+
45
+ /** This string owns its memory, and should be freed using `pm_string_free`. */
46
+ PM_STRING_OWNED,
47
+
48
+ /** This string is a memory-mapped file, and should be freed using `pm_string_free`. */
49
+ PM_STRING_MAPPED
50
+ } type;
51
+ } pm_string_t;
52
+
53
+ /**
54
+ * Returns the size of the pm_string_t struct. This is necessary to allocate the
55
+ * correct amount of memory in the FFI backend.
56
+ *
57
+ * @return The size of the pm_string_t struct.
58
+ */
59
+ PRISM_EXPORTED_FUNCTION size_t pm_string_sizeof(void);
60
+
61
+ /**
62
+ * Defines an empty string. This is useful for initializing a string that will
63
+ * be filled in later.
64
+ */
65
+ #define PM_STRING_EMPTY ((pm_string_t) { .type = PM_STRING_CONSTANT, .source = NULL, .length = 0 })
66
+
67
+ /**
68
+ * Initialize a shared string that is based on initial input.
69
+ *
70
+ * @param string The string to initialize.
71
+ * @param start The start of the string.
72
+ * @param end The end of the string.
73
+ */
74
+ void pm_string_shared_init(pm_string_t *string, const uint8_t *start, const uint8_t *end);
75
+
76
+ /**
77
+ * Initialize an owned string that is responsible for freeing allocated memory.
78
+ *
79
+ * @param string The string to initialize.
80
+ * @param source The source of the string.
81
+ * @param length The length of the string.
82
+ */
83
+ void pm_string_owned_init(pm_string_t *string, uint8_t *source, size_t length);
84
+
85
+ /**
86
+ * Initialize a constant string that doesn't own its memory source.
87
+ *
88
+ * @param string The string to initialize.
89
+ * @param source The source of the string.
90
+ * @param length The length of the string.
91
+ */
92
+ void pm_string_constant_init(pm_string_t *string, const char *source, size_t length);
93
+
94
+ /**
95
+ * Read the file indicated by the filepath parameter into source and load its
96
+ * contents and size into the given `pm_string_t`. The given `pm_string_t`
97
+ * should be freed using `pm_string_free` when it is no longer used.
98
+ *
99
+ * We want to use demand paging as much as possible in order to avoid having to
100
+ * read the entire file into memory (which could be detrimental to performance
101
+ * for large files). This means that if we're on windows we'll use
102
+ * `MapViewOfFile`, on POSIX systems that have access to `mmap` we'll use
103
+ * `mmap`, and on other POSIX systems we'll use `read`.
104
+ *
105
+ * @param string The string to initialize.
106
+ * @param filepath The filepath to read.
107
+ * @return Whether or not the file was successfully mapped.
108
+ */
109
+ PRISM_EXPORTED_FUNCTION bool pm_string_mapped_init(pm_string_t *string, const char *filepath);
110
+
111
+ /**
112
+ * Returns the memory size associated with the string.
113
+ *
114
+ * @param string The string to get the memory size of.
115
+ * @return The size of the memory associated with the string.
116
+ */
117
+ size_t pm_string_memsize(const pm_string_t *string);
118
+
119
+ /**
120
+ * Ensure the string is owned. If it is not, then reinitialize it as owned and
121
+ * copy over the previous source.
122
+ *
123
+ * @param string The string to ensure is owned.
124
+ */
125
+ void pm_string_ensure_owned(pm_string_t *string);
126
+
127
+ /**
128
+ * Returns the length associated with the string.
129
+ *
130
+ * @param string The string to get the length of.
131
+ * @return The length of the string.
132
+ */
133
+ PRISM_EXPORTED_FUNCTION size_t pm_string_length(const pm_string_t *string);
134
+
135
+ /**
136
+ * Returns the start pointer associated with the string.
137
+ *
138
+ * @param string The string to get the start pointer of.
139
+ * @return The start pointer of the string.
140
+ */
141
+ PRISM_EXPORTED_FUNCTION const uint8_t * pm_string_source(const pm_string_t *string);
142
+
143
+ /**
144
+ * Free the associated memory of the given string.
145
+ *
146
+ * @param string The string to free.
147
+ */
148
+ PRISM_EXPORTED_FUNCTION void pm_string_free(pm_string_t *string);
149
+
150
+ #endif
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @file pm_string_list.h
3
+ *
4
+ * A list of strings.
5
+ */
6
+ #ifndef PRISM_STRING_LIST_H
7
+ #define PRISM_STRING_LIST_H
8
+
9
+ #include "prism/defines.h"
10
+ #include "prism/util/pm_string.h"
11
+
12
+ #include <stddef.h>
13
+ #include <stdlib.h>
14
+
15
+ /**
16
+ * A list of strings.
17
+ */
18
+ typedef struct {
19
+ /** The length of the string list. */
20
+ size_t length;
21
+
22
+ /** The capacity of the string list that has been allocated. */
23
+ size_t capacity;
24
+
25
+ /** A pointer to the start of the string list. */
26
+ pm_string_t *strings;
27
+ } pm_string_list_t;
28
+
29
+ /**
30
+ * Append a pm_string_t to the given string list.
31
+ *
32
+ * @param string_list The string list to append to.
33
+ * @param string The string to append.
34
+ */
35
+ void pm_string_list_append(pm_string_list_t *string_list, pm_string_t *string);
36
+
37
+ /**
38
+ * Free the memory associated with the string list.
39
+ *
40
+ * @param string_list The string list to free.
41
+ */
42
+ PRISM_EXPORTED_FUNCTION void pm_string_list_free(pm_string_list_t *string_list);
43
+
44
+ #endif
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @file pm_strncasecmp.h
3
+ *
4
+ * A custom strncasecmp implementation.
5
+ */
6
+ #ifndef PRISM_STRNCASECMP_H
7
+ #define PRISM_STRNCASECMP_H
8
+
9
+ #include "prism/defines.h"
10
+
11
+ #include <ctype.h>
12
+ #include <stddef.h>
13
+ #include <stdint.h>
14
+
15
+ /**
16
+ * Compare two strings, ignoring case, up to the given length. Returns 0 if the
17
+ * strings are equal, a negative number if string1 is less than string2, or a
18
+ * positive number if string1 is greater than string2.
19
+ *
20
+ * Note that this is effectively our own implementation of strncasecmp, but it's
21
+ * not available on all of the platforms we want to support so we're rolling it
22
+ * here.
23
+ *
24
+ * @param string1 The first string to compare.
25
+ * @param string2 The second string to compare
26
+ * @param length The maximum number of characters to compare.
27
+ * @return 0 if the strings are equal, a negative number if string1 is less than
28
+ * string2, or a positive number if string1 is greater than string2.
29
+ */
30
+ int pm_strncasecmp(const uint8_t *string1, const uint8_t *string2, size_t length);
31
+
32
+ #endif
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @file pm_strpbrk.h
3
+ *
4
+ * A custom strpbrk implementation.
5
+ */
6
+ #ifndef PRISM_STRPBRK_H
7
+ #define PRISM_STRPBRK_H
8
+
9
+ #include "prism/defines.h"
10
+ #include "prism/diagnostic.h"
11
+ #include "prism/parser.h"
12
+
13
+ #include <stddef.h>
14
+ #include <string.h>
15
+
16
+ /**
17
+ * Here we have rolled our own version of strpbrk. The standard library strpbrk
18
+ * has undefined behavior when the source string is not null-terminated. We want
19
+ * to support strings that are not null-terminated because pm_parse does not
20
+ * have the contract that the string is null-terminated. (This is desirable
21
+ * because it means the extension can call pm_parse with the result of a call to
22
+ * mmap).
23
+ *
24
+ * The standard library strpbrk also does not support passing a maximum length
25
+ * to search. We want to support this for the reason mentioned above, but we
26
+ * also don't want it to stop on null bytes. Ruby actually allows null bytes
27
+ * within strings, comments, regular expressions, etc. So we need to be able to
28
+ * skip past them.
29
+ *
30
+ * Finally, we want to support encodings wherein the charset could contain
31
+ * characters that are trailing bytes of multi-byte characters. For example, in
32
+ * Shift-JIS, the backslash character can be a trailing byte. In that case we
33
+ * need to take a slower path and iterate one multi-byte character at a time.
34
+ *
35
+ * @param parser The parser.
36
+ * @param source The source to search.
37
+ * @param charset The charset to search for.
38
+ * @param length The maximum number of bytes to search.
39
+ * @param validate Whether to validate that the source string is valid in the
40
+ * current encoding of the parser.
41
+ * @return A pointer to the first character in the source string that is in the
42
+ * charset, or NULL if no such character exists.
43
+ */
44
+ const uint8_t * pm_strpbrk(pm_parser_t *parser, const uint8_t *source, const uint8_t *charset, ptrdiff_t length, bool validate);
45
+
46
+ #endif
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @file version.h
3
+ *
4
+ * The version of the Prism library.
5
+ */
6
+ #ifndef PRISM_VERSION_H
7
+ #define PRISM_VERSION_H
8
+
9
+ /**
10
+ * The major version of the Prism library as an int.
11
+ */
12
+ #define PRISM_VERSION_MAJOR 0
13
+
14
+ /**
15
+ * The minor version of the Prism library as an int.
16
+ */
17
+ #define PRISM_VERSION_MINOR 23
18
+
19
+ /**
20
+ * The patch version of the Prism library as an int.
21
+ */
22
+ #define PRISM_VERSION_PATCH 0
23
+
24
+ /**
25
+ * The version of the Prism library as a constant string.
26
+ */
27
+ #define PRISM_VERSION "0.23.0"
28
+
29
+ #endif