Skip to content

Commit

Permalink
Stop using exit in parser.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ArthurSonzogni committed Mar 27, 2021
1 parent fbf5122 commit d1ca569
Show file tree
Hide file tree
Showing 22 changed files with 617 additions and 588 deletions.
2 changes: 2 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ SRC += src/ast.c
SRC += src/ast_binary.c
SRC += src/bitmap.c
SRC += src/main.c
SRC += src/parsing_error.c
SRC += src/rewrite_ci.c
SRC += src/rewrite_invisible.c
SRC += src/txt.c
Expand All @@ -22,6 +23,7 @@ ${BUILD}/bin/kgt: ${BUILD}/src/ast.o
${BUILD}/bin/kgt: ${BUILD}/src/ast_binary.o
${BUILD}/bin/kgt: ${BUILD}/src/bitmap.o
${BUILD}/bin/kgt: ${BUILD}/src/main.o
${BUILD}/bin/kgt: ${BUILD}/src/parsing_error.o
${BUILD}/bin/kgt: ${BUILD}/src/rewrite_ci.o
${BUILD}/bin/kgt: ${BUILD}/src/rewrite_invisible.o
${BUILD}/bin/kgt: ${BUILD}/src/txt.o
Expand Down
4 changes: 2 additions & 2 deletions src/abnf/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define KGT_ABNF_IO_H

#include "../compiler_specific.h"

#include "../parsing_error.h"
struct ast_rule;

/*
Expand All @@ -17,7 +17,7 @@ struct ast_rule;
*/

struct ast_rule *
abnf_input(int (*f)(void *opaque), void *opaque);
abnf_input(int (*f)(void *opaque), void *opaque, parsing_error_queue* errors);

WARN_UNUSED_RESULT
int
Expand Down

0 comments on commit d1ca569

Please sign in to comment.