|
Prism Ruby parser
|
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, std::string_view source, const pm_options_t *options=nullptr) noexcept |
| Allocate a new parser over the given source. | |
| std::string_view | prism::constant (const pm_parser_t *parser, 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, 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) noexcept |
| The errors found while parsing. | |
| diagnostic_range | prism::warnings (const pm_parser_t *parser) noexcept |
| The warnings found while parsing. | |
| comment_range | prism::comments (const pm_parser_t *parser) noexcept |
| The comments found while parsing, in source order. | |
| magic_comment_range | prism::magic_comments (const pm_parser_t *parser) 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.
|
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. |
|
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. |
|
inlinenoexcept |
The bytes of source that the given location covers.
| parser | The parser containing the source. |
| location | The location in the source. |
|
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. |
|
inlinenoexcept |
The errors found while parsing.
| parser | The parser containing the source. |
|
inlinenoexcept |
The warnings found while parsing.
| parser | The parser containing the source. |
|
inlinenoexcept |
The comments found while parsing, in source order.
| parser | The parser containing the source. |
|
inlinenoexcept |
The magic comments found while parsing.
| parser | The parser containing the source. |