X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/0876ef2649dfc1d1c1fe86a0d56e9506806b37b9..0c61f9637a469ac7a28b5a329551b03e6ad14d62:/src/parse.y diff --git a/src/parse.y b/src/parse.y index f90013a..a14f909 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1,7 +1,7 @@ %code top { /* * Parser for C declarations. - * Copyright © 2011 Nick Bowler + * Copyright © 2011-2012, 2021 Nick Bowler * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ } %name-prefix "cdecl__yy" -%parse-param {yyscan_t scanner} +%parse-param {void *scanner} %parse-param {struct cdecl **out} %lex-param {yyscan_t scanner} %define api.pure @@ -33,6 +33,7 @@ #include "scan.h" #include "cdecl.h" +#include "cdecl-internal.h" #define FAIL(msg) do { \ yyerror(&yylloc, NULL, NULL, msg); \ @@ -56,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); } @@ -131,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); } @@ -578,11 +580,13 @@ english_vla: T_IDENT | { %% void -yyerror(YYLTYPE *loc, yyscan_t scanner, struct cdecl **out, - const char *err) +yyerror(YYLTYPE *loc, yyscan_t scanner, struct cdecl **out, const char *err) { if (strstr(err, "T_LEX_ERROR")) return; - fprintf(stderr, "%s\n", err); + cdecl__set_error(&(const struct cdecl_error){ + .code = CDECL_ENOPARSE, + .str = err, + }); }