debase-ruby_core_source 3.3.5 → 3.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.idea/vcs.xml +28 -0
- data/CHANGELOG.md +8 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/addr2line.h +22 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/builtin.h +119 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/ccan/list/list.h +791 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/ccan/str/str.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/constant.h +53 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/darray.h +209 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/debug_counter.h +423 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/dln.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/eval_intern.h +324 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/hrtime.h +237 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/id.h +347 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/id_table.h +39 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/insns.inc +265 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/insns_info.inc +9902 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/array.h +152 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/basic_operators.h +64 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/bignum.h +244 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/bits.h +568 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/class.h +283 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/cmdlineopt.h +65 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/compar.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/compile.h +34 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/compilers.h +107 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/cont.h +35 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/dir.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/enc.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/encoding.h +36 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/enum.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/enumerator.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/error.h +218 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/eval.h +33 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/file.h +38 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/fixnum.h +184 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/gc.h +322 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/hash.h +192 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/imemo.h +261 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/inits.h +47 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/io.h +143 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/load.h +18 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/loadpath.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/math.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/missing.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/numeric.h +274 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/object.h +63 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/parse.h +129 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/proc.h +30 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/process.h +124 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/ractor.h +6 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/random.h +17 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/range.h +40 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/rational.h +71 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/re.h +28 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/ruby_parser.h +102 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/sanitizers.h +326 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/serial.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/signal.h +24 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/st.h +11 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/static_assert.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/string.h +186 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/struct.h +127 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/symbol.h +45 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/thread.h +85 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/time.h +34 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/transcode.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/util.h +27 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/variable.h +72 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/vm.h +137 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal/warnings.h +16 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/internal.h +108 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/iseq.h +340 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/known_errors.inc +1419 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/method.h +255 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/node.h +111 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/node_name.inc +224 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/optunifs.inc +43 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/parse.h +244 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/parser_bits.h +564 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/parser_node.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/parser_st.h +162 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/parser_value.h +106 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/ast.h +7524 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/defines.h +242 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/diagnostic.h +450 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/encoding.h +283 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/extension.h +19 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/node.h +129 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/options.h +396 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/pack.h +163 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/parser.h +933 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/prettyprint.h +34 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/prism.h +336 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/regexp.h +43 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/static_literals.h +121 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/util/pm_buffer.h +218 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/util/pm_char.h +204 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/util/pm_constant_pool.h +218 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/util/pm_integer.h +126 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/util/pm_list.h +97 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/util/pm_memchr.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/util/pm_newline_list.h +113 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/util/pm_string.h +190 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/util/pm_strncasecmp.h +32 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/util/pm_strpbrk.h +46 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism/version.h +29 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/prism_compile.h +99 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/probes_helper.h +42 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/ractor_core.h +382 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/regenc.h +254 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/regint.h +1006 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/regparse.h +371 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/revision.h +5 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/rjit.h +101 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/rjit_c.h +165 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/ruby_assert.h +14 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/ruby_atomic.h +23 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/rubyparser.h +1350 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/shape.h +234 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/symbol.h +123 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/thread_none.h +21 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/thread_pthread.h +168 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/thread_win32.h +58 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/timev.h +58 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/variable.h +39 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/version.h +69 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/vm.inc +5840 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/vm_callinfo.h +627 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/vm_core.h +2222 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/vm_debug.h +124 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/vm_exec.h +199 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/vm_insnhelper.h +277 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/vm_opts.h +67 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/vm_sync.h +137 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/vmtc.inc +259 -0
- data/lib/debase/ruby_core_source/ruby-3.4.0-preview2/yjit.h +79 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +150 -6
@@ -0,0 +1,242 @@
|
|
1
|
+
/**
|
2
|
+
* @file defines.h
|
3
|
+
*
|
4
|
+
* Macro definitions used throughout the prism library.
|
5
|
+
*
|
6
|
+
* This file should be included first by any *.h or *.c in prism for consistency
|
7
|
+
* and to ensure that the macros are defined before they are used.
|
8
|
+
*/
|
9
|
+
#ifndef PRISM_DEFINES_H
|
10
|
+
#define PRISM_DEFINES_H
|
11
|
+
|
12
|
+
#include <ctype.h>
|
13
|
+
#include <limits.h>
|
14
|
+
#include <math.h>
|
15
|
+
#include <stdarg.h>
|
16
|
+
#include <stddef.h>
|
17
|
+
#include <stdint.h>
|
18
|
+
#include <stdio.h>
|
19
|
+
#include <string.h>
|
20
|
+
|
21
|
+
/**
|
22
|
+
* We want to be able to use the PRI* macros for printing out integers, but on
|
23
|
+
* some platforms they aren't included unless this is already defined.
|
24
|
+
*/
|
25
|
+
#define __STDC_FORMAT_MACROS
|
26
|
+
#include <inttypes.h>
|
27
|
+
|
28
|
+
/**
|
29
|
+
* When we are parsing using recursive descent, we want to protect against
|
30
|
+
* malicious payloads that could attempt to crash our parser. We do this by
|
31
|
+
* specifying a maximum depth to which we are allowed to recurse.
|
32
|
+
*/
|
33
|
+
#ifndef PRISM_DEPTH_MAXIMUM
|
34
|
+
#define PRISM_DEPTH_MAXIMUM 1000
|
35
|
+
#endif
|
36
|
+
|
37
|
+
/**
|
38
|
+
* By default, we compile with -fvisibility=hidden. When this is enabled, we
|
39
|
+
* need to mark certain functions as being publically-visible. This macro does
|
40
|
+
* that in a compiler-agnostic way.
|
41
|
+
*/
|
42
|
+
#ifndef PRISM_EXPORTED_FUNCTION
|
43
|
+
# ifdef PRISM_EXPORT_SYMBOLS
|
44
|
+
# ifdef _WIN32
|
45
|
+
# define PRISM_EXPORTED_FUNCTION __declspec(dllexport) extern
|
46
|
+
# else
|
47
|
+
# define PRISM_EXPORTED_FUNCTION __attribute__((__visibility__("default"))) extern
|
48
|
+
# endif
|
49
|
+
# else
|
50
|
+
# define PRISM_EXPORTED_FUNCTION
|
51
|
+
# endif
|
52
|
+
#endif
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Certain compilers support specifying that a function accepts variadic
|
56
|
+
* parameters that look like printf format strings to provide a better developer
|
57
|
+
* experience when someone is using the function. This macro does that in a
|
58
|
+
* compiler-agnostic way.
|
59
|
+
*/
|
60
|
+
#if defined(__GNUC__)
|
61
|
+
# if defined(__MINGW_PRINTF_FORMAT)
|
62
|
+
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((format(__MINGW_PRINTF_FORMAT, string_index, argument_index)))
|
63
|
+
# else
|
64
|
+
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((format(printf, string_index, argument_index)))
|
65
|
+
# endif
|
66
|
+
#elif defined(__clang__)
|
67
|
+
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((__format__(__printf__, string_index, argument_index)))
|
68
|
+
#else
|
69
|
+
# define PRISM_ATTRIBUTE_FORMAT(string_index, argument_index)
|
70
|
+
#endif
|
71
|
+
|
72
|
+
/**
|
73
|
+
* GCC will warn if you specify a function or parameter that is unused at
|
74
|
+
* runtime. This macro allows you to mark a function or parameter as unused in a
|
75
|
+
* compiler-agnostic way.
|
76
|
+
*/
|
77
|
+
#if defined(__GNUC__)
|
78
|
+
# define PRISM_ATTRIBUTE_UNUSED __attribute__((unused))
|
79
|
+
#else
|
80
|
+
# define PRISM_ATTRIBUTE_UNUSED
|
81
|
+
#endif
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Old Visual Studio versions do not support the inline keyword, so we need to
|
85
|
+
* define it to be __inline.
|
86
|
+
*/
|
87
|
+
#if defined(_MSC_VER) && !defined(inline)
|
88
|
+
# define inline __inline
|
89
|
+
#endif
|
90
|
+
|
91
|
+
/**
|
92
|
+
* Old Visual Studio versions before 2015 do not implement sprintf, but instead
|
93
|
+
* implement _snprintf. We standard that here.
|
94
|
+
*/
|
95
|
+
#if !defined(snprintf) && defined(_MSC_VER) && (_MSC_VER < 1900)
|
96
|
+
# define snprintf _snprintf
|
97
|
+
#endif
|
98
|
+
|
99
|
+
/**
|
100
|
+
* A simple utility macro to concatenate two tokens together, necessary when one
|
101
|
+
* of the tokens is itself a macro.
|
102
|
+
*/
|
103
|
+
#define PM_CONCATENATE(left, right) left ## right
|
104
|
+
|
105
|
+
/**
|
106
|
+
* We want to be able to use static assertions, but they weren't standardized
|
107
|
+
* until C11. As such, we polyfill it here by making a hacky typedef that will
|
108
|
+
* fail to compile due to a negative array size if the condition is false.
|
109
|
+
*/
|
110
|
+
#if defined(_Static_assert)
|
111
|
+
# define PM_STATIC_ASSERT(line, condition, message) _Static_assert(condition, message)
|
112
|
+
#else
|
113
|
+
# define PM_STATIC_ASSERT(line, condition, message) typedef char PM_CONCATENATE(static_assert_, line)[(condition) ? 1 : -1]
|
114
|
+
#endif
|
115
|
+
|
116
|
+
/**
|
117
|
+
* In general, libc for embedded systems does not support memory-mapped files.
|
118
|
+
* If the target platform is POSIX or Windows, we can map a file in memory and
|
119
|
+
* read it in a more efficient manner.
|
120
|
+
*/
|
121
|
+
#ifdef _WIN32
|
122
|
+
# define PRISM_HAS_MMAP
|
123
|
+
#else
|
124
|
+
# include <unistd.h>
|
125
|
+
# ifdef _POSIX_MAPPED_FILES
|
126
|
+
# define PRISM_HAS_MMAP
|
127
|
+
# endif
|
128
|
+
#endif
|
129
|
+
|
130
|
+
/**
|
131
|
+
* If PRISM_HAS_NO_FILESYSTEM is defined, then we want to exclude all filesystem
|
132
|
+
* related code from the library. All filesystem related code should be guarded
|
133
|
+
* by PRISM_HAS_FILESYSTEM.
|
134
|
+
*/
|
135
|
+
#ifndef PRISM_HAS_NO_FILESYSTEM
|
136
|
+
# define PRISM_HAS_FILESYSTEM
|
137
|
+
#endif
|
138
|
+
|
139
|
+
/**
|
140
|
+
* isinf on Windows is defined as accepting a float, but on POSIX systems it
|
141
|
+
* accepts a float, a double, or a long double. We want to mirror this behavior
|
142
|
+
* on windows.
|
143
|
+
*/
|
144
|
+
#ifdef _WIN32
|
145
|
+
# include <float.h>
|
146
|
+
# undef isinf
|
147
|
+
# define isinf(x) (sizeof(x) == sizeof(float) ? !_finitef(x) : !_finite(x))
|
148
|
+
#endif
|
149
|
+
|
150
|
+
/**
|
151
|
+
* If you build prism with a custom allocator, configure it with
|
152
|
+
* "-D PRISM_XALLOCATOR" to use your own allocator that defines xmalloc,
|
153
|
+
* xrealloc, xcalloc, and xfree.
|
154
|
+
*
|
155
|
+
* For example, your `prism_xallocator.h` file could look like this:
|
156
|
+
*
|
157
|
+
* ```
|
158
|
+
* #ifndef PRISM_XALLOCATOR_H
|
159
|
+
* #define PRISM_XALLOCATOR_H
|
160
|
+
* #define xmalloc my_malloc
|
161
|
+
* #define xrealloc my_realloc
|
162
|
+
* #define xcalloc my_calloc
|
163
|
+
* #define xfree my_free
|
164
|
+
* #endif
|
165
|
+
* ```
|
166
|
+
*/
|
167
|
+
#ifdef PRISM_XALLOCATOR
|
168
|
+
#include "prism_xallocator.h"
|
169
|
+
#else
|
170
|
+
#ifndef xmalloc
|
171
|
+
/**
|
172
|
+
* The malloc function that should be used. This can be overridden with
|
173
|
+
* the PRISM_XALLOCATOR define.
|
174
|
+
*/
|
175
|
+
#define xmalloc malloc
|
176
|
+
#endif
|
177
|
+
|
178
|
+
#ifndef xrealloc
|
179
|
+
/**
|
180
|
+
* The realloc function that should be used. This can be overridden with
|
181
|
+
* the PRISM_XALLOCATOR define.
|
182
|
+
*/
|
183
|
+
#define xrealloc realloc
|
184
|
+
#endif
|
185
|
+
|
186
|
+
#ifndef xcalloc
|
187
|
+
/**
|
188
|
+
* The calloc function that should be used. This can be overridden with
|
189
|
+
* the PRISM_XALLOCATOR define.
|
190
|
+
*/
|
191
|
+
#define xcalloc calloc
|
192
|
+
#endif
|
193
|
+
|
194
|
+
#ifndef xfree
|
195
|
+
/**
|
196
|
+
* The free function that should be used. This can be overridden with the
|
197
|
+
* PRISM_XALLOCATOR define.
|
198
|
+
*/
|
199
|
+
#define xfree free
|
200
|
+
#endif
|
201
|
+
#endif
|
202
|
+
|
203
|
+
/**
|
204
|
+
* If PRISM_BUILD_MINIMAL is defined, then we're going to define every possible
|
205
|
+
* switch that will turn off certain features of prism.
|
206
|
+
*/
|
207
|
+
#ifdef PRISM_BUILD_MINIMAL
|
208
|
+
/** Exclude the serialization API. */
|
209
|
+
#define PRISM_EXCLUDE_SERIALIZATION
|
210
|
+
|
211
|
+
/** Exclude the JSON serialization API. */
|
212
|
+
#define PRISM_EXCLUDE_JSON
|
213
|
+
|
214
|
+
/** Exclude the Array#pack parser API. */
|
215
|
+
#define PRISM_EXCLUDE_PACK
|
216
|
+
|
217
|
+
/** Exclude the prettyprint API. */
|
218
|
+
#define PRISM_EXCLUDE_PRETTYPRINT
|
219
|
+
|
220
|
+
/** Exclude the full set of encodings, using the minimal only. */
|
221
|
+
#define PRISM_ENCODING_EXCLUDE_FULL
|
222
|
+
#endif
|
223
|
+
|
224
|
+
/**
|
225
|
+
* Support PRISM_LIKELY and PRISM_UNLIKELY to help the compiler optimize its
|
226
|
+
* branch predication.
|
227
|
+
*/
|
228
|
+
#if defined(__GNUC__) || defined(__clang__)
|
229
|
+
/** The compiler should predicate that this branch will be taken. */
|
230
|
+
#define PRISM_LIKELY(x) __builtin_expect(!!(x), 1)
|
231
|
+
|
232
|
+
/** The compiler should predicate that this branch will not be taken. */
|
233
|
+
#define PRISM_UNLIKELY(x) __builtin_expect(!!(x), 0)
|
234
|
+
#else
|
235
|
+
/** Void because this platform does not support branch prediction hints. */
|
236
|
+
#define PRISM_LIKELY(x) (x)
|
237
|
+
|
238
|
+
/** Void because this platform does not support branch prediction hints. */
|
239
|
+
#define PRISM_UNLIKELY(x) (x)
|
240
|
+
#endif
|
241
|
+
|
242
|
+
#endif
|
@@ -0,0 +1,450 @@
|
|
1
|
+
/*----------------------------------------------------------------------------*/
|
2
|
+
/* This file is generated by the templates/template.rb script and should not */
|
3
|
+
/* be modified manually. See */
|
4
|
+
/* templates/include/prism/diagnostic.h.erb */
|
5
|
+
/* if you are looking to modify the */
|
6
|
+
/* template */
|
7
|
+
/*----------------------------------------------------------------------------*/
|
8
|
+
|
9
|
+
/**
|
10
|
+
* @file diagnostic.h
|
11
|
+
*
|
12
|
+
* A list of diagnostics generated during parsing.
|
13
|
+
*/
|
14
|
+
#ifndef PRISM_DIAGNOSTIC_H
|
15
|
+
#define PRISM_DIAGNOSTIC_H
|
16
|
+
|
17
|
+
#include "prism/ast.h"
|
18
|
+
#include "prism/defines.h"
|
19
|
+
#include "prism/util/pm_list.h"
|
20
|
+
|
21
|
+
#include <stdbool.h>
|
22
|
+
#include <stdlib.h>
|
23
|
+
#include <assert.h>
|
24
|
+
|
25
|
+
/**
|
26
|
+
* The diagnostic IDs of all of the diagnostics, used to communicate the types
|
27
|
+
* of errors between the parser and the user.
|
28
|
+
*/
|
29
|
+
typedef enum {
|
30
|
+
// These are the error diagnostics.
|
31
|
+
PM_ERR_ALIAS_ARGUMENT,
|
32
|
+
PM_ERR_ALIAS_ARGUMENT_NUMBERED_REFERENCE,
|
33
|
+
PM_ERR_AMPAMPEQ_MULTI_ASSIGN,
|
34
|
+
PM_ERR_ARGUMENT_AFTER_BLOCK,
|
35
|
+
PM_ERR_ARGUMENT_AFTER_FORWARDING_ELLIPSES,
|
36
|
+
PM_ERR_ARGUMENT_BARE_HASH,
|
37
|
+
PM_ERR_ARGUMENT_BLOCK_FORWARDING,
|
38
|
+
PM_ERR_ARGUMENT_BLOCK_MULTI,
|
39
|
+
PM_ERR_ARGUMENT_CONFLICT_AMPERSAND,
|
40
|
+
PM_ERR_ARGUMENT_CONFLICT_STAR,
|
41
|
+
PM_ERR_ARGUMENT_CONFLICT_STAR_STAR,
|
42
|
+
PM_ERR_ARGUMENT_FORMAL_CLASS,
|
43
|
+
PM_ERR_ARGUMENT_FORMAL_CONSTANT,
|
44
|
+
PM_ERR_ARGUMENT_FORMAL_GLOBAL,
|
45
|
+
PM_ERR_ARGUMENT_FORMAL_IVAR,
|
46
|
+
PM_ERR_ARGUMENT_FORWARDING_UNBOUND,
|
47
|
+
PM_ERR_ARGUMENT_NO_FORWARDING_AMPERSAND,
|
48
|
+
PM_ERR_ARGUMENT_NO_FORWARDING_ELLIPSES,
|
49
|
+
PM_ERR_ARGUMENT_NO_FORWARDING_STAR,
|
50
|
+
PM_ERR_ARGUMENT_NO_FORWARDING_STAR_STAR,
|
51
|
+
PM_ERR_ARGUMENT_SPLAT_AFTER_ASSOC_SPLAT,
|
52
|
+
PM_ERR_ARGUMENT_SPLAT_AFTER_SPLAT,
|
53
|
+
PM_ERR_ARGUMENT_TERM_PAREN,
|
54
|
+
PM_ERR_ARGUMENT_UNEXPECTED_BLOCK,
|
55
|
+
PM_ERR_ARRAY_ELEMENT,
|
56
|
+
PM_ERR_ARRAY_EXPRESSION,
|
57
|
+
PM_ERR_ARRAY_EXPRESSION_AFTER_STAR,
|
58
|
+
PM_ERR_ARRAY_SEPARATOR,
|
59
|
+
PM_ERR_ARRAY_TERM,
|
60
|
+
PM_ERR_BEGIN_LONELY_ELSE,
|
61
|
+
PM_ERR_BEGIN_TERM,
|
62
|
+
PM_ERR_BEGIN_UPCASE_BRACE,
|
63
|
+
PM_ERR_BEGIN_UPCASE_TERM,
|
64
|
+
PM_ERR_BEGIN_UPCASE_TOPLEVEL,
|
65
|
+
PM_ERR_BLOCK_PARAM_LOCAL_VARIABLE,
|
66
|
+
PM_ERR_BLOCK_PARAM_PIPE_TERM,
|
67
|
+
PM_ERR_BLOCK_TERM_BRACE,
|
68
|
+
PM_ERR_BLOCK_TERM_END,
|
69
|
+
PM_ERR_CANNOT_PARSE_EXPRESSION,
|
70
|
+
PM_ERR_CANNOT_PARSE_STRING_PART,
|
71
|
+
PM_ERR_CASE_EXPRESSION_AFTER_CASE,
|
72
|
+
PM_ERR_CASE_EXPRESSION_AFTER_WHEN,
|
73
|
+
PM_ERR_CASE_MATCH_MISSING_PREDICATE,
|
74
|
+
PM_ERR_CASE_MISSING_CONDITIONS,
|
75
|
+
PM_ERR_CASE_TERM,
|
76
|
+
PM_ERR_CLASS_IN_METHOD,
|
77
|
+
PM_ERR_CLASS_NAME,
|
78
|
+
PM_ERR_CLASS_SUPERCLASS,
|
79
|
+
PM_ERR_CLASS_TERM,
|
80
|
+
PM_ERR_CLASS_UNEXPECTED_END,
|
81
|
+
PM_ERR_CLASS_VARIABLE_BARE,
|
82
|
+
PM_ERR_CONDITIONAL_ELSIF_PREDICATE,
|
83
|
+
PM_ERR_CONDITIONAL_IF_PREDICATE,
|
84
|
+
PM_ERR_CONDITIONAL_PREDICATE_TERM,
|
85
|
+
PM_ERR_CONDITIONAL_TERM,
|
86
|
+
PM_ERR_CONDITIONAL_TERM_ELSE,
|
87
|
+
PM_ERR_CONDITIONAL_UNLESS_PREDICATE,
|
88
|
+
PM_ERR_CONDITIONAL_UNTIL_PREDICATE,
|
89
|
+
PM_ERR_CONDITIONAL_WHILE_PREDICATE,
|
90
|
+
PM_ERR_CONSTANT_PATH_COLON_COLON_CONSTANT,
|
91
|
+
PM_ERR_DEF_ENDLESS,
|
92
|
+
PM_ERR_DEF_ENDLESS_SETTER,
|
93
|
+
PM_ERR_DEF_NAME,
|
94
|
+
PM_ERR_DEF_PARAMS_TERM,
|
95
|
+
PM_ERR_DEF_PARAMS_TERM_PAREN,
|
96
|
+
PM_ERR_DEF_RECEIVER,
|
97
|
+
PM_ERR_DEF_RECEIVER_TERM,
|
98
|
+
PM_ERR_DEF_TERM,
|
99
|
+
PM_ERR_DEFINED_EXPRESSION,
|
100
|
+
PM_ERR_EMBDOC_TERM,
|
101
|
+
PM_ERR_EMBEXPR_END,
|
102
|
+
PM_ERR_EMBVAR_INVALID,
|
103
|
+
PM_ERR_END_UPCASE_BRACE,
|
104
|
+
PM_ERR_END_UPCASE_TERM,
|
105
|
+
PM_ERR_ESCAPE_INVALID_CONTROL,
|
106
|
+
PM_ERR_ESCAPE_INVALID_CONTROL_REPEAT,
|
107
|
+
PM_ERR_ESCAPE_INVALID_HEXADECIMAL,
|
108
|
+
PM_ERR_ESCAPE_INVALID_META,
|
109
|
+
PM_ERR_ESCAPE_INVALID_META_REPEAT,
|
110
|
+
PM_ERR_ESCAPE_INVALID_UNICODE,
|
111
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_CM_FLAGS,
|
112
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_LIST,
|
113
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_LITERAL,
|
114
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_LONG,
|
115
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_SHORT,
|
116
|
+
PM_ERR_ESCAPE_INVALID_UNICODE_TERM,
|
117
|
+
PM_ERR_EXPECT_ARGUMENT,
|
118
|
+
PM_ERR_EXPECT_EOL_AFTER_STATEMENT,
|
119
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_AMPAMPEQ,
|
120
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_COMMA,
|
121
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_EQUAL,
|
122
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_LESS_LESS,
|
123
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_LPAREN,
|
124
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_OPERATOR,
|
125
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_PIPEPIPEEQ,
|
126
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_QUESTION,
|
127
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT,
|
128
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_SPLAT_HASH,
|
129
|
+
PM_ERR_EXPECT_EXPRESSION_AFTER_STAR,
|
130
|
+
PM_ERR_EXPECT_FOR_DELIMITER,
|
131
|
+
PM_ERR_EXPECT_IDENT_REQ_PARAMETER,
|
132
|
+
PM_ERR_EXPECT_IN_DELIMITER,
|
133
|
+
PM_ERR_EXPECT_LPAREN_REQ_PARAMETER,
|
134
|
+
PM_ERR_EXPECT_MESSAGE,
|
135
|
+
PM_ERR_EXPECT_RBRACKET,
|
136
|
+
PM_ERR_EXPECT_RPAREN,
|
137
|
+
PM_ERR_EXPECT_RPAREN_AFTER_MULTI,
|
138
|
+
PM_ERR_EXPECT_RPAREN_REQ_PARAMETER,
|
139
|
+
PM_ERR_EXPECT_SINGLETON_CLASS_DELIMITER,
|
140
|
+
PM_ERR_EXPECT_STRING_CONTENT,
|
141
|
+
PM_ERR_EXPECT_WHEN_DELIMITER,
|
142
|
+
PM_ERR_EXPRESSION_BARE_HASH,
|
143
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE,
|
144
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_ENCODING,
|
145
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_FALSE,
|
146
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_FILE,
|
147
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_LINE,
|
148
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_NIL,
|
149
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_NUMBERED,
|
150
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_SELF,
|
151
|
+
PM_ERR_EXPRESSION_NOT_WRITABLE_TRUE,
|
152
|
+
PM_ERR_FLOAT_PARSE,
|
153
|
+
PM_ERR_FOR_COLLECTION,
|
154
|
+
PM_ERR_FOR_IN,
|
155
|
+
PM_ERR_FOR_INDEX,
|
156
|
+
PM_ERR_FOR_TERM,
|
157
|
+
PM_ERR_GLOBAL_VARIABLE_BARE,
|
158
|
+
PM_ERR_HASH_EXPRESSION_AFTER_LABEL,
|
159
|
+
PM_ERR_HASH_KEY,
|
160
|
+
PM_ERR_HASH_ROCKET,
|
161
|
+
PM_ERR_HASH_TERM,
|
162
|
+
PM_ERR_HASH_VALUE,
|
163
|
+
PM_ERR_HEREDOC_IDENTIFIER,
|
164
|
+
PM_ERR_HEREDOC_TERM,
|
165
|
+
PM_ERR_INCOMPLETE_QUESTION_MARK,
|
166
|
+
PM_ERR_INCOMPLETE_VARIABLE_CLASS,
|
167
|
+
PM_ERR_INCOMPLETE_VARIABLE_CLASS_3_3,
|
168
|
+
PM_ERR_INCOMPLETE_VARIABLE_INSTANCE,
|
169
|
+
PM_ERR_INCOMPLETE_VARIABLE_INSTANCE_3_3,
|
170
|
+
PM_ERR_INSTANCE_VARIABLE_BARE,
|
171
|
+
PM_ERR_INVALID_BLOCK_EXIT,
|
172
|
+
PM_ERR_INVALID_CHARACTER,
|
173
|
+
PM_ERR_INVALID_ENCODING_MAGIC_COMMENT,
|
174
|
+
PM_ERR_INVALID_ESCAPE_CHARACTER,
|
175
|
+
PM_ERR_INVALID_FLOAT_EXPONENT,
|
176
|
+
PM_ERR_INVALID_LOCAL_VARIABLE_READ,
|
177
|
+
PM_ERR_INVALID_LOCAL_VARIABLE_WRITE,
|
178
|
+
PM_ERR_INVALID_MULTIBYTE_CHAR,
|
179
|
+
PM_ERR_INVALID_MULTIBYTE_CHARACTER,
|
180
|
+
PM_ERR_INVALID_MULTIBYTE_ESCAPE,
|
181
|
+
PM_ERR_INVALID_NUMBER_BINARY,
|
182
|
+
PM_ERR_INVALID_NUMBER_DECIMAL,
|
183
|
+
PM_ERR_INVALID_NUMBER_FRACTION,
|
184
|
+
PM_ERR_INVALID_NUMBER_HEXADECIMAL,
|
185
|
+
PM_ERR_INVALID_NUMBER_OCTAL,
|
186
|
+
PM_ERR_INVALID_NUMBER_UNDERSCORE_INNER,
|
187
|
+
PM_ERR_INVALID_NUMBER_UNDERSCORE_TRAILING,
|
188
|
+
PM_ERR_INVALID_PERCENT,
|
189
|
+
PM_ERR_INVALID_PERCENT_EOF,
|
190
|
+
PM_ERR_INVALID_PRINTABLE_CHARACTER,
|
191
|
+
PM_ERR_INVALID_RETRY_AFTER_ELSE,
|
192
|
+
PM_ERR_INVALID_RETRY_AFTER_ENSURE,
|
193
|
+
PM_ERR_INVALID_RETRY_WITHOUT_RESCUE,
|
194
|
+
PM_ERR_INVALID_SYMBOL,
|
195
|
+
PM_ERR_INVALID_VARIABLE_GLOBAL,
|
196
|
+
PM_ERR_INVALID_VARIABLE_GLOBAL_3_3,
|
197
|
+
PM_ERR_INVALID_YIELD,
|
198
|
+
PM_ERR_IT_NOT_ALLOWED_NUMBERED,
|
199
|
+
PM_ERR_IT_NOT_ALLOWED_ORDINARY,
|
200
|
+
PM_ERR_LAMBDA_OPEN,
|
201
|
+
PM_ERR_LAMBDA_TERM_BRACE,
|
202
|
+
PM_ERR_LAMBDA_TERM_END,
|
203
|
+
PM_ERR_LIST_I_LOWER_ELEMENT,
|
204
|
+
PM_ERR_LIST_I_LOWER_TERM,
|
205
|
+
PM_ERR_LIST_I_UPPER_ELEMENT,
|
206
|
+
PM_ERR_LIST_I_UPPER_TERM,
|
207
|
+
PM_ERR_LIST_W_LOWER_ELEMENT,
|
208
|
+
PM_ERR_LIST_W_LOWER_TERM,
|
209
|
+
PM_ERR_LIST_W_UPPER_ELEMENT,
|
210
|
+
PM_ERR_LIST_W_UPPER_TERM,
|
211
|
+
PM_ERR_MALLOC_FAILED,
|
212
|
+
PM_ERR_MIXED_ENCODING,
|
213
|
+
PM_ERR_MODULE_IN_METHOD,
|
214
|
+
PM_ERR_MODULE_NAME,
|
215
|
+
PM_ERR_MODULE_TERM,
|
216
|
+
PM_ERR_MULTI_ASSIGN_MULTI_SPLATS,
|
217
|
+
PM_ERR_MULTI_ASSIGN_UNEXPECTED_REST,
|
218
|
+
PM_ERR_NESTING_TOO_DEEP,
|
219
|
+
PM_ERR_NO_LOCAL_VARIABLE,
|
220
|
+
PM_ERR_NON_ASSOCIATIVE_OPERATOR,
|
221
|
+
PM_ERR_NOT_EXPRESSION,
|
222
|
+
PM_ERR_NUMBER_LITERAL_UNDERSCORE,
|
223
|
+
PM_ERR_NUMBERED_PARAMETER_INNER_BLOCK,
|
224
|
+
PM_ERR_NUMBERED_PARAMETER_IT,
|
225
|
+
PM_ERR_NUMBERED_PARAMETER_ORDINARY,
|
226
|
+
PM_ERR_NUMBERED_PARAMETER_OUTER_BLOCK,
|
227
|
+
PM_ERR_OPERATOR_MULTI_ASSIGN,
|
228
|
+
PM_ERR_OPERATOR_WRITE_ARGUMENTS,
|
229
|
+
PM_ERR_OPERATOR_WRITE_BLOCK,
|
230
|
+
PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI,
|
231
|
+
PM_ERR_PARAMETER_BLOCK_MULTI,
|
232
|
+
PM_ERR_PARAMETER_CIRCULAR,
|
233
|
+
PM_ERR_PARAMETER_FORWARDING_AFTER_REST,
|
234
|
+
PM_ERR_PARAMETER_METHOD_NAME,
|
235
|
+
PM_ERR_PARAMETER_NAME_DUPLICATED,
|
236
|
+
PM_ERR_PARAMETER_NO_DEFAULT,
|
237
|
+
PM_ERR_PARAMETER_NO_DEFAULT_KW,
|
238
|
+
PM_ERR_PARAMETER_NUMBERED_RESERVED,
|
239
|
+
PM_ERR_PARAMETER_ORDER,
|
240
|
+
PM_ERR_PARAMETER_SPLAT_MULTI,
|
241
|
+
PM_ERR_PARAMETER_STAR,
|
242
|
+
PM_ERR_PARAMETER_UNEXPECTED_FWD,
|
243
|
+
PM_ERR_PARAMETER_UNEXPECTED_NO_KW,
|
244
|
+
PM_ERR_PARAMETER_WILD_LOOSE_COMMA,
|
245
|
+
PM_ERR_PATTERN_ARRAY_MULTIPLE_RESTS,
|
246
|
+
PM_ERR_PATTERN_CAPTURE_DUPLICATE,
|
247
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET,
|
248
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA,
|
249
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_HROCKET,
|
250
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_IN,
|
251
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_KEY,
|
252
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_PAREN,
|
253
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_PIN,
|
254
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_PIPE,
|
255
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_RANGE,
|
256
|
+
PM_ERR_PATTERN_EXPRESSION_AFTER_REST,
|
257
|
+
PM_ERR_PATTERN_FIND_MISSING_INNER,
|
258
|
+
PM_ERR_PATTERN_HASH_IMPLICIT,
|
259
|
+
PM_ERR_PATTERN_HASH_KEY,
|
260
|
+
PM_ERR_PATTERN_HASH_KEY_DUPLICATE,
|
261
|
+
PM_ERR_PATTERN_HASH_KEY_INTERPOLATED,
|
262
|
+
PM_ERR_PATTERN_HASH_KEY_LABEL,
|
263
|
+
PM_ERR_PATTERN_HASH_KEY_LOCALS,
|
264
|
+
PM_ERR_PATTERN_IDENT_AFTER_HROCKET,
|
265
|
+
PM_ERR_PATTERN_LABEL_AFTER_COMMA,
|
266
|
+
PM_ERR_PATTERN_REST,
|
267
|
+
PM_ERR_PATTERN_TERM_BRACE,
|
268
|
+
PM_ERR_PATTERN_TERM_BRACKET,
|
269
|
+
PM_ERR_PATTERN_TERM_PAREN,
|
270
|
+
PM_ERR_PIPEPIPEEQ_MULTI_ASSIGN,
|
271
|
+
PM_ERR_REGEXP_ENCODING_OPTION_MISMATCH,
|
272
|
+
PM_ERR_REGEXP_INCOMPAT_CHAR_ENCODING,
|
273
|
+
PM_ERR_REGEXP_INVALID_UNICODE_RANGE,
|
274
|
+
PM_ERR_REGEXP_NON_ESCAPED_MBC,
|
275
|
+
PM_ERR_REGEXP_PARSE_ERROR,
|
276
|
+
PM_ERR_REGEXP_TERM,
|
277
|
+
PM_ERR_REGEXP_UNKNOWN_OPTIONS,
|
278
|
+
PM_ERR_REGEXP_UTF8_CHAR_NON_UTF8_REGEXP,
|
279
|
+
PM_ERR_RESCUE_EXPRESSION,
|
280
|
+
PM_ERR_RESCUE_MODIFIER_VALUE,
|
281
|
+
PM_ERR_RESCUE_TERM,
|
282
|
+
PM_ERR_RESCUE_VARIABLE,
|
283
|
+
PM_ERR_RETURN_INVALID,
|
284
|
+
PM_ERR_SCRIPT_NOT_FOUND,
|
285
|
+
PM_ERR_SINGLETON_FOR_LITERALS,
|
286
|
+
PM_ERR_STATEMENT_ALIAS,
|
287
|
+
PM_ERR_STATEMENT_POSTEXE_END,
|
288
|
+
PM_ERR_STATEMENT_PREEXE_BEGIN,
|
289
|
+
PM_ERR_STATEMENT_UNDEF,
|
290
|
+
PM_ERR_STRING_CONCATENATION,
|
291
|
+
PM_ERR_STRING_INTERPOLATED_TERM,
|
292
|
+
PM_ERR_STRING_LITERAL_EOF,
|
293
|
+
PM_ERR_STRING_LITERAL_TERM,
|
294
|
+
PM_ERR_SYMBOL_INVALID,
|
295
|
+
PM_ERR_SYMBOL_TERM_DYNAMIC,
|
296
|
+
PM_ERR_SYMBOL_TERM_INTERPOLATED,
|
297
|
+
PM_ERR_TERNARY_COLON,
|
298
|
+
PM_ERR_TERNARY_EXPRESSION_FALSE,
|
299
|
+
PM_ERR_TERNARY_EXPRESSION_TRUE,
|
300
|
+
PM_ERR_UNARY_DISALLOWED,
|
301
|
+
PM_ERR_UNARY_RECEIVER,
|
302
|
+
PM_ERR_UNDEF_ARGUMENT,
|
303
|
+
PM_ERR_UNEXPECTED_BLOCK_ARGUMENT,
|
304
|
+
PM_ERR_UNEXPECTED_INDEX_BLOCK,
|
305
|
+
PM_ERR_UNEXPECTED_INDEX_KEYWORDS,
|
306
|
+
PM_ERR_UNEXPECTED_LABEL,
|
307
|
+
PM_ERR_UNEXPECTED_MULTI_WRITE,
|
308
|
+
PM_ERR_UNEXPECTED_RANGE_OPERATOR,
|
309
|
+
PM_ERR_UNEXPECTED_SAFE_NAVIGATION,
|
310
|
+
PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT,
|
311
|
+
PM_ERR_UNEXPECTED_TOKEN_IGNORE,
|
312
|
+
PM_ERR_UNTIL_TERM,
|
313
|
+
PM_ERR_VOID_EXPRESSION,
|
314
|
+
PM_ERR_WHILE_TERM,
|
315
|
+
PM_ERR_WRITE_TARGET_IN_METHOD,
|
316
|
+
PM_ERR_WRITE_TARGET_READONLY,
|
317
|
+
PM_ERR_WRITE_TARGET_UNEXPECTED,
|
318
|
+
PM_ERR_XSTRING_TERM,
|
319
|
+
|
320
|
+
// These are the warning diagnostics.
|
321
|
+
PM_WARN_AMBIGUOUS_BINARY_OPERATOR,
|
322
|
+
PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_MINUS,
|
323
|
+
PM_WARN_AMBIGUOUS_FIRST_ARGUMENT_PLUS,
|
324
|
+
PM_WARN_AMBIGUOUS_PREFIX_AMPERSAND,
|
325
|
+
PM_WARN_AMBIGUOUS_PREFIX_STAR,
|
326
|
+
PM_WARN_AMBIGUOUS_PREFIX_STAR_STAR,
|
327
|
+
PM_WARN_AMBIGUOUS_SLASH,
|
328
|
+
PM_WARN_COMPARISON_AFTER_COMPARISON,
|
329
|
+
PM_WARN_DOT_DOT_DOT_EOL,
|
330
|
+
PM_WARN_EQUAL_IN_CONDITIONAL,
|
331
|
+
PM_WARN_EQUAL_IN_CONDITIONAL_3_3,
|
332
|
+
PM_WARN_END_IN_METHOD,
|
333
|
+
PM_WARN_DUPLICATED_HASH_KEY,
|
334
|
+
PM_WARN_DUPLICATED_WHEN_CLAUSE,
|
335
|
+
PM_WARN_FLOAT_OUT_OF_RANGE,
|
336
|
+
PM_WARN_IGNORED_FROZEN_STRING_LITERAL,
|
337
|
+
PM_WARN_INDENTATION_MISMATCH,
|
338
|
+
PM_WARN_INTEGER_IN_FLIP_FLOP,
|
339
|
+
PM_WARN_INVALID_CHARACTER,
|
340
|
+
PM_WARN_INVALID_MAGIC_COMMENT_VALUE,
|
341
|
+
PM_WARN_INVALID_NUMBERED_REFERENCE,
|
342
|
+
PM_WARN_KEYWORD_EOL,
|
343
|
+
PM_WARN_LITERAL_IN_CONDITION_DEFAULT,
|
344
|
+
PM_WARN_LITERAL_IN_CONDITION_VERBOSE,
|
345
|
+
PM_WARN_SHAREABLE_CONSTANT_VALUE_LINE,
|
346
|
+
PM_WARN_SHEBANG_CARRIAGE_RETURN,
|
347
|
+
PM_WARN_UNEXPECTED_CARRIAGE_RETURN,
|
348
|
+
PM_WARN_UNREACHABLE_STATEMENT,
|
349
|
+
PM_WARN_UNUSED_LOCAL_VARIABLE,
|
350
|
+
PM_WARN_VOID_STATEMENT,
|
351
|
+
} pm_diagnostic_id_t;
|
352
|
+
|
353
|
+
/**
|
354
|
+
* This struct represents a diagnostic generated during parsing.
|
355
|
+
*
|
356
|
+
* @extends pm_list_node_t
|
357
|
+
*/
|
358
|
+
typedef struct {
|
359
|
+
/** The embedded base node. */
|
360
|
+
pm_list_node_t node;
|
361
|
+
|
362
|
+
/** The location of the diagnostic in the source. */
|
363
|
+
pm_location_t location;
|
364
|
+
|
365
|
+
/** The ID of the diagnostic. */
|
366
|
+
pm_diagnostic_id_t diag_id;
|
367
|
+
|
368
|
+
/** The message associated with the diagnostic. */
|
369
|
+
const char *message;
|
370
|
+
|
371
|
+
/**
|
372
|
+
* Whether or not the memory related to the message of this diagnostic is
|
373
|
+
* owned by this diagnostic. If it is, it needs to be freed when the
|
374
|
+
* diagnostic is freed.
|
375
|
+
*/
|
376
|
+
bool owned;
|
377
|
+
|
378
|
+
/**
|
379
|
+
* The level of the diagnostic, see `pm_error_level_t` and
|
380
|
+
* `pm_warning_level_t` for possible values.
|
381
|
+
*/
|
382
|
+
uint8_t level;
|
383
|
+
} pm_diagnostic_t;
|
384
|
+
|
385
|
+
/**
|
386
|
+
* The levels of errors generated during parsing.
|
387
|
+
*/
|
388
|
+
typedef enum {
|
389
|
+
/** For errors that should raise a syntax error. */
|
390
|
+
PM_ERROR_LEVEL_SYNTAX = 0,
|
391
|
+
|
392
|
+
/** For errors that should raise an argument error. */
|
393
|
+
PM_ERROR_LEVEL_ARGUMENT = 1,
|
394
|
+
|
395
|
+
/** For errors that should raise a load error. */
|
396
|
+
PM_ERROR_LEVEL_LOAD = 2
|
397
|
+
} pm_error_level_t;
|
398
|
+
|
399
|
+
/**
|
400
|
+
* The levels of warnings generated during parsing.
|
401
|
+
*/
|
402
|
+
typedef enum {
|
403
|
+
/** For warnings which should be emitted if $VERBOSE != nil. */
|
404
|
+
PM_WARNING_LEVEL_DEFAULT = 0,
|
405
|
+
|
406
|
+
/** For warnings which should be emitted if $VERBOSE == true. */
|
407
|
+
PM_WARNING_LEVEL_VERBOSE = 1
|
408
|
+
} pm_warning_level_t;
|
409
|
+
|
410
|
+
/**
|
411
|
+
* Get the human-readable name of the given diagnostic ID.
|
412
|
+
*
|
413
|
+
* @param diag_id The diagnostic ID.
|
414
|
+
* @return The human-readable name of the diagnostic ID.
|
415
|
+
*/
|
416
|
+
const char * pm_diagnostic_id_human(pm_diagnostic_id_t diag_id);
|
417
|
+
|
418
|
+
/**
|
419
|
+
* Append a diagnostic to the given list of diagnostics that is using shared
|
420
|
+
* memory for its message.
|
421
|
+
*
|
422
|
+
* @param list The list to append to.
|
423
|
+
* @param start The start of the diagnostic.
|
424
|
+
* @param end The end of the diagnostic.
|
425
|
+
* @param diag_id The diagnostic ID.
|
426
|
+
* @return Whether the diagnostic was successfully appended.
|
427
|
+
*/
|
428
|
+
bool pm_diagnostic_list_append(pm_list_t *list, const uint8_t *start, const uint8_t *end, pm_diagnostic_id_t diag_id);
|
429
|
+
|
430
|
+
/**
|
431
|
+
* Append a diagnostic to the given list of diagnostics that is using a format
|
432
|
+
* string for its message.
|
433
|
+
*
|
434
|
+
* @param list The list to append to.
|
435
|
+
* @param start The start of the diagnostic.
|
436
|
+
* @param end The end of the diagnostic.
|
437
|
+
* @param diag_id The diagnostic ID.
|
438
|
+
* @param ... The arguments to the format string for the message.
|
439
|
+
* @return Whether the diagnostic was successfully appended.
|
440
|
+
*/
|
441
|
+
bool pm_diagnostic_list_append_format(pm_list_t *list, const uint8_t *start, const uint8_t *end, pm_diagnostic_id_t diag_id, ...);
|
442
|
+
|
443
|
+
/**
|
444
|
+
* Deallocate the internal state of the given diagnostic list.
|
445
|
+
*
|
446
|
+
* @param list The list to deallocate.
|
447
|
+
*/
|
448
|
+
void pm_diagnostic_list_free(pm_list_t *list);
|
449
|
+
|
450
|
+
#endif
|