|
Ruby 4.1.0dev (2026-10-21 revision 536dc6f98b72e6999a84bb6373562c43cb1ddf8a)
|
Ownership of parsers from C++, and lookups through a parser into the source, the constant pool, comments, and diagnostics. More...
#include "prism/compiler/cplusplus.hpp"#include "prism/compiler/lifetimebound.hpp"#include "prism/arena.h"#include "prism/constant_pool.h"#include "prism/line_offset_list.h"#include "prism/parser.h"#include <cassert>#include <cstddef>#include <cstdint>#include <iterator>#include <memory>#include <string_view>
Go to the source code of this file.
Data Structures | |
| struct | prism::parser_deleter |
| Frees a parser with pm_parser_free. More... | |
| class | prism::detail::next_range< T, Next > |
| The diagnostics, comments, or magic comments found while parsing, usable in a range-based for loop and with the standard algorithms. More... | |
| class | prism::detail::next_range< T, Next >::iterator |
| Steps through the items one after another. More... | |
Typedefs | |
| using | prism::unique_parser = std::unique_ptr< pm_parser_t, parser_deleter > |
| An owned parser. | |
| using | prism::diagnostic_range = detail::next_range< pm_diagnostic_t, pm_diagnostic_next > |
| The errors or warnings found while parsing. | |
| using | prism::comment_range = detail::next_range< pm_comment_t, pm_comment_next > |
| The comments found while parsing. | |
| using | prism::magic_comment_range = detail::next_range< pm_magic_comment_t, pm_magic_comment_next > |
| The magic comments found while parsing. | |
Functions | |
| unique_parser | prism::make_parser (pm_arena_t *arena PRISM_LIFETIMEBOUND, std::string_view source PRISM_LIFETIMEBOUND, const pm_options_t *options PRISM_LIFETIMEBOUND=nullptr) noexcept |
| Allocate a new parser over the given source. | |
| std::string_view | prism::constant (const pm_parser_t *parser PRISM_LIFETIMEBOUND, pm_constant_id_t constant_id) noexcept |
| The name of the constant with the given id, which must not be zero. | |
| std::string_view | prism::slice (const pm_parser_t *parser PRISM_LIFETIMEBOUND, pm_location_t location) noexcept |
| The bytes of source that the given location covers. | |
| pm_line_column_t | prism::line_column (const pm_parser_t *parser, std::uint32_t offset) noexcept |
| The line and column of the given byte offset into the source. | |
| diagnostic_range | prism::errors (const pm_parser_t *parser PRISM_LIFETIMEBOUND) noexcept |
| The errors found while parsing. | |
| diagnostic_range | prism::warnings (const pm_parser_t *parser PRISM_LIFETIMEBOUND) noexcept |
| The warnings found while parsing. | |
| comment_range | prism::comments (const pm_parser_t *parser PRISM_LIFETIMEBOUND) noexcept |
| The comments found while parsing, in source order. | |
| magic_comment_range | prism::magic_comments (const pm_parser_t *parser PRISM_LIFETIMEBOUND) noexcept |
| The magic comments found while parsing. | |
Ownership of parsers from C++, and lookups through a parser into the source, the constant pool, comments, and diagnostics.
Definition in file parser.hpp.
| using prism::comment_range = typedef detail::next_range<pm_comment_t, pm_comment_next> |
The comments found while parsing.
Definition at line 223 of file parser.hpp.
| using prism::diagnostic_range = typedef detail::next_range<pm_diagnostic_t, pm_diagnostic_next> |
The errors or warnings found while parsing.
Definition at line 220 of file parser.hpp.
| using prism::magic_comment_range = typedef detail::next_range<pm_magic_comment_t, pm_magic_comment_next> |
The magic comments found while parsing.
Definition at line 226 of file parser.hpp.
| using prism::unique_parser = typedef std::unique_ptr<pm_parser_t, parser_deleter> |
An owned parser.
Definition at line 38 of file parser.hpp.
|
inlinenoexcept |
The comments found while parsing, in source order.
| parser | The parser containing the source. |
Definition at line 257 of file parser.hpp.
Referenced by prism::comments().
|
inlinenoexcept |
The name of the constant with the given id, which must not be zero.
Fields holding an optional constant use zero for none, so check those first.
| parser | The parser containing the constant. |
| constant_id | The id of the constant. |
Definition at line 64 of file parser.hpp.
Referenced by prism::constant().
|
inlinenoexcept |
The errors found while parsing.
| parser | The parser containing the source. |
Definition at line 235 of file parser.hpp.
Referenced by prism::errors().
|
inlinenoexcept |
The line and column of the given byte offset into the source.
Lines start at the parser's start line, and columns are byte offsets from the line start.
| parser | The parser containing the source. |
| offset | The byte offset into the source. |
Definition at line 91 of file parser.hpp.
Referenced by prism::line_column().
|
inlinenoexcept |
The magic comments found while parsing.
| parser | The parser containing the source. |
Definition at line 268 of file parser.hpp.
Referenced by prism::magic_comments().
|
inlinenoexcept |
Allocate a new parser over the given source.
The source, the arena, and the options (which may be null) are not copied, so all three must outlive the parser. Allocation failure aborts, so this never throws.
| arena | The arena to use for allocations. |
| source | The source code to parse. |
| options | The parse options, or null for defaults. |
Definition at line 51 of file parser.hpp.
Referenced by prism::make_parser().
|
inlinenoexcept |
The bytes of source that the given location covers.
| parser | The parser containing the source. |
| location | The location in the source. |
Definition at line 78 of file parser.hpp.
Referenced by prism::slice().
|
inlinenoexcept |
The warnings found while parsing.
| parser | The parser containing the source. |
Definition at line 246 of file parser.hpp.
Referenced by prism::warnings().