ctf: Remove redundant declarations of lexer/parser functions
[babeltrace.git] / src / plugins / ctf / common / metadata / parser.y
index b6f5b7a3abd0aa01611766411d57b59889aeb893..54d28b6fef67b811f8a88d6a1da377782a0fd15e 100644 (file)
 #include "common/list.h"
 #include "common/assert.h"
 #include "scanner.h"
-#include "parser.h"
 #include "ast.h"
 #include "objstack.h"
 
-#if BT_LOG_ENABLED_TRACE
-# define YYDEBUG 1
-# define YYFPRINTF(_stream, _fmt, args...) BT_LOGT(_fmt, ## args)
-#else
-# define YYDEBUG 0
-#endif
+#include "parser-wrap.h"
 
 /* Join two lists, put "add" at the end of "head".  */
 static inline void
@@ -65,8 +59,6 @@ _bt_list_splice_tail (struct bt_list_head *add, struct bt_list_head *head)
        }
 }
 
-BT_HIDDEN
-int yyparse(struct ctf_scanner *scanner, yyscan_t yyscanner);
 BT_HIDDEN
 int yylex(union YYSTYPE *yyval, yyscan_t yyscanner);
 BT_HIDDEN
@@ -165,7 +157,7 @@ int parse_base_sequence(const char *src, size_t len, size_t pos,
                        return -1;
                }
        }
-       BT_ASSERT(nr_char > 0);
+       BT_ASSERT_DBG(nr_char > 0);
        buffer[nr_char] = '\0';
        *buf_len = nr_char;
        return 0;
@@ -351,7 +343,7 @@ int is_type(struct ctf_scanner *scanner, const char *id)
        struct ctf_scanner_scope *it;
        int ret = 0;
 
-       for (it = scanner->cs; it != NULL; it = it->parent) {
+       for (it = scanner->cs; it; it = it->parent) {
                if (lookup_type(it, id)) {
                        ret = 1;
                        break;
@@ -1042,8 +1034,30 @@ void ctf_scanner_free(struct ctf_scanner *scanner)
        free(scanner);
 }
 
+/*
+ * The bison-provided version of strlen (yystrlen) generates a benign
+ * -Wnull-dereference warning.  That version is used when building on cygwin,
+ * for example, but you can also enable it by hand (to test) by removing the
+ * preprocessor conditional around it.
+ *
+ * Define yystrlen such that it will always use strlen.  As far as we know,
+ * strlen provided by all the platforms we use is reliable.
+ */
+#define yystrlen strlen
+
 %}
 
+/*
+ * This ends up in parser.h and makes sure those who want to include it pass
+ * through parser-wrap.h.
+ */
+%code requires {
+#ifndef ALLOW_INCLUDE_PARSER_H
+# error "Don't include parser.h directly, include parser-wrap.h instead."
+#endif
+}
+
+
 %define api.pure
        /* %locations */
 %error-verbose
@@ -1305,7 +1319,7 @@ unary_expression:
                                $$->u.unary_expression.type = UNARY_SIGNED_CONSTANT;
                                $$->u.unary_expression.u.signed_constant =
                                        -($$->u.unary_expression.u.unsigned_constant);
-                       } else if ($$->u.unary_expression.type == UNARY_UNSIGNED_CONSTANT) {
+                       } else if ($$->u.unary_expression.type == UNARY_SIGNED_CONSTANT) {
                                $$->u.unary_expression.u.signed_constant =
                                        -($$->u.unary_expression.u.signed_constant);
                        } else {
This page took 0.026056 seconds and 4 git commands to generate.