*/
#include <stdio.h>
+#include <babeltrace/babeltrace.h>
#include "ctf-scanner.h"
#include "ctf-parser.h"
#include "ctf-ast.h"
__attribute__((unused));
static int input (yyscan_t yyscanner) __attribute__((unused));
-#define printf_dbg(fmt, args...) fprintf(stderr, "%s: " fmt, __func__, ##args)
-
%}
%x comment_ml comment_sl string_lit char_const
[1-9]{DIGIT}*{INTEGER_SUFFIX}? setstring(yyextra, yylval, yytext); return DECIMAL_CONSTANT;
0{OCTALDIGIT}*{INTEGER_SUFFIX}? setstring(yyextra, yylval, yytext); return OCTAL_CONSTANT;
0[xX]{HEXDIGIT}+{INTEGER_SUFFIX}? setstring(yyextra, yylval, yytext); return HEXADECIMAL_CONSTANT;
-{IDENTIFIER} printf_dbg("<IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER;
+{IDENTIFIER} printf_debug("<IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER;
[ \t\n]+ ; /* ignore */
. return ERROR;
%%
#include <errno.h>
#include <inttypes.h>
#include <babeltrace/list.h>
+#include <babeltrace/babeltrace.h>
#include "ctf-scanner.h"
#include "ctf-parser.h"
#include "ctf-ast.h"
+int yydebug;
+
/*
* TODO: support enum, variant and struct declarations in scopes.
*/
}
}
-#define printf_dbg(fmt, args...) fprintf(stderr, "%s: " fmt, __func__, ## args)
-
int yyparse(struct ctf_scanner *scanner);
int yylex(union YYSTYPE *yyval, struct ctf_scanner *scanner);
int yylex_init_extra(struct ctf_scanner *scanner, yyscan_t * ptr_yy_globals);
{
struct ctf_scanner_scope *ns;
- printf_dbg("push scope\n");
+ printf_debug("push scope\n");
ns = malloc(sizeof(struct ctf_scanner_scope));
init_scope(ns, scanner->cs);
scanner->cs = ns;
{
struct ctf_scanner_scope *os;
- printf_dbg("pop scope\n");
+ printf_debug("pop scope\n");
os = scanner->cs;
scanner->cs = os->parent;
finalize_scope(os);
int ret;
ret = (int) (long) g_hash_table_lookup(s->types, id);
- printf_dbg("lookup %p %s %d\n", s, id, ret);
+ printf_debug("lookup %p %s %d\n", s, id, ret);
return ret;
}
break;
}
}
- printf_dbg("is type %s %d\n", id, ret);
+ printf_debug("is type %s %d\n", id, ret);
return ret;
}
static void add_type(struct ctf_scanner *scanner, struct gc_string *id)
{
- printf_dbg("add type %s\n", id->s);
+ printf_debug("add type %s\n", id->s);
if (lookup_type(scanner->cs, id->s))
return;
g_hash_table_insert(scanner->cs->types, id->s, id->s);
struct ctf_scanner *scanner;
int ret;
+ yydebug = babeltrace_debug;
+
scanner = malloc(sizeof(*scanner));
if (!scanner)
return NULL;