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,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file prettyprint.h
|
|
3
|
+
*
|
|
4
|
+
* An AST node pretty-printer.
|
|
5
|
+
*/
|
|
6
|
+
#ifndef PRISM_PRETTYPRINT_H
|
|
7
|
+
#define PRISM_PRETTYPRINT_H
|
|
8
|
+
|
|
9
|
+
#include "prism/excludes.h"
|
|
10
|
+
|
|
11
|
+
#ifndef PRISM_EXCLUDE_PRETTYPRINT
|
|
12
|
+
|
|
13
|
+
#include "prism/compiler/exported.h"
|
|
14
|
+
#include "prism/compiler/nonnull.h"
|
|
15
|
+
|
|
16
|
+
#include "prism/ast.h"
|
|
17
|
+
#include "prism/buffer.h"
|
|
18
|
+
#include "prism/parser.h"
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Pretty-prints the AST represented by the given node to the given buffer.
|
|
22
|
+
*
|
|
23
|
+
* @param output_buffer The buffer to write the pretty-printed AST to.
|
|
24
|
+
* @param parser The parser that parsed the AST.
|
|
25
|
+
* @param node The root node of the AST to pretty-print.
|
|
26
|
+
*/
|
|
27
|
+
PRISM_EXPORTED_FUNCTION void pm_prettyprint(pm_buffer_t *output_buffer, const pm_parser_t *parser, const pm_node_t *node) PRISM_NONNULL(1, 2, 3);
|
|
28
|
+
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
#endif
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file prism.h
|
|
3
|
+
*
|
|
4
|
+
* The main header file for the prism parser.
|
|
5
|
+
*/
|
|
6
|
+
#ifndef PRISM_H
|
|
7
|
+
#define PRISM_H
|
|
8
|
+
|
|
9
|
+
#ifdef __cplusplus
|
|
10
|
+
extern "C" {
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
#include "prism/arena.h"
|
|
14
|
+
#include "prism/ast.h"
|
|
15
|
+
#include "prism/buffer.h"
|
|
16
|
+
#include "prism/diagnostic.h"
|
|
17
|
+
#include "prism/errors_format.h"
|
|
18
|
+
#include "prism/json.h"
|
|
19
|
+
#include "prism/node.h"
|
|
20
|
+
#include "prism/options.h"
|
|
21
|
+
#include "prism/parser.h"
|
|
22
|
+
#include "prism/prettyprint.h"
|
|
23
|
+
#include "prism/serialize.h"
|
|
24
|
+
#include "prism/source.h"
|
|
25
|
+
#include "prism/stream.h"
|
|
26
|
+
#include "prism/string_query.h"
|
|
27
|
+
#include "prism/version.h"
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @mainpage
|
|
31
|
+
*
|
|
32
|
+
* Prism is a parser for the Ruby programming language. It is designed to be
|
|
33
|
+
* portable, error tolerant, and maintainable. It is written in C99 and has no
|
|
34
|
+
* dependencies. It is currently being integrated into
|
|
35
|
+
* [CRuby](https://github.com/ruby/ruby),
|
|
36
|
+
* [JRuby](https://github.com/jruby/jruby),
|
|
37
|
+
* [TruffleRuby](https://github.com/truffleruby/truffleruby),
|
|
38
|
+
* [Sorbet](https://github.com/sorbet/sorbet), and
|
|
39
|
+
* [Syntax Tree](https://github.com/ruby-syntax-tree/syntax_tree).
|
|
40
|
+
*
|
|
41
|
+
* @section getting-started Getting started
|
|
42
|
+
*
|
|
43
|
+
* If you're vendoring this project and compiling it statically then as long as
|
|
44
|
+
* you have a C99 compiler you will be fine. If you're linking against it as
|
|
45
|
+
* shared library, then you should compile with `-fvisibility=hidden` and
|
|
46
|
+
* `-DPRISM_EXPORT_SYMBOLS` to tell prism to make only its public interface
|
|
47
|
+
* visible.
|
|
48
|
+
*
|
|
49
|
+
* @section parsing Parsing
|
|
50
|
+
*
|
|
51
|
+
* In order to parse Ruby code, the functions that you are going to want to use
|
|
52
|
+
* and be aware of are:
|
|
53
|
+
*
|
|
54
|
+
* * `pm_arena_new()` - create a new arena to hold all AST-lifetime allocations
|
|
55
|
+
* * `pm_parser_new()` - allocate and initialize a new parser
|
|
56
|
+
* * `pm_parse()` - parse and return the root node
|
|
57
|
+
* * `pm_parser_free()` - free the parser and its internal memory
|
|
58
|
+
* * `pm_arena_free()` - free all AST-lifetime memory
|
|
59
|
+
*
|
|
60
|
+
* Putting all of this together would look something like:
|
|
61
|
+
*
|
|
62
|
+
* ```c
|
|
63
|
+
* void parse(const uint8_t *source, size_t length) {
|
|
64
|
+
* pm_arena_t *arena = pm_arena_new();
|
|
65
|
+
* pm_parser_t *parser = pm_parser_new(arena, source, length, NULL);
|
|
66
|
+
*
|
|
67
|
+
* pm_node_t *root = pm_parse(parser);
|
|
68
|
+
* printf("PARSED!\n");
|
|
69
|
+
*
|
|
70
|
+
* pm_parser_free(parser);
|
|
71
|
+
* pm_arena_free(arena);
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* All of the nodes "inherit" from `pm_node_t` by embedding those structures
|
|
76
|
+
* as their first member. This means you can downcast and upcast any node in the
|
|
77
|
+
* tree to a `pm_node_t`.
|
|
78
|
+
*
|
|
79
|
+
* @section serializing Serializing
|
|
80
|
+
*
|
|
81
|
+
* Prism provides the ability to serialize the AST and its related metadata into
|
|
82
|
+
* a binary format. This format is designed to be portable to different
|
|
83
|
+
* languages and runtimes so that you only need to make one FFI call in order to
|
|
84
|
+
* parse Ruby code. The functions that you are going to want to use and be
|
|
85
|
+
* aware of are:
|
|
86
|
+
*
|
|
87
|
+
* * `pm_buffer_new()` - create a new buffer
|
|
88
|
+
* * `pm_buffer_free()` - free the buffer and its internal memory
|
|
89
|
+
* * `pm_serialize_parse()` - parse and serialize the AST into a buffer
|
|
90
|
+
*
|
|
91
|
+
* Putting all of this together would look something like:
|
|
92
|
+
*
|
|
93
|
+
* ```c
|
|
94
|
+
* void serialize(const uint8_t *source, size_t length) {
|
|
95
|
+
* pm_buffer_t *buffer = pm_buffer_new();
|
|
96
|
+
*
|
|
97
|
+
* pm_serialize_parse(buffer, source, length, NULL);
|
|
98
|
+
* printf("SERIALIZED!\n");
|
|
99
|
+
*
|
|
100
|
+
* pm_buffer_free(buffer);
|
|
101
|
+
* }
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @section inspecting Inspecting
|
|
105
|
+
*
|
|
106
|
+
* Prism provides the ability to inspect the AST by pretty-printing nodes. You
|
|
107
|
+
* can do this with the `pm_prettyprint()` function, which you would use like:
|
|
108
|
+
*
|
|
109
|
+
* ```c
|
|
110
|
+
* void prettyprint(const uint8_t *source, size_t length) {
|
|
111
|
+
* pm_arena_t *arena = pm_arena_new();
|
|
112
|
+
* pm_parser_t *parser = pm_parser_new(arena, source, length, NULL);
|
|
113
|
+
*
|
|
114
|
+
* pm_node_t *root = pm_parse(parser);
|
|
115
|
+
* pm_buffer_t *buffer = pm_buffer_new();
|
|
116
|
+
*
|
|
117
|
+
* pm_prettyprint(buffer, parser, root);
|
|
118
|
+
* printf("%*.s\n", (int) pm_buffer_length(buffer), pm_buffer_value(buffer));
|
|
119
|
+
*
|
|
120
|
+
* pm_buffer_free(buffer);
|
|
121
|
+
* pm_parser_free(parser);
|
|
122
|
+
* pm_arena_free(arena);
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
#ifdef __cplusplus
|
|
128
|
+
}
|
|
129
|
+
#endif
|
|
130
|
+
|
|
131
|
+
#endif
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file serialize.h
|
|
3
|
+
*
|
|
4
|
+
* The functions related to serializing the AST to a binary format.
|
|
5
|
+
*/
|
|
6
|
+
#ifndef PRISM_SERIALIZE_H
|
|
7
|
+
#define PRISM_SERIALIZE_H
|
|
8
|
+
|
|
9
|
+
#include "prism/excludes.h"
|
|
10
|
+
|
|
11
|
+
/* We optionally support serializing to a binary string. For systems that do not
|
|
12
|
+
* want or need this functionality, it can be turned off with the
|
|
13
|
+
* PRISM_EXCLUDE_SERIALIZATION define. */
|
|
14
|
+
#ifndef PRISM_EXCLUDE_SERIALIZATION
|
|
15
|
+
|
|
16
|
+
#include "prism/compiler/exported.h"
|
|
17
|
+
#include "prism/compiler/nonnull.h"
|
|
18
|
+
|
|
19
|
+
#include "prism/buffer.h"
|
|
20
|
+
#include "prism/errors_format.h"
|
|
21
|
+
#include "prism/parser.h"
|
|
22
|
+
#include "prism/source.h"
|
|
23
|
+
#include "prism/stream.h"
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Serialize the AST represented by the given node to the given buffer.
|
|
27
|
+
*
|
|
28
|
+
* @param parser The parser to serialize.
|
|
29
|
+
* @param node The node to serialize.
|
|
30
|
+
* @param buffer The buffer to serialize to.
|
|
31
|
+
*/
|
|
32
|
+
PRISM_EXPORTED_FUNCTION void pm_serialize(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) PRISM_NONNULL(1, 2, 3);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Parse the given source to the AST and dump the AST to the given buffer.
|
|
36
|
+
*
|
|
37
|
+
* @param buffer The buffer to serialize to.
|
|
38
|
+
* @param source The source to parse.
|
|
39
|
+
* @param size The size of the source.
|
|
40
|
+
* @param data The optional data to pass to the parser.
|
|
41
|
+
*/
|
|
42
|
+
PRISM_EXPORTED_FUNCTION void pm_serialize_parse(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Parse and serialize the AST represented by the given source into the given
|
|
46
|
+
* buffer.
|
|
47
|
+
*
|
|
48
|
+
* @param buffer The buffer to serialize to.
|
|
49
|
+
* @param source The source to parse.
|
|
50
|
+
* @param data The optional data to pass to the parser.
|
|
51
|
+
*/
|
|
52
|
+
PRISM_EXPORTED_FUNCTION void pm_serialize_parse_stream(pm_buffer_t *buffer, pm_source_t *source, const char *data) PRISM_NONNULL(1, 2);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Parse and serialize the comments in the given source to the given buffer.
|
|
56
|
+
*
|
|
57
|
+
* @param buffer The buffer to serialize to.
|
|
58
|
+
* @param source The source to parse.
|
|
59
|
+
* @param size The size of the source.
|
|
60
|
+
* @param data The optional data to pass to the parser.
|
|
61
|
+
*/
|
|
62
|
+
PRISM_EXPORTED_FUNCTION void pm_serialize_parse_comments(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Lex the given source and serialize to the given buffer.
|
|
66
|
+
*
|
|
67
|
+
* @param source The source to lex.
|
|
68
|
+
* @param size The size of the source.
|
|
69
|
+
* @param buffer The buffer to serialize to.
|
|
70
|
+
* @param data The optional data to pass to the lexer.
|
|
71
|
+
*/
|
|
72
|
+
PRISM_EXPORTED_FUNCTION void pm_serialize_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Parse and serialize both the AST and the tokens represented by the given
|
|
76
|
+
* source to the given buffer.
|
|
77
|
+
*
|
|
78
|
+
* @param buffer The buffer to serialize to.
|
|
79
|
+
* @param source The source to parse.
|
|
80
|
+
* @param size The size of the source.
|
|
81
|
+
* @param data The optional data to pass to the parser.
|
|
82
|
+
*/
|
|
83
|
+
PRISM_EXPORTED_FUNCTION void pm_serialize_parse_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1, 2);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Parse the source and return true if it parses without errors or warnings.
|
|
87
|
+
*
|
|
88
|
+
* @param source The source to parse.
|
|
89
|
+
* @param size The size of the source.
|
|
90
|
+
* @param data The optional data to pass to the parser.
|
|
91
|
+
* @returns True if the source parses without errors or warnings.
|
|
92
|
+
*/
|
|
93
|
+
PRISM_EXPORTED_FUNCTION bool pm_serialize_parse_success_p(const uint8_t *source, size_t size, const char *data) PRISM_NONNULL(1);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Parse the given source and format any errors that are encountered into the
|
|
97
|
+
* given buffer using the given format type. If the source parses without any
|
|
98
|
+
* errors, then -1 is returned and the buffer is left empty. Otherwise, the
|
|
99
|
+
* name of the encoding of the source is written to the buffer, followed by a
|
|
100
|
+
* null byte, followed by the formatted errors, and the error level of the
|
|
101
|
+
* error with the highest precedence is returned.
|
|
102
|
+
*
|
|
103
|
+
* @param buffer The buffer to write the encoding name and formatted errors to.
|
|
104
|
+
* @param source The source to parse.
|
|
105
|
+
* @param size The size of the source.
|
|
106
|
+
* @param data The optional data to pass to the parser.
|
|
107
|
+
* @param format_type The type of formatting to use when formatting the errors.
|
|
108
|
+
* @returns The error level of the error with the highest precedence, or -1 if
|
|
109
|
+
* the source parsed without errors.
|
|
110
|
+
*/
|
|
111
|
+
PRISM_EXPORTED_FUNCTION int8_t pm_serialize_parse_errors_format(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data, pm_errors_format_type_t format_type) PRISM_NONNULL(1, 2);
|
|
112
|
+
|
|
113
|
+
#endif
|
|
114
|
+
|
|
115
|
+
#endif
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file source.h
|
|
3
|
+
*
|
|
4
|
+
* An opaque type representing the source code being parsed, regardless of
|
|
5
|
+
* origin (constant memory, file, memory-mapped file, or stream).
|
|
6
|
+
*/
|
|
7
|
+
#ifndef PRISM_SOURCE_H
|
|
8
|
+
#define PRISM_SOURCE_H
|
|
9
|
+
|
|
10
|
+
#include "prism/compiler/exported.h"
|
|
11
|
+
#include "prism/compiler/filesystem.h"
|
|
12
|
+
#include "prism/compiler/nodiscard.h"
|
|
13
|
+
#include "prism/compiler/nonnull.h"
|
|
14
|
+
|
|
15
|
+
#include <stddef.h>
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* An opaque type representing source code being parsed.
|
|
20
|
+
*/
|
|
21
|
+
typedef struct pm_source_t pm_source_t;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This function is used to retrieve a line of input from a stream. It closely
|
|
25
|
+
* mirrors that of fgets so that fgets can be used as the default
|
|
26
|
+
* implementation.
|
|
27
|
+
*
|
|
28
|
+
* As with fgets, implementations MUST write at most `size` bytes into
|
|
29
|
+
* `string`, including the terminating NUL byte (i.e. at most `size - 1` bytes
|
|
30
|
+
* of data followed by a '\0'). The caller relies on this bound for memory
|
|
31
|
+
* safety, so an implementation that reads from a source which may return more
|
|
32
|
+
* data than requested (for example a multi-byte-aware `gets`) is responsible
|
|
33
|
+
* for clamping the amount it copies. Returns `string`, or NULL on EOF.
|
|
34
|
+
*/
|
|
35
|
+
typedef char * (pm_source_stream_fgets_t)(char *string, int size, void *stream);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* This function is used to check whether a stream is at EOF. It closely mirrors
|
|
39
|
+
* that of feof so that feof can be used as the default implementation.
|
|
40
|
+
*/
|
|
41
|
+
typedef int (pm_source_stream_feof_t)(void *stream);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Represents the result of initializing a source from a file.
|
|
45
|
+
*/
|
|
46
|
+
typedef enum {
|
|
47
|
+
/** Indicates that the source was successfully initialized. */
|
|
48
|
+
PM_SOURCE_INIT_SUCCESS = 0,
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Indicates a generic error from a source init function, where the type
|
|
52
|
+
* of error should be read from `errno` or `GetLastError()`.
|
|
53
|
+
*/
|
|
54
|
+
PM_SOURCE_INIT_ERROR_GENERIC = 1,
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Indicates that the file that was attempted to be opened was a directory.
|
|
58
|
+
*/
|
|
59
|
+
PM_SOURCE_INIT_ERROR_DIRECTORY = 2,
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Indicates that the file is not a regular file (e.g. a pipe or character
|
|
63
|
+
* device) and the caller should handle reading it.
|
|
64
|
+
*/
|
|
65
|
+
PM_SOURCE_INIT_ERROR_NON_REGULAR = 3
|
|
66
|
+
} pm_source_init_result_t;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Create a new source that wraps existing constant memory. The memory is not
|
|
70
|
+
* owned and will not be freed.
|
|
71
|
+
*
|
|
72
|
+
* @param data The pointer to the source data.
|
|
73
|
+
* @param length The length of the source data in bytes.
|
|
74
|
+
* @returns A new source. Aborts on allocation failure.
|
|
75
|
+
*/
|
|
76
|
+
PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_constant_new(const uint8_t *data, size_t length);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Create a new source that wraps existing shared memory. The memory is not
|
|
80
|
+
* owned and will not be freed. Semantically a "slice" of another source.
|
|
81
|
+
*
|
|
82
|
+
* @param data The pointer to the source data.
|
|
83
|
+
* @param length The length of the source data in bytes.
|
|
84
|
+
* @returns A new source. Aborts on allocation failure.
|
|
85
|
+
*/
|
|
86
|
+
PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_shared_new(const uint8_t *data, size_t length);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Create a new source that owns its memory. The memory will be freed with
|
|
90
|
+
* xfree when the source is freed.
|
|
91
|
+
*
|
|
92
|
+
* @param data The pointer to the heap-allocated source data.
|
|
93
|
+
* @param length The length of the source data in bytes.
|
|
94
|
+
* @returns A new source. Aborts on allocation failure.
|
|
95
|
+
*/
|
|
96
|
+
PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_owned_new(uint8_t *data, size_t length);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Create a new source by reading a file into a heap-allocated buffer.
|
|
100
|
+
*
|
|
101
|
+
* @param filepath The path to the file to read.
|
|
102
|
+
* @param result Out parameter for the result of the initialization.
|
|
103
|
+
* @returns A new source, or NULL on error (with result written to out param).
|
|
104
|
+
*/
|
|
105
|
+
PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_file_new(const char *filepath, pm_source_init_result_t *result) PRISM_NONNULL(1, 2);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Create a new source by memory-mapping a file. Falls back to file reading on
|
|
109
|
+
* platforms without mmap support.
|
|
110
|
+
*
|
|
111
|
+
* If the file is a non-regular file (e.g. a pipe or character device),
|
|
112
|
+
* PM_SOURCE_INIT_ERROR_NON_REGULAR is returned, allowing the caller to handle
|
|
113
|
+
* it appropriately (e.g. by reading it through their own I/O layer).
|
|
114
|
+
*
|
|
115
|
+
* @param filepath The path to the file to read.
|
|
116
|
+
* @param open_flags Additional flags to pass to open(2) (e.g. O_NONBLOCK).
|
|
117
|
+
* @param result Out parameter for the result of the initialization.
|
|
118
|
+
* @returns A new source, or NULL on error (with result written to out param).
|
|
119
|
+
*/
|
|
120
|
+
PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_mapped_new(const char *filepath, int open_flags, pm_source_init_result_t *result) PRISM_NONNULL(1, 3);
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Create a new source by reading from a stream using the provided callbacks.
|
|
124
|
+
*
|
|
125
|
+
* @param stream The stream to read from.
|
|
126
|
+
* @param fgets The function to use to read from the stream.
|
|
127
|
+
* @param feof The function to use to check if the stream is at EOF.
|
|
128
|
+
* @returns A new source. Aborts on allocation failure.
|
|
129
|
+
*/
|
|
130
|
+
PRISM_NODISCARD PRISM_EXPORTED_FUNCTION pm_source_t * pm_source_stream_new(void *stream, pm_source_stream_fgets_t *fgets, pm_source_stream_feof_t *feof);
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Free the given source and any memory it owns.
|
|
134
|
+
*
|
|
135
|
+
* @param source The source to free.
|
|
136
|
+
*/
|
|
137
|
+
PRISM_EXPORTED_FUNCTION void pm_source_free(pm_source_t *source) PRISM_NONNULL(1);
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Returns the length of the source data in bytes.
|
|
141
|
+
*
|
|
142
|
+
* @param source The source to get the length of.
|
|
143
|
+
* @returns The length of the source data.
|
|
144
|
+
*/
|
|
145
|
+
PRISM_EXPORTED_FUNCTION size_t pm_source_length(const pm_source_t *source) PRISM_NONNULL(1);
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Returns a pointer to the source data.
|
|
149
|
+
*
|
|
150
|
+
* @param source The source to get the data of.
|
|
151
|
+
* @returns A pointer to the source data.
|
|
152
|
+
*/
|
|
153
|
+
PRISM_EXPORTED_FUNCTION const uint8_t * pm_source_source(const pm_source_t *source) PRISM_NONNULL(1);
|
|
154
|
+
|
|
155
|
+
#endif
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file stream.h
|
|
3
|
+
*
|
|
4
|
+
* Functions for parsing streams.
|
|
5
|
+
*/
|
|
6
|
+
#ifndef PRISM_STREAM_H
|
|
7
|
+
#define PRISM_STREAM_H
|
|
8
|
+
|
|
9
|
+
#include "prism/compiler/exported.h"
|
|
10
|
+
#include "prism/compiler/nonnull.h"
|
|
11
|
+
|
|
12
|
+
#include "prism/arena.h"
|
|
13
|
+
#include "prism/options.h"
|
|
14
|
+
#include "prism/parser.h"
|
|
15
|
+
#include "prism/source.h"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Parse a stream of Ruby source and return the tree.
|
|
19
|
+
*
|
|
20
|
+
* @param parser The out parameter to write the parser to.
|
|
21
|
+
* @param arena The arena to use for all AST-lifetime allocations.
|
|
22
|
+
* @param source The source to use, created via pm_source_stream_new.
|
|
23
|
+
* @param options The optional options to use when parsing.
|
|
24
|
+
* @returns The AST representing the source.
|
|
25
|
+
*/
|
|
26
|
+
PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse_stream(pm_parser_t **parser, pm_arena_t *arena, pm_source_t *source, const pm_options_t *options) PRISM_NONNULL(1, 2, 3);
|
|
27
|
+
|
|
28
|
+
#endif
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file string_query.h
|
|
3
|
+
*
|
|
4
|
+
* Functions for querying properties of strings, such as whether they are valid
|
|
5
|
+
* local variable names, constant names, or method names.
|
|
6
|
+
*/
|
|
7
|
+
#ifndef PRISM_STRING_QUERY_H
|
|
8
|
+
#define PRISM_STRING_QUERY_H
|
|
9
|
+
|
|
10
|
+
#include "prism/compiler/exported.h"
|
|
11
|
+
#include "prism/compiler/nonnull.h"
|
|
12
|
+
|
|
13
|
+
#include <stddef.h>
|
|
14
|
+
#include <stdint.h>
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the results of a slice query.
|
|
18
|
+
*/
|
|
19
|
+
typedef enum {
|
|
20
|
+
/** Returned if the encoding given to a slice query was invalid. */
|
|
21
|
+
PM_STRING_QUERY_ERROR = -1,
|
|
22
|
+
|
|
23
|
+
/** Returned if the result of the slice query is false. */
|
|
24
|
+
PM_STRING_QUERY_FALSE,
|
|
25
|
+
|
|
26
|
+
/** Returned if the result of the slice query is true. */
|
|
27
|
+
PM_STRING_QUERY_TRUE
|
|
28
|
+
} pm_string_query_t;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Check that the slice is a valid local variable name.
|
|
32
|
+
*
|
|
33
|
+
* @param source The source to check.
|
|
34
|
+
* @param length The length of the source.
|
|
35
|
+
* @param encoding_name The name of the encoding of the source.
|
|
36
|
+
* @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if
|
|
37
|
+
* the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid.
|
|
38
|
+
*/
|
|
39
|
+
PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_local(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Check that the slice is a valid constant name.
|
|
43
|
+
*
|
|
44
|
+
* @param source The source to check.
|
|
45
|
+
* @param length The length of the source.
|
|
46
|
+
* @param encoding_name The name of the encoding of the source.
|
|
47
|
+
* @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if
|
|
48
|
+
* the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid.
|
|
49
|
+
*/
|
|
50
|
+
PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_constant(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Check that the slice is a valid method name.
|
|
54
|
+
*
|
|
55
|
+
* @param source The source to check.
|
|
56
|
+
* @param length The length of the source.
|
|
57
|
+
* @param encoding_name The name of the encoding of the source.
|
|
58
|
+
* @returns PM_STRING_QUERY_TRUE if the query is true, PM_STRING_QUERY_FALSE if
|
|
59
|
+
* the query is false, and PM_STRING_QUERY_ERROR if the encoding was invalid.
|
|
60
|
+
*/
|
|
61
|
+
PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_method_name(const uint8_t *source, size_t length, const char *encoding_name) PRISM_NONNULL(1, 3);
|
|
62
|
+
|
|
63
|
+
#endif
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file stringy.h
|
|
3
|
+
*
|
|
4
|
+
* A generic string type that can have various ownership semantics.
|
|
5
|
+
*/
|
|
6
|
+
#ifndef PRISM_STRINGY_H
|
|
7
|
+
#define PRISM_STRINGY_H
|
|
8
|
+
|
|
9
|
+
#include "prism/compiler/exported.h"
|
|
10
|
+
#include "prism/compiler/nonnull.h"
|
|
11
|
+
|
|
12
|
+
#include <stddef.h>
|
|
13
|
+
#include <stdint.h>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A generic string type that can have various ownership semantics.
|
|
17
|
+
*/
|
|
18
|
+
typedef struct {
|
|
19
|
+
/** A pointer to the start of the string. */
|
|
20
|
+
const uint8_t *source;
|
|
21
|
+
|
|
22
|
+
/** The length of the string in bytes of memory. */
|
|
23
|
+
size_t length;
|
|
24
|
+
|
|
25
|
+
/** The type of the string. This field determines how the string should be freed. */
|
|
26
|
+
enum {
|
|
27
|
+
/** This string is a constant string, and should not be freed. */
|
|
28
|
+
PM_STRING_CONSTANT,
|
|
29
|
+
|
|
30
|
+
/** This is a slice of another string, and should not be freed. */
|
|
31
|
+
PM_STRING_SHARED,
|
|
32
|
+
|
|
33
|
+
/** This string owns its memory, and should be freed internally. */
|
|
34
|
+
PM_STRING_OWNED
|
|
35
|
+
} type;
|
|
36
|
+
} pm_string_t;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Initialize a constant string that doesn't own its memory source.
|
|
40
|
+
*
|
|
41
|
+
* @param string The string to initialize.
|
|
42
|
+
* @param source The source of the string.
|
|
43
|
+
* @param length The length of the string.
|
|
44
|
+
*/
|
|
45
|
+
PRISM_EXPORTED_FUNCTION void pm_string_constant_init(pm_string_t *string, const char *source, size_t length) PRISM_NONNULL(1);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Initialize an owned string that is responsible for freeing allocated memory.
|
|
49
|
+
*
|
|
50
|
+
* @param string The string to initialize.
|
|
51
|
+
* @param source The source of the string.
|
|
52
|
+
* @param length The length of the string.
|
|
53
|
+
*/
|
|
54
|
+
PRISM_EXPORTED_FUNCTION void pm_string_owned_init(pm_string_t *string, uint8_t *source, size_t length) PRISM_NONNULL(1, 2);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Returns the length associated with the string.
|
|
58
|
+
*
|
|
59
|
+
* @param string The string to get the length of.
|
|
60
|
+
* @returns The length of the string.
|
|
61
|
+
*/
|
|
62
|
+
PRISM_EXPORTED_FUNCTION size_t pm_string_length(const pm_string_t *string) PRISM_NONNULL(1);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Returns the start pointer associated with the string.
|
|
66
|
+
*
|
|
67
|
+
* @param string The string to get the start pointer of.
|
|
68
|
+
* @returns The start pointer of the string.
|
|
69
|
+
*/
|
|
70
|
+
PRISM_EXPORTED_FUNCTION const uint8_t * pm_string_source(const pm_string_t *string) PRISM_NONNULL(1);
|
|
71
|
+
|
|
72
|
+
#endif
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
#include "prism/compiler/exported.h"
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The major version of the Prism library as an int.
|
|
13
|
+
*/
|
|
14
|
+
#define PRISM_VERSION_MAJOR 1
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The minor version of the Prism library as an int.
|
|
18
|
+
*/
|
|
19
|
+
#define PRISM_VERSION_MINOR 9
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The patch version of the Prism library as an int.
|
|
23
|
+
*/
|
|
24
|
+
#define PRISM_VERSION_PATCH 0
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The version of the Prism library as a constant string.
|
|
28
|
+
*/
|
|
29
|
+
#define PRISM_VERSION "1.9.0"
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The prism version and the serialization format.
|
|
33
|
+
*
|
|
34
|
+
* @returns The prism version as a constant string.
|
|
35
|
+
*/
|
|
36
|
+
PRISM_EXPORTED_FUNCTION const char * pm_version(void);
|
|
37
|
+
|
|
38
|
+
#endif
|