debase-ruby_core_source 4.0.1 → 4.1.0.preview1
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/CHANGELOG.md +4 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/addr2line.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/builtin.h +127 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/build_assert/build_assert.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/check_type/check_type.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/container_of/container_of.h +142 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/list/list.h +791 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ccan/str/str.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/constant.h +53 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/darray.h +295 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/debug_counter.h +428 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/dln.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/encindex.h +70 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/eval_intern.h +356 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/hrtime.h +237 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/id.h +365 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/id_table.h +74 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/insns.inc +315 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/insns_info.inc +11637 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/array.h +158 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/basic_operators.h +67 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/bignum.h +249 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/bits.h +647 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/box.h +103 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/class.h +797 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/cmdlineopt.h +64 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compar.h +30 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compile.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/compilers.h +104 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/complex.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/concurrent_set.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/cont.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/coverage.h +51 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/dir.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enc.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/encoding.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enum.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/enumerator.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/error.h +287 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/eval.h +43 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/file.h +40 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/fixnum.h +185 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/gc.h +411 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/hash.h +220 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/imemo.h +302 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/inits.h +54 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/io.h +167 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/io_buffer.h +36 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/jit.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/load.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/loadpath.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/marshal.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/math.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/missing.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/numeric.h +326 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/object.h +88 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/objspace.h +24 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/parse.h +131 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/proc.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/process.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/ractor.h +9 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/random.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/range.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/rational.h +92 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/re.h +87 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/ruby_parser.h +109 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/sanitizers.h +346 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/scheduler.h +7 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/serial.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/set.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/set_table.h +77 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/signal.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/simd.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/st.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/static_assert.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/string.h +240 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/struct.h +120 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/symbol.h +46 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/thread.h +108 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/time.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/transcode.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/util.h +27 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/variable.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/vm.h +144 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/vm_map.h +95 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal/warnings.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/internal.h +106 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/iseq.h +439 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/known_errors.inc +1419 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/method.h +279 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/node.h +122 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/node_name.inc +224 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/optinsn.inc +128 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/optunifs.inc +41 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parse.h +246 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_bits.h +647 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_node.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_st.h +161 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/parser_value.h +116 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/arena.h +37 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/ast.h +10371 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/buffer.h +52 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/comments.h +43 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/accel.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/align.h +36 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/assume.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/exported.h +24 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/fallthrough.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/filesystem.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/flex_array.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/force_inline.h +21 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/format.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/inline.h +17 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nodiscard.h +22 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/nonnull.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/compiler/unused.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/constant_pool.h +81 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/diagnostic.h +93 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/errors_format.h +53 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/excludes.h +29 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/extension.h +19 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/integer.h +41 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/allocator.h +68 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/allocator_debug.h +88 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/arena.h +108 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/bit.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/buffer.h +91 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/char.h +139 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/comments.h +20 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/constant_pool.h +152 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/diagnostic.h +389 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/encoding.h +242 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/integer.h +68 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/isinf.h +16 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/line_offset_list.h +34 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/list.h +62 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/magic_comments.h +23 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/memchr.h +15 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/node.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/options.h +224 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/parser.h +971 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/regexp.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/serialize.h +39 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/source.h +72 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/static_literals.h +100 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/stringy.h +35 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/strncasecmp.h +18 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/strpbrk.h +33 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/internal/tokens.h +11 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/json.h +32 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/line_offset_list.h +61 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/magic_comments.h +35 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/node.h +94 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/options.h +335 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/parser.h +348 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/prettyprint.h +31 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/prism.h +131 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/serialize.h +115 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/source.h +155 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/stream.h +28 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/string_query.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/stringy.h +72 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism/version.h +38 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism_compile.h +204 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/prism_xallocator.h +6 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/probes_helper.h +42 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ractor_core.h +421 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regenc.h +261 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regint.h +983 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/regparse.h +371 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/revision.h +5 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ruby_assert.h +14 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/ruby_atomic.h +115 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/rubyparser.h +1389 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/shape.h +733 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/siphash.h +48 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/symbol.h +116 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_none.h +25 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_pthread.h +63 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_sched.h +271 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/thread_win32.h +48 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/timev.h +58 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/transcode_data.h +138 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/variable.h +26 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/version.h +69 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm.inc +6457 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_call_iseq_optimized.inc +244 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_callinfo.h +688 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_core.h +2509 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_debug.h +124 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_exec.h +202 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_insnhelper.h +280 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_opts.h +65 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vm_sync.h +160 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/vmtc.inc +302 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/yjit.h +87 -0
- data/lib/debase/ruby_core_source/ruby-4.1.0-preview1/zjit.h +221 -0
- data/lib/debase/ruby_core_source/version.rb +1 -1
- metadata +2930 -2724
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file options.h
|
|
3
|
+
*
|
|
4
|
+
* The options that can be passed to parsing.
|
|
5
|
+
*/
|
|
6
|
+
#ifndef PRISM_OPTIONS_H
|
|
7
|
+
#define PRISM_OPTIONS_H
|
|
8
|
+
|
|
9
|
+
#include "prism/compiler/exported.h"
|
|
10
|
+
#include "prism/compiler/nodiscard.h"
|
|
11
|
+
#include "prism/compiler/nonnull.h"
|
|
12
|
+
|
|
13
|
+
#include "prism/stringy.h"
|
|
14
|
+
|
|
15
|
+
#include <stdbool.h>
|
|
16
|
+
#include <stddef.h>
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A scope of locals surrounding the code that is being parsed.
|
|
20
|
+
*/
|
|
21
|
+
typedef struct pm_options_scope_t pm_options_scope_t;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The options that can be passed to the parser.
|
|
25
|
+
*/
|
|
26
|
+
typedef struct pm_options_t pm_options_t;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* String literals should not be frozen.
|
|
30
|
+
*/
|
|
31
|
+
#define PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED ((int8_t) -1)
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* String literals may be frozen or mutable depending on the implementation
|
|
35
|
+
* default.
|
|
36
|
+
*/
|
|
37
|
+
#define PM_OPTIONS_FROZEN_STRING_LITERAL_UNSET ((int8_t) 0)
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* String literals should be made frozen.
|
|
41
|
+
*/
|
|
42
|
+
#define PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED ((int8_t) 1)
|
|
43
|
+
|
|
44
|
+
/** The default value for parameters. */
|
|
45
|
+
static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_NONE = 0x0;
|
|
46
|
+
|
|
47
|
+
/** When the scope is forwarding with the * parameter. */
|
|
48
|
+
static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_POSITIONALS = 0x1;
|
|
49
|
+
|
|
50
|
+
/** When the scope is forwarding with the ** parameter. */
|
|
51
|
+
static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_KEYWORDS = 0x2;
|
|
52
|
+
|
|
53
|
+
/** When the scope is forwarding with the & parameter. */
|
|
54
|
+
static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_BLOCK = 0x4;
|
|
55
|
+
|
|
56
|
+
/** When the scope is forwarding with the ... parameter. */
|
|
57
|
+
static const uint8_t PM_OPTIONS_SCOPE_FORWARDING_ALL = 0x8;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The callback called when additional switches are found in a shebang comment
|
|
61
|
+
* that need to be processed by the runtime.
|
|
62
|
+
*
|
|
63
|
+
* @param options The options struct that may be updated by this callback.
|
|
64
|
+
* Certain fields will be checked for changes, specifically encoding,
|
|
65
|
+
* command_line, and frozen_string_literal.
|
|
66
|
+
* @param source The source of the shebang comment.
|
|
67
|
+
* @param length The length of the source.
|
|
68
|
+
* @param shebang_callback_data Any additional data that should be passed along
|
|
69
|
+
* to the callback.
|
|
70
|
+
*/
|
|
71
|
+
typedef void (*pm_options_shebang_callback_t)(pm_options_t *options, const uint8_t *source, size_t length, void *shebang_callback_data);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A bit representing whether or not the command line -a option was set. -a
|
|
75
|
+
* splits the input line $_ into $F.
|
|
76
|
+
*/
|
|
77
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_A = 0x1;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A bit representing whether or not the command line -e option was set. -e
|
|
81
|
+
* allow the user to specify a script to be executed. This is necessary for
|
|
82
|
+
* prism to know because certain warnings are not generated when -e is used.
|
|
83
|
+
*/
|
|
84
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_E = 0x2;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A bit representing whether or not the command line -l option was set. -l
|
|
88
|
+
* chomps the input line by default.
|
|
89
|
+
*/
|
|
90
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_L = 0x4;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A bit representing whether or not the command line -n option was set. -n
|
|
94
|
+
* wraps the script in a while gets loop.
|
|
95
|
+
*/
|
|
96
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_N = 0x8;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A bit representing whether or not the command line -p option was set. -p
|
|
100
|
+
* prints the value of $_ at the end of each loop.
|
|
101
|
+
*/
|
|
102
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_P = 0x10;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A bit representing whether or not the command line -x option was set. -x
|
|
106
|
+
* searches the input file for a shebang that includes "ruby".
|
|
107
|
+
*/
|
|
108
|
+
static const uint8_t PM_OPTIONS_COMMAND_LINE_X = 0x20;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Allocate a new options struct. If the options struct cannot be allocated,
|
|
112
|
+
* this function aborts the process.
|
|
113
|
+
*
|
|
114
|
+
* @returns A new options struct with default values. It is the responsibility
|
|
115
|
+
* of the caller to free this struct using pm_options_free().
|
|
116
|
+
*/
|
|
117
|
+
PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_options_t * pm_options_new(void);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Free both the held memory of the given options struct and the struct itself.
|
|
121
|
+
*
|
|
122
|
+
* @param options The options struct to free.
|
|
123
|
+
*/
|
|
124
|
+
PRISM_EXPORTED_FUNCTION void pm_options_free(pm_options_t *options) PRISM_NONNULL(1);
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Set the shebang callback option on the given options struct.
|
|
128
|
+
*
|
|
129
|
+
* @param options The options struct to set the shebang callback on.
|
|
130
|
+
* @param shebang_callback The shebang callback to set.
|
|
131
|
+
* @param shebang_callback_data Any additional data that should be passed along
|
|
132
|
+
* to the callback.
|
|
133
|
+
*/
|
|
134
|
+
PRISM_EXPORTED_FUNCTION void pm_options_shebang_callback_set(pm_options_t *options, pm_options_shebang_callback_t shebang_callback, void *shebang_callback_data) PRISM_NONNULL(1);
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Get the filepath option on the given options struct.
|
|
138
|
+
*
|
|
139
|
+
* @param options The options struct to get the filepath from.
|
|
140
|
+
* @returns The filepath.
|
|
141
|
+
*/
|
|
142
|
+
PRISM_EXPORTED_FUNCTION const pm_string_t * pm_options_filepath(const pm_options_t *options) PRISM_NONNULL(1);
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Set the filepath option on the given options struct.
|
|
146
|
+
*
|
|
147
|
+
* @param options The options struct to set the filepath on.
|
|
148
|
+
* @param filepath The filepath to set.
|
|
149
|
+
*/
|
|
150
|
+
PRISM_EXPORTED_FUNCTION void pm_options_filepath_set(pm_options_t *options, const char *filepath) PRISM_NONNULL(1);
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Set the line option on the given options struct.
|
|
154
|
+
*
|
|
155
|
+
* @param options The options struct to set the line on.
|
|
156
|
+
* @param line The line to set.
|
|
157
|
+
*/
|
|
158
|
+
PRISM_EXPORTED_FUNCTION void pm_options_line_set(pm_options_t *options, int32_t line) PRISM_NONNULL(1);
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Set the encoding option on the given options struct.
|
|
162
|
+
*
|
|
163
|
+
* @param options The options struct to set the encoding on.
|
|
164
|
+
* @param encoding The encoding to set.
|
|
165
|
+
*/
|
|
166
|
+
PRISM_EXPORTED_FUNCTION void pm_options_encoding_set(pm_options_t *options, const char *encoding) PRISM_NONNULL(1);
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Set the encoding_locked option on the given options struct.
|
|
170
|
+
*
|
|
171
|
+
* @param options The options struct to set the encoding_locked value on.
|
|
172
|
+
* @param encoding_locked The encoding_locked value to set.
|
|
173
|
+
*/
|
|
174
|
+
PRISM_EXPORTED_FUNCTION void pm_options_encoding_locked_set(pm_options_t *options, bool encoding_locked) PRISM_NONNULL(1);
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Set the frozen string literal option on the given options struct.
|
|
178
|
+
*
|
|
179
|
+
* @param options The options struct to set the frozen string literal value on.
|
|
180
|
+
* @param frozen_string_literal The frozen string literal value to set.
|
|
181
|
+
*/
|
|
182
|
+
PRISM_EXPORTED_FUNCTION void pm_options_frozen_string_literal_set(pm_options_t *options, bool frozen_string_literal) PRISM_NONNULL(1);
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Sets the command line option on the given options struct.
|
|
186
|
+
*
|
|
187
|
+
* @param options The options struct to set the command line option on.
|
|
188
|
+
* @param command_line The command_line value to set.
|
|
189
|
+
*/
|
|
190
|
+
PRISM_EXPORTED_FUNCTION void pm_options_command_line_set(pm_options_t *options, uint8_t command_line) PRISM_NONNULL(1);
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Set the version option on the given options struct by parsing the given
|
|
194
|
+
* string. If the string contains an invalid option, this returns false.
|
|
195
|
+
* Otherwise, it returns true.
|
|
196
|
+
*
|
|
197
|
+
* @param options The options struct to set the version on.
|
|
198
|
+
* @param version The version to set.
|
|
199
|
+
* @param length The length of the version string.
|
|
200
|
+
* @returns Whether or not the version was parsed successfully.
|
|
201
|
+
*/
|
|
202
|
+
PRISM_EXPORTED_FUNCTION bool pm_options_version_set(pm_options_t *options, const char *version, size_t length) PRISM_NONNULL(1);
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Set the version option on the given options struct to the lowest version of
|
|
206
|
+
* Ruby that prism supports.
|
|
207
|
+
*
|
|
208
|
+
* @param options The options struct to set the version on.
|
|
209
|
+
*/
|
|
210
|
+
PRISM_EXPORTED_FUNCTION void pm_options_version_set_lowest(pm_options_t *options) PRISM_NONNULL(1);
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Set the version option on the given options struct to the highest version of
|
|
214
|
+
* Ruby that prism supports.
|
|
215
|
+
*
|
|
216
|
+
* @param options The options struct to set the version on.
|
|
217
|
+
*/
|
|
218
|
+
PRISM_EXPORTED_FUNCTION void pm_options_version_set_highest(pm_options_t *options) PRISM_NONNULL(1);
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Set the main script option on the given options struct.
|
|
222
|
+
*
|
|
223
|
+
* @param options The options struct to set the main script value on.
|
|
224
|
+
* @param main_script The main script value to set.
|
|
225
|
+
*/
|
|
226
|
+
PRISM_EXPORTED_FUNCTION void pm_options_main_script_set(pm_options_t *options, bool main_script) PRISM_NONNULL(1);
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Set the partial script option on the given options struct.
|
|
230
|
+
*
|
|
231
|
+
* @param options The options struct to set the partial script value on.
|
|
232
|
+
* @param partial_script The partial script value to set.
|
|
233
|
+
*/
|
|
234
|
+
PRISM_EXPORTED_FUNCTION void pm_options_partial_script_set(pm_options_t *options, bool partial_script) PRISM_NONNULL(1);
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Get the freeze option on the given options struct.
|
|
238
|
+
*
|
|
239
|
+
* @param options The options struct to get the freeze value from.
|
|
240
|
+
* @returns The freeze value.
|
|
241
|
+
*/
|
|
242
|
+
PRISM_EXPORTED_FUNCTION bool pm_options_freeze(const pm_options_t *options) PRISM_NONNULL(1);
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Set the freeze option on the given options struct.
|
|
246
|
+
*
|
|
247
|
+
* @param options The options struct to set the freeze value on.
|
|
248
|
+
* @param freeze The freeze value to set.
|
|
249
|
+
*/
|
|
250
|
+
PRISM_EXPORTED_FUNCTION void pm_options_freeze_set(pm_options_t *options, bool freeze) PRISM_NONNULL(1);
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Get the raise_error option on the given options struct.
|
|
254
|
+
*
|
|
255
|
+
* @param options The options struct to get the raise_error value from.
|
|
256
|
+
* @returns The raise_error value.
|
|
257
|
+
*/
|
|
258
|
+
PRISM_EXPORTED_FUNCTION uint8_t pm_options_raise_error(const pm_options_t *options) PRISM_NONNULL(1);
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Set the raise_error option on the given options struct.
|
|
262
|
+
*
|
|
263
|
+
* @param options The options struct to set the raise_error value on.
|
|
264
|
+
* @param raise_error The raise_error value to set.
|
|
265
|
+
*/
|
|
266
|
+
PRISM_EXPORTED_FUNCTION void pm_options_raise_error_set(pm_options_t *options, uint8_t raise_error) PRISM_NONNULL(1);
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Allocate and zero out the scopes array on the given options struct.
|
|
270
|
+
*
|
|
271
|
+
* @param options The options struct to initialize the scopes array on.
|
|
272
|
+
* @param scopes_count The number of scopes to allocate.
|
|
273
|
+
* @returns Whether or not the scopes array was initialized successfully.
|
|
274
|
+
*/
|
|
275
|
+
PRISM_EXPORTED_FUNCTION bool pm_options_scopes_init(pm_options_t *options, size_t scopes_count) PRISM_NONNULL(1);
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Return a constant pointer to the scope at the given index within the given
|
|
279
|
+
* options.
|
|
280
|
+
*
|
|
281
|
+
* @param options The options struct to get the scope from.
|
|
282
|
+
* @param index The index of the scope to get.
|
|
283
|
+
* @returns A constant pointer to the scope at the given index.
|
|
284
|
+
*/
|
|
285
|
+
PRISM_EXPORTED_FUNCTION const pm_options_scope_t * pm_options_scope(const pm_options_t *options, size_t index) PRISM_NONNULL(1);
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Return a mutable pointer to the scope at the given index within the given
|
|
289
|
+
* options.
|
|
290
|
+
*
|
|
291
|
+
* @param options The options struct to get the scope from.
|
|
292
|
+
* @param index The index of the scope to get.
|
|
293
|
+
* @returns A mutable pointer to the scope at the given index.
|
|
294
|
+
*/
|
|
295
|
+
PRISM_EXPORTED_FUNCTION pm_options_scope_t * pm_options_scope_mut(pm_options_t *options, size_t index) PRISM_NONNULL(1);
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Create a new options scope struct. This will hold a set of locals that are in
|
|
299
|
+
* scope surrounding the code that is being parsed. If the scope was unable to
|
|
300
|
+
* allocate its locals, this function will abort the process.
|
|
301
|
+
*
|
|
302
|
+
* @param scope The scope struct to initialize.
|
|
303
|
+
* @param locals_count The number of locals to allocate.
|
|
304
|
+
*/
|
|
305
|
+
PRISM_EXPORTED_FUNCTION void pm_options_scope_init(pm_options_scope_t *scope, size_t locals_count) PRISM_NONNULL(1);
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Return a constant pointer to the local at the given index within the given
|
|
309
|
+
* scope.
|
|
310
|
+
*
|
|
311
|
+
* @param scope The scope struct to get the local from.
|
|
312
|
+
* @param index The index of the local to get.
|
|
313
|
+
* @returns A constant pointer to the local at the given index.
|
|
314
|
+
*/
|
|
315
|
+
PRISM_EXPORTED_FUNCTION const pm_string_t * pm_options_scope_local(const pm_options_scope_t *scope, size_t index) PRISM_NONNULL(1);
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Return a mutable pointer to the local at the given index within the given
|
|
319
|
+
* scope.
|
|
320
|
+
*
|
|
321
|
+
* @param scope The scope struct to get the local from.
|
|
322
|
+
* @param index The index of the local to get.
|
|
323
|
+
* @returns A mutable pointer to the local at the given index.
|
|
324
|
+
*/
|
|
325
|
+
PRISM_EXPORTED_FUNCTION pm_string_t * pm_options_scope_local_mut(pm_options_scope_t *scope, size_t index) PRISM_NONNULL(1);
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Set the forwarding option on the given scope struct.
|
|
329
|
+
*
|
|
330
|
+
* @param scope The scope struct to set the forwarding on.
|
|
331
|
+
* @param forwarding The forwarding value to set.
|
|
332
|
+
*/
|
|
333
|
+
PRISM_EXPORTED_FUNCTION void pm_options_scope_forwarding_set(pm_options_scope_t *scope, uint8_t forwarding) PRISM_NONNULL(1);
|
|
334
|
+
|
|
335
|
+
#endif
|
|
@@ -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
|