Prism Ruby parser
Loading...
Searching...
No Matches
Typedefs | Enumerations | Functions
diagnostic.h File Reference

A list of diagnostics generated during parsing. More...

#include "prism/compiler/exported.h"
#include "prism/compiler/nodiscard.h"
#include "prism/compiler/nonnull.h"
#include "prism/ast.h"
Include dependency graph for diagnostic.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct pm_diagnostic_t pm_diagnostic_t
 An opaque pointer to a diagnostic generated during parsing.
 

Enumerations

enum  pm_error_level_t { PM_ERROR_LEVEL_SYNTAX = 0 , PM_ERROR_LEVEL_ARGUMENT = 1 , PM_ERROR_LEVEL_LOAD = 2 }
 The levels of errors generated during parsing. More...
 
enum  pm_warning_level_t { PM_WARNING_LEVEL_DEFAULT = 0 , PM_WARNING_LEVEL_VERBOSE = 1 }
 The levels of warnings generated during parsing. More...
 

Functions

PRISM_EXPORTED_FUNCTION const char * pm_diagnostic_type (const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1)
 Get the type of the given diagnostic.
 
PRISM_EXPORTED_FUNCTION pm_location_t pm_diagnostic_location (const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1)
 Get the location of the given diagnostic.
 
PRISM_EXPORTED_FUNCTION const char * pm_diagnostic_message (const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1)
 Get the message of the given diagnostic.
 
PRISM_EXPORTED_FUNCTION pm_error_level_t pm_diagnostic_error_level (const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1)
 Get the error level associated with the given diagnostic.
 
PRISM_EXPORTED_FUNCTION pm_warning_level_t pm_diagnostic_warning_level (const pm_diagnostic_t *diagnostic) PRISM_NONNULL(1)
 Get the warning level associated with the given diagnostic.
 

Detailed Description

A list of diagnostics generated during parsing.

Enumeration Type Documentation

◆ pm_error_level_t

The levels of errors generated during parsing.

Enumerator
PM_ERROR_LEVEL_SYNTAX 

For errors that should raise a syntax error.

PM_ERROR_LEVEL_ARGUMENT 

For errors that should raise an argument error.

PM_ERROR_LEVEL_LOAD 

For errors that should raise a load error.

◆ pm_warning_level_t

The levels of warnings generated during parsing.

Enumerator
PM_WARNING_LEVEL_DEFAULT 

For warnings which should be emitted if $VERBOSE != nil.

PM_WARNING_LEVEL_VERBOSE 

For warnings which should be emitted if $VERBOSE == true.

Function Documentation

◆ pm_diagnostic_type()

PRISM_EXPORTED_FUNCTION const char * pm_diagnostic_type ( const pm_diagnostic_t diagnostic)

Get the type of the given diagnostic.

Parameters
diagnosticThe diagnostic to get the type of.
Returns
The type of the given diagnostic. Note that this is a string representation of an internal ID, and is not meant to be relied upon as a stable identifier for the diagnostic. We do not guarantee that these will not change in the future. This is meant to be used for debugging and error reporting purposes, and not for programmatic checks.

◆ pm_diagnostic_location()

PRISM_EXPORTED_FUNCTION pm_location_t pm_diagnostic_location ( const pm_diagnostic_t diagnostic)

Get the location of the given diagnostic.

Parameters
diagnosticThe diagnostic to get the location of.
Returns
The location of the given diagnostic.

◆ pm_diagnostic_message()

PRISM_EXPORTED_FUNCTION const char * pm_diagnostic_message ( const pm_diagnostic_t diagnostic)

Get the message of the given diagnostic.

Parameters
diagnosticThe diagnostic to get the message of.
Returns
The message of the given diagnostic.

◆ pm_diagnostic_error_level()

PRISM_EXPORTED_FUNCTION pm_error_level_t pm_diagnostic_error_level ( const pm_diagnostic_t diagnostic)

Get the error level associated with the given diagnostic.

Parameters
diagnosticThe diagnostic to get the error level of.
Returns
The error level of the given diagnostic. If the diagnostic was a warning, or is in any way not an error, then the return value is undefined and should not be relied upon.

◆ pm_diagnostic_warning_level()

PRISM_EXPORTED_FUNCTION pm_warning_level_t pm_diagnostic_warning_level ( const pm_diagnostic_t diagnostic)

Get the warning level associated with the given diagnostic.

Parameters
diagnosticThe diagnostic to get the warning level of.
Returns
The warning level of the given diagnostic. If the diagnostic was an error, or is in any way not a warning, then the return value is undefined and should not be relied upon.