]> git.draconx.ca Git - cdecl99.git/blobdiff - src/parse.y
Batch up crossparse tests to improve performance.
[cdecl99.git] / src / parse.y
index 1cda21f14d7c39328518345667a31d705c019cfc..3f021290ee32e207ef600d1de74ec5ef6b025d49 100644 (file)
 %locations
 
 %{
+#include <config.h>
 #include <assert.h>
 #include <stdbool.h>
 
 #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,
+       });
 }