Skip to content

Commit ad55241

Browse files
Stop using exit in parser.
Using exit(EXIT_FAILURE) in the middle of a function makes kgt hard to be embedded as a library, because it interrupts the caller. The previous patch removed usage of exit for every generators: katef#40 This one removes usage of exit for every parser. The parsing_error struct is introduced to list all the errors. Issue: - katef#38 - ArthurSonzogni/Diagon#19
1 parent f41cbe0 commit ad55241

22 files changed

+617
-588
lines changed

src/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ SRC += src/ast.c
44
SRC += src/ast_binary.c
55
SRC += src/bitmap.c
66
SRC += src/main.c
7+
SRC += src/parsing_error.c
78
SRC += src/rewrite_ci.c
89
SRC += src/rewrite_invisible.c
910
SRC += src/txt.c
@@ -22,6 +23,7 @@ ${BUILD}/bin/kgt: ${BUILD}/src/ast.o
2223
${BUILD}/bin/kgt: ${BUILD}/src/ast_binary.o
2324
${BUILD}/bin/kgt: ${BUILD}/src/bitmap.o
2425
${BUILD}/bin/kgt: ${BUILD}/src/main.o
26+
${BUILD}/bin/kgt: ${BUILD}/src/parsing_error.o
2527
${BUILD}/bin/kgt: ${BUILD}/src/rewrite_ci.o
2628
${BUILD}/bin/kgt: ${BUILD}/src/rewrite_invisible.o
2729
${BUILD}/bin/kgt: ${BUILD}/src/txt.o

src/abnf/io.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define KGT_ABNF_IO_H
99

1010
#include "../compiler_specific.h"
11-
11+
#include "../parsing_error.h"
1212
struct ast_rule;
1313

1414
/*
@@ -17,7 +17,7 @@ struct ast_rule;
1717
*/
1818

1919
struct ast_rule *
20-
abnf_input(int (*f)(void *opaque), void *opaque);
20+
abnf_input(int (*f)(void *opaque), void *opaque, parsing_error_queue* errors);
2121

2222
WARN_UNUSED_RESULT
2323
int

0 commit comments

Comments
 (0)