Luma 0.1.0
A low-level compiled alternative to C, C++, and more!
Loading...
Searching...
No Matches
Macros | Functions
error.c File Reference

Implementation of error reporting and diagnostics functions. More...

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../../lexer/lexer.h"
#include "../color/color.h"
#include "../memory/memory.h"
#include "error.h"
Include dependency graph for error.c:

Macros

#define MAX_ERRORS   256
 

Functions

const char * generate_line (ArenaAllocator *arena, Token *tokens, int token_count, int target_line)
 Generates the full source line text for a given line number.
 
void error_add (ErrorInformation err)
 Adds an error to the internal error list.
 
void error_clear (void)
 Clears all accumulated errors from the error list.
 
bool error_report (void)
 Reports all accumulated errors with formatting.
 
int error_get_count (void)
 Gets the current error count.
 
bool error_has_errors (void)
 Checks if there are any errors.
 
ErrorInformationerror_get_at_index (int index)
 Gets the error at the specified index.
 

Detailed Description

Implementation of error reporting and diagnostics functions.

This module manages an internal list of errors, supports generating source line context from tokens, and prints detailed error reports with color highlighting.

Macro Definition Documentation

◆ MAX_ERRORS

#define MAX_ERRORS   256

Function Documentation

◆ error_add()

void error_add ( ErrorInformation  err)

Adds an error to the internal error list.

Adds a new error to the internal error list.

◆ error_clear()

void error_clear ( void  )

Clears all accumulated errors from the error list.

Clears all accumulated errors.

◆ error_get_at_index()

ErrorInformation * error_get_at_index ( int  index)

Gets the error at the specified index.

Parameters
indexIndex of the error to retrieve (0-based).
Returns
Pointer to the ErrorInformation struct, or NULL if index is invalid.

◆ error_get_count()

int error_get_count ( void  )

Gets the current error count.

Returns
Number of errors currently accumulated.

◆ error_has_errors()

bool error_has_errors ( void  )

Checks if there are any errors.

Returns
true if there are errors, false otherwise.

◆ error_report()

bool error_report ( void  )

Reports all accumulated errors with formatting.

Reports all accumulated errors to stderr or appropriate output.

◆ generate_line()

const char * generate_line ( ArenaAllocator arena,
Token tokens,
int  token_count,
int  target_line 
)

Generates the full source line text for a given line number.

Generates the source code line text for a given line number.