libpulsar
A modular compiler for the pulsar programming language
Loading...
Searching...
No Matches
error.h
Go to the documentation of this file.
1
8#pragma once
9
10#include <stdio.h>
11
12#include "def.h"
13#include "enum/make.h"
14#include "frontend/lexer/loc.h"
15
16#ifndef PS_MAX_ERRORS
17 #define PS_MAX_ERRORS 128
18#endif
19
24#define ENUM TO_ENUM
25#include "error_scope.h"
26#undef ENUM
28};
29
34#define ENUM TO_ENUM
35#include "error_codes.h"
36#undef ENUM
38};
39
43struct ps_error {
45 short code;
46
47 const char* file_source;
48
49 struct ps_loc loc;
51
52 const char* message;
53 const char* explain;
54 const char* fix;
55
56 const char* theme;
57};
58
71void ps_error(enum ps_error_scope scope, short code, const char* file_source,
72 struct ps_loc loc, usize length, const char* message, const char* explain,
73 const char* fix);
74
81void ps_fprint_errors(FILE* stream);
82#define ps_print_errors() ps_fprint_errors(stderr)
83
Base definitions.
#define usize
Definition def.h:50
usize ps_error_count(void)
The number of errors that have been reported in the error reporting system.
Definition error.c:240
void ps_fprint_errors(FILE *stream)
Prints all errors in the error-reporting system to the given output stream stream.
Definition error.c:215
ps_error_scope
THe domain of error that occured.
Definition error.h:23
@ PS_NUM_OF_ESCOPES
Definition error.h:27
ps_error_code
The type of error that occured.
Definition error.h:33
@ PS_NUM_OF_ECODES
Definition error.h:37
Error codes.
Error scopes.
static void usize struct ps_loc loc
Definition lexer.h:76
static void usize length
Definition lexer.h:71
File location structure.
Retrieval of associated data from custom enum (see enum.h).
Represents an error or source-referencing display message.
Definition error.h:43
struct ps_loc loc
Definition error.h:49
const char * explain
Definition error.h:53
short code
Definition error.h:45
const char * fix
Definition error.h:54
const char * file_source
Definition error.h:47
const char * theme
Definition error.h:56
enum ps_error_scope scope
Definition error.h:44
const char * message
Definition error.h:52
usize length
Definition error.h:50
Represents a token location.
Definition loc.h:16