|
Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
|
#include "serene/ir/reader.h"#include <stdio.h>#include <string.h>#include "serene/rt/context.h"#include "serene/rt/core.h"#include "serene/rt/engine.h"#include "serene/rt/errors.h"#include "serene/rt/fiber.h"#include "serene/rt/impl/array_list.h"#include "serene/rt/mm/interface.h"#include "serene/utils.h"#include "serene/vendor/utf8.h"Go to the source code of this file.
Macros | |
| #define | UNEXPECTED_CHAR_MSG_LEN 48 |
| #define | CHAR_BUFF_SIZE 5 |
| #define | C_LAMBDA 0x03BB |
| #define | DEBUG_BUF_MAX_SIZE 4096 |
| #define | METADATA_STR_DEBUG_SIZE 48 |
Functions | |
| static bool | is_atom_char (utf8_int32_t c) |
| static utf8_int32_t | peek (srn_sexp_parser_t *p) |
| static utf8_int32_t | advance (srn_sexp_parser_t *p) |
| static utf8_int32_t | peek_next (srn_sexp_parser_t *p) |
| The codepoint one past the current one, without moving p. | |
| static bool | is_whitespace (utf8_int32_t c) |
| static bool | is_digit (utf8_int32_t c) |
| static bool | is_at_end (srn_sexp_parser_t *p) |
| static void | read_comment (srn_sexp_parser_t *p) |
| static void | skip_whitespace (srn_sexp_parser_t *p) |
| static bool | is_atom_start (utf8_int32_t c) |
| static bool | is_number_start (utf8_int32_t c, utf8_int32_t next) |
| static srn_error_t * | parse_error (srn_sexp_parser_t *parser, const utf8_int32_t c, const char *msg) |
| srn_sexp_node_t * | srn_sexp_make_atom (srn_context_t *ctx, const char *name) |
| srn_sexp_node_t * | srn_sexp_make_str (srn_context_t *ctx, const char *data) |
| srn_sexp_node_t * | srn_sexp_make_num (srn_context_t *ctx, const char *text) |
| srn_sexp_node_t * | srn_sexp_make_cons (srn_context_t *ctx, srn_sexp_node_t *head, srn_sexp_node_t *tail) |
| srn_sexp_node_t * | srn_sexp_make_list (srn_context_t *ctx) |
| srn_sexp_node_t * | srn_sexp_make_node (srn_context_t *ctx, srn_sexp_node_type_e type) |
| static srn_sexp_node_t * | read_list (srn_sexp_parser_t *parser, srn_error_t **err) |
| static srn_sexp_node_t * | read_seq (srn_sexp_parser_t *parser, srn_error_t **err) |
| static srn_sexp_node_t * | read_atom (srn_sexp_parser_t *parser, srn_error_t **err) |
| static srn_sexp_node_t * | read_number (srn_sexp_parser_t *parser, srn_error_t **err) |
| A number literal: an optional leading sign, digits, an optional '. | |
| static srn_sexp_node_t * | read_string (srn_sexp_parser_t *parser, srn_error_t **err) |
| srn_sexp_node_t * | read_expr (srn_sexp_parser_t *parser, srn_error_t **err) |
| srn_fiber_result_t | read_from_buffer (srn_context_t *ctx, void *arg) |
| srn_sexp_tree_t * | srn_sexp_read_from_string (srn_context_t *ctx, void *reading_context, const char *buf) |
| Read the symbolic expressions from a buffer. | |
| srn_sexp_tree_t * | srn_sexp_read_from_file (srn_context_t *ctx, void *reading_context, const char *path) |
| Read the symbolic expressions from a file. | |
| static const char * | node_type_debug_name (srn_sexp_node_type_e type) |
| static srn_error_t * | debug_buf_append (const srn_context_t *ctx, char *out, const char *fragment) |
| Append fragment to the end of the out debug buffer (a DEBUG_BUF_MAX_SIZE buffer, treated as a growing C string). | |
| static srn_error_t * | debug_buf_append_location (const srn_context_t *ctx, char *out, const srn_metadata_t *metadata) |
| static srn_error_t * | node_to_debug_strig (const srn_context_t *ctx, srn_sexp_node_t *node, char *out) |
| static srn_error_t * | sexp_tree_reducer (array_list_t *exprs_array, size_t n, void *expr, void *state) |
| const char * | srn_sexp_to_debug_string (srn_context_t *ctx, srn_sexp_tree_t *tree) |
| Convert the given sexp to a string for debugging purposes. | |
|
inlinestatic |
|
static |
Append fragment to the end of the out debug buffer (a DEBUG_BUF_MAX_SIZE buffer, treated as a growing C string).
Returns an error instead of overflowing the buffer.
Definition at line 718 of file reader.c.
|
static |
Definition at line 733 of file reader.c.
|
inlinestatic |
|
inlinestatic |
Definition at line 115 of file reader.c.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |
Definition at line 749 of file reader.c.
|
inlinestatic |
|
inlinestatic |
Definition at line 135 of file reader.c.
|
inlinestatic |
|
inlinestatic |
The codepoint one past the current one, without moving p.
peek only ever reads at p->pos itself, so this is what tells a signed number ('-5') from a bare symbol ('-'): decode the current codepoint just to find where it ends, then decode the one after it.
Definition at line 65 of file reader.c.
|
static |
Definition at line 361 of file reader.c.
|
inlinestatic |
| srn_sexp_node_t * read_expr | ( | srn_sexp_parser_t * | parser, |
| srn_error_t ** | err ) |
Definition at line 552 of file reader.c.
| srn_fiber_result_t read_from_buffer | ( | srn_context_t * | ctx, |
| void * | arg ) |
Definition at line 584 of file reader.c.
|
static |
Definition at line 250 of file reader.c.
|
static |
A number literal: an optional leading sign, digits, an optional '.
'-separated fractional part, and an optional 'e'/'E' exponent. Kept as the raw source text (see srn_sexp_num_t), the reader only recognises the shape.
Definition at line 399 of file reader.c.
|
static |
Definition at line 306 of file reader.c.
|
static |
Definition at line 466 of file reader.c.
|
static |
Definition at line 853 of file reader.c.
|
inlinestatic |
Definition at line 97 of file reader.c.
| srn_sexp_node_t * srn_sexp_make_atom | ( | srn_context_t * | ctx, |
| const char * | name ) |
Definition at line 176 of file reader.c.
| srn_sexp_node_t * srn_sexp_make_cons | ( | srn_context_t * | ctx, |
| srn_sexp_node_t * | head, | ||
| srn_sexp_node_t * | tail ) |
Definition at line 211 of file reader.c.
| srn_sexp_node_t * srn_sexp_make_list | ( | srn_context_t * | ctx | ) |
Definition at line 224 of file reader.c.
| srn_sexp_node_t * srn_sexp_make_node | ( | srn_context_t * | ctx, |
| srn_sexp_node_type_e | type ) |
| srn_sexp_node_t * srn_sexp_make_num | ( | srn_context_t * | ctx, |
| const char * | text ) |
Definition at line 198 of file reader.c.
| srn_sexp_node_t * srn_sexp_make_str | ( | srn_context_t * | ctx, |
| const char * | data ) |
Definition at line 187 of file reader.c.
| srn_sexp_tree_t * srn_sexp_read_from_file | ( | srn_context_t * | ctx, |
| void * | reading_context, | ||
| const char * | path ) |
Read the symbolic expressions from a file.
reading_context is a piece of data that the reader might provide as an identity or a piece of data that gives meaning to the result. For example a namespace key.
Definition at line 643 of file reader.c.
| srn_sexp_tree_t * srn_sexp_read_from_string | ( | srn_context_t * | ctx, |
| void * | reading_context, | ||
| const char * | buf ) |
Read the symbolic expressions from a buffer.
reading_context is a piece of data that the reader might provide as an identity or a piece of data that gives meaning to the result. For example a namespace key.
Definition at line 636 of file reader.c.
| const char * srn_sexp_to_debug_string | ( | srn_context_t * | ctx, |
| srn_sexp_tree_t * | tree ) |
Convert the given sexp to a string for debugging purposes.
The string will contain metadata info as well.
Definition at line 860 of file reader.c.