Lime Parser Generator 0.1.0
Runtime-extensible LALR(1) parser with SIMD tokenization and LLVM JIT
Loading...
Searching...
No Matches
lime_error.h
1/*
2** Error reporting utilities for Lime-generated parsers.
3**
4** Provides expected-token reporting and structured error accumulation
5** for improved parser diagnostics.
6*/
7#ifndef LIME_ERROR_H
8#define LIME_ERROR_H
9
10#include <stddef.h>
11#include <stdint.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17#ifdef LIME_LOCATION_H
18typedef struct LimeLocation LimeLocation;
19#endif
20
29typedef struct LimeError {
30 uint32_t line;
31 uint32_t column;
32 const char *filename;
33 char *message;
34 char *expected;
35 struct LimeError *next;
36} LimeError;
37
38/*
39** Append a new error to the end of `list` and return the (possibly new)
40** list head.
41**
42** list -- existing list head, or NULL to start a new list
43** message -- error text (duplicated; may be NULL)
44** expected -- expected-token string (duplicated; may be NULL)
45** line, column -- 1-based source location
46** filename -- optional filename (borrowed, not duplicated)
47**
48** Returns the list head, or NULL on allocation failure (in which case
49** `list` is left unchanged and the caller still owns it).
50*/
51LimeError *lime_error_append(LimeError *list,
52 const char *message,
53 const char *expected,
54 uint32_t line,
55 uint32_t column,
56 const char *filename);
57
58/*
59** Count the number of errors in `list`. Safe on NULL.
60*/
61size_t lime_error_count(const LimeError *list);
62
63/*
64** Free a linked list of LimeError nodes.
65** Passing NULL is safe.
66*/
67void lime_error_free(LimeError *err);
68
69#ifdef __cplusplus
70}
71#endif
72
73#endif /* LIME_ERROR_H */
Accumulated parse error with location and expected-token info.
Definition lime_error.h:29
struct LimeError * next
Next entry in linked list of errors.
Definition lime_error.h:35
uint32_t line
1-based source line
Definition lime_error.h:30
const char * filename
Borrowed filename, or NULL.
Definition lime_error.h:32
char * message
Human-readable error message (owned)
Definition lime_error.h:33
uint32_t column
1-based source column
Definition lime_error.h:31
char * expected
Comma-separated expected-token list (owned)
Definition lime_error.h:34
Source location tracking for Lime-generated parsers.