libpulsar
A modular compiler for the pulsar programming language
Loading...
Searching...
No Matches
Macros | Functions
error.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "error.h"
#include "frontend/lexer/loc.h"
#include "util/abort.h"
#include "../libtermcolor/include/termcolor.h"
#include "enum/make.h"
#include "error_scope.h"
#include "error_codes.h"

Go to the source code of this file.

Macros

#define _PRINTF(...)   tcol_fprintf(stream, __VA_ARGS__)
 
#define _PRINTF_FST(...)   fprintf(stream, __VA_ARGS__)
 
#define _PUTCHR(__c)   fputc(__c, stream)
 
#define ENUM   TO_STRING
 
#define ENUM   TO_STRING2
 
#define ENUM   TO_STRING
 
#define N_COLORS_STORABLE   20
 
#define N_ESTIMATED_MAX_COLOR_LENGTH   24
 

Functions

bool ps_is_loc_none (const struct ps_loc *loc)
 
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_error (FILE *stream, struct ps_error *err)
 Displays the err on the given output stream stream.
 
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.
 

Macro Definition Documentation

◆ _PRINTF

#define _PRINTF (   ...)    tcol_fprintf(stream, __VA_ARGS__)

Definition at line 22 of file error.c.

◆ _PRINTF_FST

#define _PRINTF_FST (   ...)    fprintf(stream, __VA_ARGS__)

Definition at line 23 of file error.c.

◆ _PUTCHR

#define _PUTCHR (   __c)    fputc(__c, stream)

Definition at line 25 of file error.c.

◆ ENUM [1/3]

#define ENUM   TO_STRING

◆ ENUM [2/3]

#define ENUM   TO_STRING2

◆ ENUM [3/3]

#define ENUM   TO_STRING

◆ N_COLORS_STORABLE

#define N_COLORS_STORABLE   20

◆ N_ESTIMATED_MAX_COLOR_LENGTH

#define N_ESTIMATED_MAX_COLOR_LENGTH   24

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_error()

void ps_fprint_error ( FILE *  stream,
struct ps_error err 
)

Displays the err on the given output stream stream.

Definition at line 208 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.

◆ ps_is_loc_none()

bool ps_is_loc_none ( const struct ps_loc loc)

Definition at line 20 of file loc.c.