herb 0.7.2-x86_64-linux-musl → 0.7.4-x86_64-linux-musl
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.
- checksums.yaml +4 -4
- data/Makefile +2 -0
- data/README.md +1 -1
- data/Rakefile +46 -1
- data/config.yml +714 -0
- data/ext/herb/extconf.rb +2 -1
- data/ext/herb/nodes.c +1 -1
- data/herb.gemspec +3 -0
- data/lib/herb/3.0/herb.so +0 -0
- data/lib/herb/3.1/herb.so +0 -0
- data/lib/herb/3.2/herb.so +0 -0
- data/lib/herb/3.3/herb.so +0 -0
- data/lib/herb/3.4/herb.so +0 -0
- data/lib/herb/engine.rb +8 -1
- data/lib/herb/version.rb +1 -1
- data/src/analyze.c +5 -9
- data/src/analyze_helpers.c +17 -6
- data/src/herb.c +2 -2
- data/src/include/parser.h +2 -2
- data/src/include/pretty_print.h +1 -1
- data/src/include/version.h +1 -1
- data/src/parser.c +3 -2
- data/src/pretty_print.c +1 -1
- data/templates/ext/herb/error_helpers.c.erb +85 -0
- data/templates/ext/herb/error_helpers.h.erb +12 -0
- data/templates/ext/herb/nodes.c.erb +90 -0
- data/templates/ext/herb/nodes.h.erb +9 -0
- data/templates/javascript/packages/core/src/errors.ts.erb +193 -0
- data/templates/javascript/packages/core/src/node-type-guards.ts.erb +325 -0
- data/templates/javascript/packages/core/src/nodes.ts.erb +414 -0
- data/templates/javascript/packages/core/src/visitor.ts.erb +29 -0
- data/templates/javascript/packages/node/extension/error_helpers.cpp.erb +113 -0
- data/templates/javascript/packages/node/extension/error_helpers.h.erb +17 -0
- data/templates/javascript/packages/node/extension/nodes.cpp.erb +111 -0
- data/templates/javascript/packages/node/extension/nodes.h.erb +17 -0
- data/templates/lib/herb/ast/nodes.rb.erb +117 -0
- data/templates/lib/herb/errors.rb.erb +106 -0
- data/templates/lib/herb/visitor.rb.erb +28 -0
- data/templates/sig/serialized_ast_errors.rbs.erb +10 -0
- data/templates/sig/serialized_ast_nodes.rbs.erb +10 -0
- data/templates/src/ast_nodes.c.erb +145 -0
- data/templates/src/ast_pretty_print.c.erb +97 -0
- data/templates/src/errors.c.erb +245 -0
- data/templates/src/include/ast_nodes.h.erb +46 -0
- data/templates/src/include/ast_pretty_print.h.erb +14 -0
- data/templates/src/include/errors.h.erb +58 -0
- data/templates/src/visitor.c.erb +47 -0
- data/templates/template.rb +406 -0
- data/templates/wasm/error_helpers.cpp.erb +93 -0
- data/templates/wasm/error_helpers.h.erb +15 -0
- data/templates/wasm/nodes.cpp.erb +79 -0
- data/templates/wasm/nodes.h.erb +15 -0
- data/vendor/prism/Rakefile +75 -0
- data/vendor/prism/config.yml +4713 -0
- data/vendor/prism/include/prism/ast.h +8190 -0
- data/vendor/prism/include/prism/defines.h +260 -0
- data/vendor/prism/include/prism/diagnostic.h +455 -0
- data/vendor/prism/include/prism/encoding.h +283 -0
- data/vendor/prism/include/prism/node.h +129 -0
- data/vendor/prism/include/prism/options.h +482 -0
- data/vendor/prism/include/prism/pack.h +163 -0
- data/vendor/prism/include/prism/parser.h +933 -0
- data/vendor/prism/include/prism/prettyprint.h +34 -0
- data/vendor/prism/include/prism/regexp.h +43 -0
- data/vendor/prism/include/prism/static_literals.h +121 -0
- data/vendor/prism/include/prism/util/pm_buffer.h +236 -0
- data/vendor/prism/include/prism/util/pm_char.h +204 -0
- data/vendor/prism/include/prism/util/pm_constant_pool.h +218 -0
- data/vendor/prism/include/prism/util/pm_integer.h +130 -0
- data/vendor/prism/include/prism/util/pm_list.h +103 -0
- data/vendor/prism/include/prism/util/pm_memchr.h +29 -0
- data/vendor/prism/include/prism/util/pm_newline_list.h +113 -0
- data/vendor/prism/include/prism/util/pm_string.h +200 -0
- data/vendor/prism/include/prism/util/pm_strncasecmp.h +32 -0
- data/vendor/prism/include/prism/util/pm_strpbrk.h +46 -0
- data/vendor/prism/include/prism/version.h +29 -0
- data/vendor/prism/include/prism.h +408 -0
- data/vendor/prism/src/diagnostic.c +848 -0
- data/vendor/prism/src/encoding.c +5235 -0
- data/vendor/prism/src/node.c +8676 -0
- data/vendor/prism/src/options.c +328 -0
- data/vendor/prism/src/pack.c +509 -0
- data/vendor/prism/src/prettyprint.c +8941 -0
- data/vendor/prism/src/prism.c +23302 -0
- data/vendor/prism/src/regexp.c +790 -0
- data/vendor/prism/src/serialize.c +2268 -0
- data/vendor/prism/src/static_literals.c +617 -0
- data/vendor/prism/src/token_type.c +703 -0
- data/vendor/prism/src/util/pm_buffer.c +357 -0
- data/vendor/prism/src/util/pm_char.c +318 -0
- data/vendor/prism/src/util/pm_constant_pool.c +342 -0
- data/vendor/prism/src/util/pm_integer.c +670 -0
- data/vendor/prism/src/util/pm_list.c +49 -0
- data/vendor/prism/src/util/pm_memchr.c +35 -0
- data/vendor/prism/src/util/pm_newline_list.c +125 -0
- data/vendor/prism/src/util/pm_string.c +383 -0
- data/vendor/prism/src/util/pm_strncasecmp.c +36 -0
- data/vendor/prism/src/util/pm_strpbrk.c +206 -0
- data/vendor/prism/templates/ext/prism/api_node.c.erb +282 -0
- data/vendor/prism/templates/include/prism/ast.h.erb +226 -0
- data/vendor/prism/templates/include/prism/diagnostic.h.erb +130 -0
- data/vendor/prism/templates/java/org/prism/AbstractNodeVisitor.java.erb +22 -0
- data/vendor/prism/templates/java/org/prism/Loader.java.erb +434 -0
- data/vendor/prism/templates/java/org/prism/Nodes.java.erb +403 -0
- data/vendor/prism/templates/javascript/src/deserialize.js.erb +448 -0
- data/vendor/prism/templates/javascript/src/nodes.js.erb +197 -0
- data/vendor/prism/templates/javascript/src/visitor.js.erb +78 -0
- data/vendor/prism/templates/lib/prism/compiler.rb.erb +43 -0
- data/vendor/prism/templates/lib/prism/dispatcher.rb.erb +103 -0
- data/vendor/prism/templates/lib/prism/dot_visitor.rb.erb +189 -0
- data/vendor/prism/templates/lib/prism/dsl.rb.erb +133 -0
- data/vendor/prism/templates/lib/prism/inspect_visitor.rb.erb +131 -0
- data/vendor/prism/templates/lib/prism/mutation_compiler.rb.erb +19 -0
- data/vendor/prism/templates/lib/prism/node.rb.erb +515 -0
- data/vendor/prism/templates/lib/prism/reflection.rb.erb +136 -0
- data/vendor/prism/templates/lib/prism/serialize.rb.erb +602 -0
- data/vendor/prism/templates/lib/prism/visitor.rb.erb +55 -0
- data/vendor/prism/templates/rbi/prism/dsl.rbi.erb +68 -0
- data/vendor/prism/templates/rbi/prism/node.rbi.erb +164 -0
- data/vendor/prism/templates/rbi/prism/visitor.rbi.erb +18 -0
- data/vendor/prism/templates/sig/prism/_private/dot_visitor.rbs.erb +45 -0
- data/vendor/prism/templates/sig/prism/dsl.rbs.erb +31 -0
- data/vendor/prism/templates/sig/prism/mutation_compiler.rbs.erb +7 -0
- data/vendor/prism/templates/sig/prism/node.rbs.erb +132 -0
- data/vendor/prism/templates/sig/prism/visitor.rbs.erb +17 -0
- data/vendor/prism/templates/sig/prism.rbs.erb +89 -0
- data/vendor/prism/templates/src/diagnostic.c.erb +523 -0
- data/vendor/prism/templates/src/node.c.erb +333 -0
- data/vendor/prism/templates/src/prettyprint.c.erb +166 -0
- data/vendor/prism/templates/src/serialize.c.erb +406 -0
- data/vendor/prism/templates/src/token_type.c.erb +369 -0
- data/vendor/prism/templates/template.rb +689 -0
- metadata +112 -2
@@ -0,0 +1,200 @@
|
|
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 <errno.h>
|
13
|
+
#include <stdbool.h>
|
14
|
+
#include <stddef.h>
|
15
|
+
#include <stdlib.h>
|
16
|
+
#include <string.h>
|
17
|
+
|
18
|
+
// The following headers are necessary to read files using demand paging.
|
19
|
+
#ifdef _WIN32
|
20
|
+
#include <windows.h>
|
21
|
+
#elif defined(_POSIX_MAPPED_FILES)
|
22
|
+
#include <fcntl.h>
|
23
|
+
#include <sys/mman.h>
|
24
|
+
#include <sys/stat.h>
|
25
|
+
#elif defined(PRISM_HAS_FILESYSTEM)
|
26
|
+
#include <fcntl.h>
|
27
|
+
#include <sys/stat.h>
|
28
|
+
#endif
|
29
|
+
|
30
|
+
/**
|
31
|
+
* A generic string type that can have various ownership semantics.
|
32
|
+
*/
|
33
|
+
typedef struct {
|
34
|
+
/** A pointer to the start of the string. */
|
35
|
+
const uint8_t *source;
|
36
|
+
|
37
|
+
/** The length of the string in bytes of memory. */
|
38
|
+
size_t length;
|
39
|
+
|
40
|
+
/** The type of the string. This field determines how the string should be freed. */
|
41
|
+
enum {
|
42
|
+
/** This string is a constant string, and should not be freed. */
|
43
|
+
PM_STRING_CONSTANT,
|
44
|
+
|
45
|
+
/** This is a slice of another string, and should not be freed. */
|
46
|
+
PM_STRING_SHARED,
|
47
|
+
|
48
|
+
/** This string owns its memory, and should be freed using `pm_string_free()`. */
|
49
|
+
PM_STRING_OWNED,
|
50
|
+
|
51
|
+
#ifdef PRISM_HAS_MMAP
|
52
|
+
/** This string is a memory-mapped file, and should be freed using `pm_string_free()`. */
|
53
|
+
PM_STRING_MAPPED
|
54
|
+
#endif
|
55
|
+
} type;
|
56
|
+
} pm_string_t;
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Returns the size of the pm_string_t struct. This is necessary to allocate the
|
60
|
+
* correct amount of memory in the FFI backend.
|
61
|
+
*
|
62
|
+
* @return The size of the pm_string_t struct.
|
63
|
+
*/
|
64
|
+
PRISM_EXPORTED_FUNCTION size_t pm_string_sizeof(void);
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Defines an empty string. This is useful for initializing a string that will
|
68
|
+
* be filled in later.
|
69
|
+
*/
|
70
|
+
#define PM_STRING_EMPTY ((pm_string_t) { .type = PM_STRING_CONSTANT, .source = NULL, .length = 0 })
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Initialize a shared string that is based on initial input.
|
74
|
+
*
|
75
|
+
* @param string The string to initialize.
|
76
|
+
* @param start The start of the string.
|
77
|
+
* @param end The end of the string.
|
78
|
+
*/
|
79
|
+
void pm_string_shared_init(pm_string_t *string, const uint8_t *start, const uint8_t *end);
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Initialize an owned string that is responsible for freeing allocated memory.
|
83
|
+
*
|
84
|
+
* @param string The string to initialize.
|
85
|
+
* @param source The source of the string.
|
86
|
+
* @param length The length of the string.
|
87
|
+
*/
|
88
|
+
void pm_string_owned_init(pm_string_t *string, uint8_t *source, size_t length);
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Initialize a constant string that doesn't own its memory source.
|
92
|
+
*
|
93
|
+
* @param string The string to initialize.
|
94
|
+
* @param source The source of the string.
|
95
|
+
* @param length The length of the string.
|
96
|
+
*/
|
97
|
+
void pm_string_constant_init(pm_string_t *string, const char *source, size_t length);
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Represents the result of calling pm_string_mapped_init or
|
101
|
+
* pm_string_file_init. We need this additional information because there is
|
102
|
+
* not a platform-agnostic way to indicate that the file that was attempted to
|
103
|
+
* be opened was a directory.
|
104
|
+
*/
|
105
|
+
typedef enum {
|
106
|
+
/** Indicates that the string was successfully initialized. */
|
107
|
+
PM_STRING_INIT_SUCCESS = 0,
|
108
|
+
/**
|
109
|
+
* Indicates a generic error from a string_*_init function, where the type
|
110
|
+
* of error should be read from `errno` or `GetLastError()`.
|
111
|
+
*/
|
112
|
+
PM_STRING_INIT_ERROR_GENERIC = 1,
|
113
|
+
/**
|
114
|
+
* Indicates that the file that was attempted to be opened was a directory.
|
115
|
+
*/
|
116
|
+
PM_STRING_INIT_ERROR_DIRECTORY = 2
|
117
|
+
} pm_string_init_result_t;
|
118
|
+
|
119
|
+
/**
|
120
|
+
* Read the file indicated by the filepath parameter into source and load its
|
121
|
+
* contents and size into the given `pm_string_t`. The given `pm_string_t`
|
122
|
+
* should be freed using `pm_string_free` when it is no longer used.
|
123
|
+
*
|
124
|
+
* We want to use demand paging as much as possible in order to avoid having to
|
125
|
+
* read the entire file into memory (which could be detrimental to performance
|
126
|
+
* for large files). This means that if we're on windows we'll use
|
127
|
+
* `MapViewOfFile`, on POSIX systems that have access to `mmap` we'll use
|
128
|
+
* `mmap`, and on other POSIX systems we'll use `read`.
|
129
|
+
*
|
130
|
+
* @param string The string to initialize.
|
131
|
+
* @param filepath The filepath to read.
|
132
|
+
* @return The success of the read, indicated by the value of the enum.
|
133
|
+
*
|
134
|
+
* \public \memberof pm_string_t
|
135
|
+
*/
|
136
|
+
PRISM_EXPORTED_FUNCTION pm_string_init_result_t pm_string_mapped_init(pm_string_t *string, const char *filepath);
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Read the file indicated by the filepath parameter into source and load its
|
140
|
+
* contents and size into the given `pm_string_t`. The given `pm_string_t`
|
141
|
+
* should be freed using `pm_string_free` when it is no longer used.
|
142
|
+
*
|
143
|
+
* @param string The string to initialize.
|
144
|
+
* @param filepath The filepath to read.
|
145
|
+
* @return The success of the read, indicated by the value of the enum.
|
146
|
+
*
|
147
|
+
* \public \memberof pm_string_t
|
148
|
+
*/
|
149
|
+
PRISM_EXPORTED_FUNCTION pm_string_init_result_t pm_string_file_init(pm_string_t *string, const char *filepath);
|
150
|
+
|
151
|
+
/**
|
152
|
+
* Ensure the string is owned. If it is not, then reinitialize it as owned and
|
153
|
+
* copy over the previous source.
|
154
|
+
*
|
155
|
+
* @param string The string to ensure is owned.
|
156
|
+
*/
|
157
|
+
void pm_string_ensure_owned(pm_string_t *string);
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Compare the underlying lengths and bytes of two strings. Returns 0 if the
|
161
|
+
* strings are equal, a negative number if the left string is less than the
|
162
|
+
* right string, and a positive number if the left string is greater than the
|
163
|
+
* right string.
|
164
|
+
*
|
165
|
+
* @param left The left string to compare.
|
166
|
+
* @param right The right string to compare.
|
167
|
+
* @return The comparison result.
|
168
|
+
*/
|
169
|
+
int pm_string_compare(const pm_string_t *left, const pm_string_t *right);
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Returns the length associated with the string.
|
173
|
+
*
|
174
|
+
* @param string The string to get the length of.
|
175
|
+
* @return The length of the string.
|
176
|
+
*
|
177
|
+
* \public \memberof pm_string_t
|
178
|
+
*/
|
179
|
+
PRISM_EXPORTED_FUNCTION size_t pm_string_length(const pm_string_t *string);
|
180
|
+
|
181
|
+
/**
|
182
|
+
* Returns the start pointer associated with the string.
|
183
|
+
*
|
184
|
+
* @param string The string to get the start pointer of.
|
185
|
+
* @return The start pointer of the string.
|
186
|
+
*
|
187
|
+
* \public \memberof pm_string_t
|
188
|
+
*/
|
189
|
+
PRISM_EXPORTED_FUNCTION const uint8_t * pm_string_source(const pm_string_t *string);
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Free the associated memory of the given string.
|
193
|
+
*
|
194
|
+
* @param string The string to free.
|
195
|
+
*
|
196
|
+
* \public \memberof pm_string_t
|
197
|
+
*/
|
198
|
+
PRISM_EXPORTED_FUNCTION void pm_string_free(pm_string_t *string);
|
199
|
+
|
200
|
+
#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 1
|
13
|
+
|
14
|
+
/**
|
15
|
+
* The minor version of the Prism library as an int.
|
16
|
+
*/
|
17
|
+
#define PRISM_VERSION_MINOR 5
|
18
|
+
|
19
|
+
/**
|
20
|
+
* The patch version of the Prism library as an int.
|
21
|
+
*/
|
22
|
+
#define PRISM_VERSION_PATCH 1
|
23
|
+
|
24
|
+
/**
|
25
|
+
* The version of the Prism library as a constant string.
|
26
|
+
*/
|
27
|
+
#define PRISM_VERSION "1.5.1"
|
28
|
+
|
29
|
+
#endif
|