Ruby: prism/prism.h Source File

Ruby 3.3.6p108 (2024-11-05 revision 75015d4c1f6965b5e85e96fb309f1f2129f933c0)

prism.h
Go to the documentation of this file.
1
6#ifndef PRISM_H
7#define PRISM_H
8
9#include "prism/defines.h"
10#include "prism/util/pm_buffer.h"
11#include "prism/util/pm_char.h"
12#include "prism/util/pm_memchr.h"
13#include "prism/util/pm_strncasecmp.h"
14#include "prism/util/pm_strpbrk.h"
15#include "prism/ast.h"
16#include "prism/diagnostic.h"
17#include "prism/node.h"
18#include "prism/options.h"
19#include "prism/pack.h"
20#include "prism/parser.h"
21#include "prism/prettyprint.h"
22#include "prism/regexp.h"
23#include "prism/version.h"
24
25#include <assert.h>
26#include <errno.h>
27#include <stdarg.h>
28#include <stdbool.h>
29#include <stdint.h>
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33
34#ifndef _WIN32
35#include <strings.h>
36#endif
37
43 PRISM_EXPORTED_FUNCTION const char * pm_version(void);
44
53 PRISM_EXPORTED_FUNCTION void pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm_options_t *options);
54
62 PRISM_EXPORTED_FUNCTION void pm_parser_register_encoding_changed_callback(pm_parser_t *parser, pm_encoding_changed_callback_t callback);
63
69 PRISM_EXPORTED_FUNCTION void pm_parser_free(pm_parser_t *parser);
70
77 PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse(pm_parser_t *parser);
78
86void pm_serialize_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buffer);
87
94void pm_serialize_encoding(const pm_encoding_t *encoding, pm_buffer_t *buffer);
95
103void pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer);
104
112 PRISM_EXPORTED_FUNCTION void pm_serialize(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer);
113
122 PRISM_EXPORTED_FUNCTION void pm_serialize_parse(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data);
123
132 PRISM_EXPORTED_FUNCTION void pm_serialize_parse_comments(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data);
133
142 PRISM_EXPORTED_FUNCTION void pm_serialize_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data);
143
153 PRISM_EXPORTED_FUNCTION void pm_serialize_parse_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data);
154
163 PRISM_EXPORTED_FUNCTION bool pm_parse_success_p(const uint8_t *source, size_t size, const char *data);
164
171 PRISM_EXPORTED_FUNCTION const char * pm_token_type_to_str(pm_token_type_t token_type);
172
272#endif
assert.h
ast.h
The abstract syntax tree.
pm_token_type_t
enum pm_token_type pm_token_type_t
This enum represents every type of token in the Ruby source.
diagnostic.h
A list of diagnostics generated during parsing.
options.h
The options that can be passed to parsing.
pack.h
A pack template string parser.
parser.h
The parser used to parse Ruby source.
pm_encoding_changed_callback_t
void(* pm_encoding_changed_callback_t)(pm_parser_t *parser)
When the encoding that is being used to parse the source is changed by prism, we provide the ability ...
Definition parser.h:425
pm_buffer.h
A wrapper around a contiguous block of allocated memory.
pm_char.h
Functions for working with characters and strings.
pm_memchr.h
A custom memchr implementation.
pm_strncasecmp.h
A custom strncasecmp implementation.
pm_strpbrk.h
A custom strpbrk implementation.
prettyprint.h
An AST node pretty-printer.
defines.h
Macro definitions used throughout the prism library.
PRISM_EXPORTED_FUNCTION
#define PRISM_EXPORTED_FUNCTION
By default, we compile with -fvisibility=hidden.
Definition defines.h:32
node.h
Functions related to nodes in the AST.
version.h
The version of the Prism library.
pm_parse
PRISM_EXPORTED_FUNCTION pm_node_t * pm_parse(pm_parser_t *parser)
Initiate the parser with the given parser.
Definition prism.c:17411
pm_parser_register_encoding_changed_callback
PRISM_EXPORTED_FUNCTION void pm_parser_register_encoding_changed_callback(pm_parser_t *parser, pm_encoding_changed_callback_t callback)
Register a callback that will be called whenever prism changes the encoding it is using to parse base...
Definition prism.c:17346
pm_serialize_lex
PRISM_EXPORTED_FUNCTION void pm_serialize_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data)
Lex the given source and serialize to the given buffer.
Definition serialize.c:2014
pm_parser_free
PRISM_EXPORTED_FUNCTION void pm_parser_free(pm_parser_t *parser)
Free any memory associated with the given parser.
Definition prism.c:17384
pm_serialize_content
void pm_serialize_content(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer)
Serialize the encoding, metadata, nodes, and constant pool.
Definition serialize.c:1934
pm_serialize_parse_lex
PRISM_EXPORTED_FUNCTION void pm_serialize_parse_lex(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data)
Parse and serialize both the AST and the tokens represented by the given source to the given buffer.
Definition serialize.c:2050
pm_serialize
PRISM_EXPORTED_FUNCTION void pm_serialize(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer)
Serialize the AST represented by the given node to the given buffer.
Definition prism.c:17428
pm_serialize_parse_comments
PRISM_EXPORTED_FUNCTION void pm_serialize_parse_comments(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data)
Parse and serialize the comments in the given source to the given buffer.
Definition prism.c:17461
pm_serialize_parse
PRISM_EXPORTED_FUNCTION void pm_serialize_parse(pm_buffer_t *buffer, const uint8_t *source, size_t size, const char *data)
Parse the given source to the AST and dump the AST to the given buffer.
Definition prism.c:17439
pm_serialize_encoding
void pm_serialize_encoding(const pm_encoding_t *encoding, pm_buffer_t *buffer)
Serialize the name of the encoding to the buffer.
Definition serialize.c:1923
pm_token_type_to_str
PRISM_EXPORTED_FUNCTION const char * pm_token_type_to_str(pm_token_type_t token_type)
Returns a string representation of the given token type.
Definition token_type.c:16
pm_parser_init
PRISM_EXPORTED_FUNCTION void pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm_options_t *options)
Initialize a parser with the given start and end pointers.
Definition prism.c:17206
pm_parse_success_p
PRISM_EXPORTED_FUNCTION bool pm_parse_success_p(const uint8_t *source, size_t size, const char *data)
Parse the source and return true if it parses without errors or warnings.
Definition serialize.c:2077
pm_serialize_comment_list
void pm_serialize_comment_list(pm_parser_t *parser, pm_list_t *list, pm_buffer_t *buffer)
Serialize the given list of comments to the given buffer.
Definition serialize.c:1858
pm_version
PRISM_EXPORTED_FUNCTION const char * pm_version(void)
The prism version and the serialization format.
Definition prism.c:7
regexp.h
A regular expression parser.
stdarg.h
Defines old _.
stdbool.h
C99 shim for <stdbool.h>
pm_buffer_t
A pm_buffer_t is a simple memory buffer that stores data in a contiguous block of memory.
Definition pm_buffer.h:21
pm_encoding_t
This struct defines the functions necessary to implement the encoding interface so we can determine h...
Definition encoding.h:23
pm_list_t
This represents the overall linked list.
Definition pm_list.h:55
pm_node
This is the base structure that represents a node in the syntax tree.
Definition ast.h:1061
pm_options_t
The options that can be passed to the parser.
Definition options.h:30
pm_parser
This struct represents the overall parser.
Definition parser.h:489