Make gc_string_append and yyerror static, as they are only used in
this file.
Remove yywrap, apparently, it's not used. This probably has to do
with the fact that our lexer uses the noyywrap option.
setstring is used by filter-lexer.c (generated from filter-lexer.l),
which has its own local setstring declaration. This is not very good,
because the prototype of setstring could change in the implementation,
and the users of the function would still compile, but then it would
probably crash inexplicably at runtime.
Instead, put the declaration in filter-parser.h, using a "%code
provides" directive. That seems to be the intent of "%code provides"
[1]:
Purpose: This is the best place to write additional definitions and
declarations that should be provided to other modules.
[1] https://www.gnu.org/software/bison/manual/html_node/_0025code-Summary.html
Change-Id: I04ce69ae9808b72e96bf9e602772f0e5758dfc10
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
#include "filter-ast.h"
#include "filter-parser.h"
-extern
-void setstring(struct filter_parser_ctx *parser_ctx, YYSTYPE *lvalp, const char *src);
-
static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
__attribute__((unused));
static int input (yyscan_t yyscanner) __attribute__((unused));
* gsrc will be garbage collected immediately, and gstr might be.
* Should only be used to append characters to a string literal or constant.
*/
-LTTNG_HIDDEN
+static
struct gc_string *gc_string_append(struct filter_parser_ctx *parser_ctx,
struct gc_string *gstr,
struct gc_string *gsrc)
return node;
}
-LTTNG_HIDDEN
+static
void yyerror(struct filter_parser_ctx *parser_ctx, yyscan_t scanner, const char *str)
{
fprintf(stderr, "error %s\n", str);
}
-
-LTTNG_HIDDEN
-int yywrap(void)
-{
- return 1;
-}
#define parse_error(parser_ctx, str) \
do { \
%}
+%code provides
+{
+#include "common/macros.h"
+
+LTTNG_HIDDEN
+void setstring(struct filter_parser_ctx *parser_ctx, YYSTYPE *lvalp, const char *src);
+}
+
%define api.pure
/* %locations */
%parse-param {struct filter_parser_ctx *parser_ctx}