libpulsar
A modular compiler for the pulsar programming language
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
error.h File Reference

Error reporting and displaying utilities. More...

#include <stdio.h>
#include "def.h"
#include "enum/make.h"
#include "frontend/lexer/loc.h"
#include "error_scope.h"
#include "error_codes.h"

Go to the source code of this file.

Data Structures

struct  ps_error
 Represents an error or source-referencing display message. More...
 

Macros

#define PS_MAX_ERRORS   128
 
#define ENUM   TO_ENUM
 
#define ENUM   TO_ENUM
 
#define ps_print_errors()   ps_fprint_errors(stderr)
 

Enumerations

enum  ps_error_scope { PS_NUM_OF_ESCOPES }
 THe domain of error that occured. More...
 
enum  ps_error_code { PS_NUM_OF_ECODES }
 The type of error that occured. More...
 

Functions

void ps_error (enum ps_error_scope scope, short code, const char *file_source, struct ps_loc loc, usize length, const char *message, const char *explain, const char *fix)
 Reports an error with the given domain scope and error code code to the error reporting system.
 
void ps_fprint_errors (FILE *stream)
 Prints all errors in the error-reporting system to the given output stream stream.
 
usize ps_error_count (void)
 The number of errors that have been reported in the error reporting system.
 

Detailed Description

Error reporting and displaying utilities.

Author
Ethan Uppal

Definition in file error.h.

Macro Definition Documentation

◆ ENUM [1/2]

#define ENUM   TO_ENUM

Definition at line 24 of file error.h.

◆ ENUM [2/2]

#define ENUM   TO_ENUM

Definition at line 24 of file error.h.

◆ PS_MAX_ERRORS

#define PS_MAX_ERRORS   128

Definition at line 17 of file error.h.

◆ ps_print_errors

#define ps_print_errors ( )    ps_fprint_errors(stderr)

Definition at line 82 of file error.h.

Enumeration Type Documentation

◆ ps_error_code

The type of error that occured.

Enumerator
PS_NUM_OF_ECODES 

Definition at line 33 of file error.h.

◆ ps_error_scope

THe domain of error that occured.

Enumerator
PS_NUM_OF_ESCOPES 

Definition at line 23 of file error.h.

Function Documentation

◆ ps_error()

void ps_error ( enum ps_error_scope  scope,
short  code,
const char *  file_source,
struct ps_loc  loc,
usize  length,
const char *  message,
const char *  explain,
const char *  fix 
)

Reports an error with the given domain scope and error code code to the error reporting system.

  • Provide the file_source, loc and length of the error so that the output is formatted nicely.
  • message describes the content of the error.
  • explain provides further information on why the error occured.
  • fix suggest ways to amend the error. You may redefine these semantics in from the user perspective as desired, but they will always be formatted the same way.
    See also
    ps_fprint_errors

Definition at line 82 of file error.c.

◆ ps_error_count()

usize ps_error_count ( void  )

The number of errors that have been reported in the error reporting system.

Definition at line 240 of file error.c.

◆ ps_fprint_errors()

void ps_fprint_errors ( FILE *  stream)

Prints all errors in the error-reporting system to the given output stream stream.

There should never be more than PS_MAX_ERRORS reported before a call to ps_fprint_errors is used to flush the error buffer.

Definition at line 215 of file error.c.