*/
}
+%name-prefix "cdecl__yy"
%parse-param {yyscan_t scanner}
%parse-param {struct cdecl **out}
%lex-param {yyscan_t scanner}
%locations
%{
+#include <config.h>
#include <assert.h>
#include <stdbool.h>
#include "scan.h"
+#include "error.h"
#include "cdecl.h"
#define FAIL(msg) do { \
}
%code provides {
-void yyerror(YYLTYPE *, void *, struct cdecl **, const char *);
-int yyparse(void *scanner, struct cdecl **out);
+void cdecl__free(struct cdecl *);
+void cdecl__yyerror(YYLTYPE *, void *, struct cdecl **, const char *);
+int cdecl__yyparse(void *scanner, struct cdecl **out);
}
%union {
}
}
-void cdecl_free(struct cdecl *decl)
+void cdecl__free(struct cdecl *decl)
{
free_decl(decl);
}
*out = $1;
};
-declaration: declspecs declarators T_SEMICOLON {
+semi: | T_SEMICOLON
+
+declaration: declspecs declarators semi {
$$ = $2;
for (struct cdecl *i = $$; i; i = i->next)
if (strstr(err, "T_LEX_ERROR"))
return;
- fprintf(stderr, "%s\n", err);
+ cdecl__set_error(&(const struct cdecl_error){
+ .code = CDECL_ENOPARSE,
+ .str = err,
+ });
}