| Ruby 3.5.0dev (2025-10-31 revision 6707945f0c065d47a4a9e8fd1627345bfcb85c10)
    | 
The main header file for the prism parser. More...
#include "prism/defines.h"#include "prism/util/pm_buffer.h"#include "prism/util/pm_char.h"#include "prism/util/pm_integer.h"#include "prism/util/pm_memchr.h"#include "prism/util/pm_strncasecmp.h"#include "prism/util/pm_strpbrk.h"#include "prism/ast.h"#include "prism/diagnostic.h"#include "prism/node.h"#include "prism/options.h"#include "prism/pack.h"#include "prism/parser.h"#include "prism/prettyprint.h"#include "prism/regexp.h"#include "prism/static_literals.h"#include "prism/version.h"#include <assert.h>#include <errno.h>#include <locale.h>#include <math.h>#include <stdarg.h>#include <stdbool.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <strings.h>

Go to the source code of this file.
| Typedefs | |
| typedef char *() | pm_parse_stream_fgets_t(char *string, int size, void *stream) | 
| This function is used in pm_parse_stream() to retrieve a line of input from a stream. | |
| typedef int() | pm_parse_stream_feof_t(void *stream) | 
| This function is used in pm_parse_stream to check whether a stream is EOF. | |
| Enumerations | |
| enum | pm_string_query_t { PM_STRING_QUERY_ERROR = -1 , PM_STRING_QUERY_FALSE , PM_STRING_QUERY_TRUE } | 
| Represents the results of a slice query.  More... | |
| Functions | |
| PRISM_EXPORTED_FUNCTION const char * | pm_version (void) | 
| The prism version and the serialization format. | |
| PRISM_EXPORTED_FUNCTION void | pm_serialize_parse_stream (pm_buffer_t *buffer, void *stream, pm_parse_stream_fgets_t *stream_fgets, pm_parse_stream_feof_t *stream_feof, const char *data) | 
| Parse and serialize the AST represented by the source that is read out of the given stream into to the given buffer. | |
| 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. | |
| void | pm_serialize_encoding (const pm_encoding_t *encoding, pm_buffer_t *buffer) | 
| Serialize the name of the encoding to the buffer. | |
| void | pm_serialize_content (pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) | 
| Serialize the encoding, metadata, nodes, and constant pool. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| PRISM_EXPORTED_FUNCTION const char * | pm_token_type_name (pm_token_type_t token_type) | 
| Returns a string representation of the given token type. | |
| const char * | pm_token_type_human (pm_token_type_t token_type) | 
| Returns the human name of the given token type. | |
| PRISM_EXPORTED_FUNCTION void | pm_dump_json (pm_buffer_t *buffer, const pm_parser_t *parser, const pm_node_t *node) | 
| Dump JSON to the given buffer. | |
| PRISM_EXPORTED_FUNCTION pm_string_query_t | pm_string_query_local (const uint8_t *source, size_t length, const char *encoding_name) | 
| Check that the slice is a valid local variable name. | |
| PRISM_EXPORTED_FUNCTION pm_string_query_t | pm_string_query_constant (const uint8_t *source, size_t length, const char *encoding_name) | 
| Check that the slice is a valid constant name. | |
| PRISM_EXPORTED_FUNCTION pm_string_query_t | pm_string_query_method_name (const uint8_t *source, size_t length, const char *encoding_name) | 
| Check that the slice is a valid method name. | |
The main header file for the prism parser.
Definition in file prism.h.
| typedef int() pm_parse_stream_feof_t(void *stream) | 
| typedef char *() pm_parse_stream_fgets_t(char *string, int size, void *stream) | 
This function is used in pm_parse_stream() to retrieve a line of input from a stream.
It closely mirrors that of fgets so that fgets can be used as the default implementation.
| enum pm_string_query_t | 
| PRISM_EXPORTED_FUNCTION void pm_dump_json | ( | pm_buffer_t * | buffer, | 
| const pm_parser_t * | parser, | ||
| const pm_node_t * | node | ||
| ) | 
| PRISM_EXPORTED_FUNCTION bool pm_parse_success_p | ( | const uint8_t * | source, | 
| size_t | size, | ||
| const char * | data | ||
| ) | 
| PRISM_EXPORTED_FUNCTION void pm_serialize | ( | pm_parser_t * | parser, | 
| pm_node_t * | node, | ||
| pm_buffer_t * | buffer | ||
| ) | 
| 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.
| parser | The parser to serialize. | 
| list | The list of comments to serialize. | 
| buffer | The buffer to serialize to. | 
Definition at line 2054 of file serialize.c.
Referenced by pm_serialize_comment_list(), and pm_serialize_parse_comments().
| void pm_serialize_content | ( | pm_parser_t * | parser, | 
| pm_node_t * | node, | ||
| pm_buffer_t * | buffer | ||
| ) | 
Serialize the encoding, metadata, nodes, and constant pool.
| parser | The parser to serialize. | 
| node | The node to serialize. | 
| buffer | The buffer to serialize to. | 
Serialize the encoding, metadata, nodes, and constant pool.
Definition at line 2147 of file serialize.c.
Referenced by pm_serialize(), pm_serialize_content(), pm_serialize_parse(), and pm_serialize_parse_stream().
| void pm_serialize_encoding | ( | const pm_encoding_t * | encoding, | 
| pm_buffer_t * | buffer | ||
| ) | 
Serialize the name of the encoding to the buffer.
| encoding | The encoding to serialize. | 
| buffer | The buffer to serialize to. | 
Definition at line 2124 of file serialize.c.
Referenced by pm_serialize_encoding(), and pm_serialize_parse_comments().
| 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.
| source | The source to lex. | 
| size | The size of the source. | 
| buffer | The buffer to serialize to. | 
| data | The optional data to pass to the lexer. | 
Definition at line 2221 of file serialize.c.
Referenced by pm_serialize_lex().
| 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.
| buffer | The buffer to serialize to. | 
| source | The source to parse. | 
| size | The size of the source. | 
| data | The optional data to pass to the parser. | 
Parse the given source to the AST and dump the AST to the given buffer.
| PRISM_EXPORTED_FUNCTION void pm_serialize_parse_comments | ( | pm_buffer_t * | buffer, | 
| const uint8_t * | source, | ||
| size_t | size, | ||
| const char * | data | ||
| ) | 
| 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.
| buffer | The buffer to serialize to. | 
| source | The source to parse. | 
| size | The size of the source. | 
| data | The optional data to pass to the parser. | 
Definition at line 2251 of file serialize.c.
Referenced by pm_serialize_parse_lex().
| PRISM_EXPORTED_FUNCTION void pm_serialize_parse_stream | ( | pm_buffer_t * | buffer, | 
| void * | stream, | ||
| pm_parse_stream_fgets_t * | stream_fgets, | ||
| pm_parse_stream_feof_t * | stream_feof, | ||
| const char * | data | ||
| ) | 
Parse and serialize the AST represented by the source that is read out of the given stream into to the given buffer.
| buffer | The buffer to serialize to. | 
| stream | The stream to parse. | 
| stream_fgets | The function to use to read from the stream. | 
| stream_feof | The function to use to tell if the stream has hit eof. | 
| data | The optional data to pass to the parser. | 
| PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_constant | ( | const uint8_t * | source, | 
| size_t | length, | ||
| const char * | encoding_name | ||
| ) | 
Check that the slice is a valid constant name.
| source | The source to check. | 
| length | The length of the source. | 
| encoding_name | The name of the encoding of the source. | 
| PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_local | ( | const uint8_t * | source, | 
| size_t | length, | ||
| const char * | encoding_name | ||
| ) | 
Check that the slice is a valid local variable name.
| source | The source to check. | 
| length | The length of the source. | 
| encoding_name | The name of the encoding of the source. | 
| PRISM_EXPORTED_FUNCTION pm_string_query_t pm_string_query_method_name | ( | const uint8_t * | source, | 
| size_t | length, | ||
| const char * | encoding_name | ||
| ) | 
Check that the slice is a valid method name.
| source | The source to check. | 
| length | The length of the source. | 
| encoding_name | The name of the encoding of the source. | 
| const char * pm_token_type_human | ( | pm_token_type_t | token_type | ) | 
Returns the human name of the given token type.
| token_type | The token type to convert to a human name. | 
Definition at line 364 of file token_type.c.
Referenced by pm_token_type_human().
| PRISM_EXPORTED_FUNCTION const char * pm_token_type_name | ( | pm_token_type_t | token_type | ) | 
Returns a string representation of the given token type.
| token_type | The token type to convert to a string. | 
Definition at line 19 of file token_type.c.
Referenced by pm_token_type_name().
| PRISM_EXPORTED_FUNCTION const char * pm_version | ( | void | ) |