|
Prism Ruby parser
|
The options that can be passed to parsing. More...
#include "prism/compiler/exported.h"#include "prism/compiler/nodiscard.h"#include "prism/compiler/nonnull.h"#include "prism/stringy.h"#include <stdbool.h>#include <stddef.h>

Go to the source code of this file.
Typedefs | |
| typedef struct pm_options_scope_t | pm_options_scope_t |
| A scope of locals surrounding the code that is being parsed. | |
| typedef struct pm_options_t | pm_options_t |
| The options that can be passed to the parser. | |
| typedef void(* | pm_options_shebang_callback_t) (pm_options_t *options, const uint8_t *source, size_t length, void *shebang_callback_data) |
| The callback called when additional switches are found in a shebang comment that need to be processed by the runtime. | |
Functions | |
| PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_options_t * | pm_options_new (void) |
| Allocate a new options struct. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_free (pm_options_t *options) PRISM_NONNULL(1) |
| Free both the held memory of the given options struct and the struct itself. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_shebang_callback_set (pm_options_t *options, pm_options_shebang_callback_t shebang_callback, void *shebang_callback_data) PRISM_NONNULL(1) |
| Set the shebang callback option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION const pm_string_t * | pm_options_filepath (const pm_options_t *options) PRISM_NONNULL(1) |
| Get the filepath option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_filepath_set (pm_options_t *options, const char *filepath) PRISM_NONNULL(1) |
| Set the filepath option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_line_set (pm_options_t *options, int32_t line) PRISM_NONNULL(1) |
| Set the line option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_encoding_set (pm_options_t *options, const char *encoding) PRISM_NONNULL(1) |
| Set the encoding option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_encoding_locked_set (pm_options_t *options, bool encoding_locked) PRISM_NONNULL(1) |
| Set the encoding_locked option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_frozen_string_literal_set (pm_options_t *options, bool frozen_string_literal) PRISM_NONNULL(1) |
| Set the frozen string literal option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_command_line_set (pm_options_t *options, uint8_t command_line) PRISM_NONNULL(1) |
| Sets the command line option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION bool | pm_options_version_set (pm_options_t *options, const char *version, size_t length) PRISM_NONNULL(1) |
| Set the version option on the given options struct by parsing the given string. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_version_set_lowest (pm_options_t *options) PRISM_NONNULL(1) |
| Set the version option on the given options struct to the lowest version of Ruby that prism supports. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_version_set_highest (pm_options_t *options) PRISM_NONNULL(1) |
| Set the version option on the given options struct to the highest version of Ruby that prism supports. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_main_script_set (pm_options_t *options, bool main_script) PRISM_NONNULL(1) |
| Set the main script option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_partial_script_set (pm_options_t *options, bool partial_script) PRISM_NONNULL(1) |
| Set the partial script option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION bool | pm_options_freeze (const pm_options_t *options) PRISM_NONNULL(1) |
| Get the freeze option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_freeze_set (pm_options_t *options, bool freeze) PRISM_NONNULL(1) |
| Set the freeze option on the given options struct. | |
| PRISM_EXPORTED_FUNCTION bool | pm_options_scopes_init (pm_options_t *options, size_t scopes_count) PRISM_NONNULL(1) |
| Allocate and zero out the scopes array on the given options struct. | |
| PRISM_EXPORTED_FUNCTION const pm_options_scope_t * | pm_options_scope (const pm_options_t *options, size_t index) PRISM_NONNULL(1) |
| Return a constant pointer to the scope at the given index within the given options. | |
| PRISM_EXPORTED_FUNCTION pm_options_scope_t * | pm_options_scope_mut (pm_options_t *options, size_t index) PRISM_NONNULL(1) |
| Return a mutable pointer to the scope at the given index within the given options. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_scope_init (pm_options_scope_t *scope, size_t locals_count) PRISM_NONNULL(1) |
| Create a new options scope struct. | |
| PRISM_EXPORTED_FUNCTION const pm_string_t * | pm_options_scope_local (const pm_options_scope_t *scope, size_t index) PRISM_NONNULL(1) |
| Return a constant pointer to the local at the given index within the given scope. | |
| PRISM_EXPORTED_FUNCTION pm_string_t * | pm_options_scope_local_mut (pm_options_scope_t *scope, size_t index) PRISM_NONNULL(1) |
| Return a mutable pointer to the local at the given index within the given scope. | |
| PRISM_EXPORTED_FUNCTION void | pm_options_scope_forwarding_set (pm_options_scope_t *scope, uint8_t forwarding) PRISM_NONNULL(1) |
| Set the forwarding option on the given scope struct. | |
The options that can be passed to parsing.
| typedef void(* pm_options_shebang_callback_t) (pm_options_t *options, const uint8_t *source, size_t length, void *shebang_callback_data) |
The callback called when additional switches are found in a shebang comment that need to be processed by the runtime.
| options | The options struct that may be updated by this callback. Certain fields will be checked for changes, specifically encoding, command_line, and frozen_string_literal. |
| source | The source of the shebang comment. |
| length | The length of the source. |
| shebang_callback_data | Any additional data that should be passed along to the callback. |
| PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_options_t * pm_options_new | ( | void | ) |
Allocate a new options struct.
If the options struct cannot be allocated, this function aborts the process.
| PRISM_EXPORTED_FUNCTION void pm_options_free | ( | pm_options_t * | options | ) |
Free both the held memory of the given options struct and the struct itself.
| options | The options struct to free. |
| PRISM_EXPORTED_FUNCTION void pm_options_shebang_callback_set | ( | pm_options_t * | options, |
| pm_options_shebang_callback_t | shebang_callback, | ||
| void * | shebang_callback_data | ||
| ) |
Set the shebang callback option on the given options struct.
| options | The options struct to set the shebang callback on. |
| shebang_callback | The shebang callback to set. |
| shebang_callback_data | Any additional data that should be passed along to the callback. |
| PRISM_EXPORTED_FUNCTION const pm_string_t * pm_options_filepath | ( | const pm_options_t * | options | ) |
Get the filepath option on the given options struct.
| options | The options struct to get the filepath from. |
| PRISM_EXPORTED_FUNCTION void pm_options_filepath_set | ( | pm_options_t * | options, |
| const char * | filepath | ||
| ) |
Set the filepath option on the given options struct.
| options | The options struct to set the filepath on. |
| filepath | The filepath to set. |
| PRISM_EXPORTED_FUNCTION void pm_options_line_set | ( | pm_options_t * | options, |
| int32_t | line | ||
| ) |
Set the line option on the given options struct.
| options | The options struct to set the line on. |
| line | The line to set. |
| PRISM_EXPORTED_FUNCTION void pm_options_encoding_set | ( | pm_options_t * | options, |
| const char * | encoding | ||
| ) |
Set the encoding option on the given options struct.
| options | The options struct to set the encoding on. |
| encoding | The encoding to set. |
| PRISM_EXPORTED_FUNCTION void pm_options_encoding_locked_set | ( | pm_options_t * | options, |
| bool | encoding_locked | ||
| ) |
Set the encoding_locked option on the given options struct.
| options | The options struct to set the encoding_locked value on. |
| encoding_locked | The encoding_locked value to set. |
| PRISM_EXPORTED_FUNCTION void pm_options_frozen_string_literal_set | ( | pm_options_t * | options, |
| bool | frozen_string_literal | ||
| ) |
Set the frozen string literal option on the given options struct.
| options | The options struct to set the frozen string literal value on. |
| frozen_string_literal | The frozen string literal value to set. |
| PRISM_EXPORTED_FUNCTION void pm_options_command_line_set | ( | pm_options_t * | options, |
| uint8_t | command_line | ||
| ) |
Sets the command line option on the given options struct.
| options | The options struct to set the command line option on. |
| command_line | The command_line value to set. |
| PRISM_EXPORTED_FUNCTION bool pm_options_version_set | ( | pm_options_t * | options, |
| const char * | version, | ||
| size_t | length | ||
| ) |
Set the version option on the given options struct by parsing the given string.
If the string contains an invalid option, this returns false. Otherwise, it returns true.
| options | The options struct to set the version on. |
| version | The version to set. |
| length | The length of the version string. |
| PRISM_EXPORTED_FUNCTION void pm_options_version_set_lowest | ( | pm_options_t * | options | ) |
Set the version option on the given options struct to the lowest version of Ruby that prism supports.
| options | The options struct to set the version on. |
| PRISM_EXPORTED_FUNCTION void pm_options_version_set_highest | ( | pm_options_t * | options | ) |
Set the version option on the given options struct to the highest version of Ruby that prism supports.
| options | The options struct to set the version on. |
| PRISM_EXPORTED_FUNCTION void pm_options_main_script_set | ( | pm_options_t * | options, |
| bool | main_script | ||
| ) |
Set the main script option on the given options struct.
| options | The options struct to set the main script value on. |
| main_script | The main script value to set. |
| PRISM_EXPORTED_FUNCTION void pm_options_partial_script_set | ( | pm_options_t * | options, |
| bool | partial_script | ||
| ) |
Set the partial script option on the given options struct.
| options | The options struct to set the partial script value on. |
| partial_script | The partial script value to set. |
| PRISM_EXPORTED_FUNCTION bool pm_options_freeze | ( | const pm_options_t * | options | ) |
Get the freeze option on the given options struct.
| options | The options struct to get the freeze value from. |
| PRISM_EXPORTED_FUNCTION void pm_options_freeze_set | ( | pm_options_t * | options, |
| bool | freeze | ||
| ) |
Set the freeze option on the given options struct.
| options | The options struct to set the freeze value on. |
| freeze | The freeze value to set. |
| PRISM_EXPORTED_FUNCTION bool pm_options_scopes_init | ( | pm_options_t * | options, |
| size_t | scopes_count | ||
| ) |
Allocate and zero out the scopes array on the given options struct.
| options | The options struct to initialize the scopes array on. |
| scopes_count | The number of scopes to allocate. |
| PRISM_EXPORTED_FUNCTION const pm_options_scope_t * pm_options_scope | ( | const pm_options_t * | options, |
| size_t | index | ||
| ) |
Return a constant pointer to the scope at the given index within the given options.
| options | The options struct to get the scope from. |
| index | The index of the scope to get. |
| PRISM_EXPORTED_FUNCTION pm_options_scope_t * pm_options_scope_mut | ( | pm_options_t * | options, |
| size_t | index | ||
| ) |
Return a mutable pointer to the scope at the given index within the given options.
| options | The options struct to get the scope from. |
| index | The index of the scope to get. |
| PRISM_EXPORTED_FUNCTION void pm_options_scope_init | ( | pm_options_scope_t * | scope, |
| size_t | locals_count | ||
| ) |
Create a new options scope struct.
This will hold a set of locals that are in scope surrounding the code that is being parsed. If the scope was unable to allocate its locals, this function will abort the process.
| scope | The scope struct to initialize. |
| locals_count | The number of locals to allocate. |
| PRISM_EXPORTED_FUNCTION const pm_string_t * pm_options_scope_local | ( | const pm_options_scope_t * | scope, |
| size_t | index | ||
| ) |
Return a constant pointer to the local at the given index within the given scope.
| scope | The scope struct to get the local from. |
| index | The index of the local to get. |
| PRISM_EXPORTED_FUNCTION pm_string_t * pm_options_scope_local_mut | ( | pm_options_scope_t * | scope, |
| size_t | index | ||
| ) |
Return a mutable pointer to the local at the given index within the given scope.
| scope | The scope struct to get the local from. |
| index | The index of the local to get. |
| PRISM_EXPORTED_FUNCTION void pm_options_scope_forwarding_set | ( | pm_options_scope_t * | scope, |
| uint8_t | forwarding | ||
| ) |
Set the forwarding option on the given scope struct.
| scope | The scope struct to set the forwarding on. |
| forwarding | The forwarding value to set. |