X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/f64af1a757804cd18bd1731b4634e5752b9ca0ed..f4b59008c1616f860f35146237d29f476c56baa8:/src/parse.y diff --git a/src/parse.y b/src/parse.y index 1cda21f..3f02129 100644 --- a/src/parse.y +++ b/src/parse.y @@ -27,10 +27,12 @@ %locations %{ +#include #include #include #include "scan.h" +#include "error.h" #include "cdecl.h" #define FAIL(msg) do { \ @@ -55,6 +57,7 @@ } %code provides { +void cdecl__free(struct cdecl *); void cdecl__yyerror(YYLTYPE *, void *, struct cdecl **, const char *); int cdecl__yyparse(void *scanner, struct cdecl **out); } @@ -130,7 +133,7 @@ static void free_decl(struct cdecl *x) } } -void cdecl_free(struct cdecl *decl) +void cdecl__free(struct cdecl *decl) { free_decl(decl); } @@ -233,7 +236,9 @@ input: T_ENGLISH english { *out = $1; }; -declaration: declspecs declarators T_SEMICOLON { +semi: | T_SEMICOLON + +declaration: declspecs declarators semi { $$ = $2; for (struct cdecl *i = $$; i; i = i->next) @@ -581,5 +586,8 @@ yyerror(YYLTYPE *loc, yyscan_t scanner, struct cdecl **out, if (strstr(err, "T_LEX_ERROR")) return; - fprintf(stderr, "%s\n", err); + cdecl__set_error(&(const struct cdecl_error){ + .code = CDECL_ENOPARSE, + .str = err, + }); }