#include "ctf-parser.h"
#include "ctf-ast.h"
-#define printf_dbg(fmt, args...) fprintf(stderr, "%s: " fmt, __func__, args)
-#define printf_dbg_noarg(fmt) fprintf(stderr, "%s: " fmt, __func__)
+#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);
strcpy(lvalp->gs->s, src);
}
-static void init_scope(struct scope *scope, struct scope *parent)
+static void init_scope(struct ctf_scanner_scope *scope,
+ struct ctf_scanner_scope *parent)
{
scope->parent = parent;
scope->types = g_hash_table_new_full(g_str_hash, g_str_equal,
(GDestroyNotify) free, NULL);
}
-static void finalize_scope(struct scope *scope)
+static void finalize_scope(struct ctf_scanner_scope *scope)
{
g_hash_table_destroy(scope->types);
}
static void push_scope(struct ctf_scanner *scanner)
{
- struct scope *ns;
+ struct ctf_scanner_scope *ns;
- printf_dbg_noarg("push scope\n");
- ns = malloc(sizeof(struct scope));
+ printf_dbg("push scope\n");
+ ns = malloc(sizeof(struct ctf_scanner_scope));
init_scope(ns, scanner->cs);
scanner->cs = ns;
}
static void pop_scope(struct ctf_scanner *scanner)
{
- struct scope *os;
+ struct ctf_scanner_scope *os;
- printf_dbg_noarg("pop scope\n");
+ printf_dbg("pop scope\n");
os = scanner->cs;
scanner->cs = os->parent;
finalize_scope(os);
free(os);
}
-static int lookup_type(struct scope *s, const char *id)
+static int lookup_type(struct ctf_scanner_scope *s, const char *id)
{
int ret;
int is_type(struct ctf_scanner *scanner, const char *id)
{
- struct scope *it;
+ struct ctf_scanner_scope *it;
int ret = 0;
for (it = scanner->cs; it != NULL; it = it->parent) {
event_declaration_begin:
EVENT LBRAC
- {
- push_scope(scanner);
- }
+ { push_scope(scanner); }
;
event_declaration_end:
RBRAC SEMICOLON
- {
- pop_scope(scanner);
- }
+ { pop_scope(scanner); }
;
stream_declaration_begin:
STREAM LBRAC
- {
- push_scope(scanner);
- }
+ { push_scope(scanner); }
;
stream_declaration_end:
RBRAC SEMICOLON
- {
- pop_scope(scanner);
- }
+ { pop_scope(scanner); }
;
trace_declaration_begin:
TRACE LBRAC
- {
- push_scope(scanner);
- }
+ { push_scope(scanner); }
;
trace_declaration_end:
RBRAC SEMICOLON
- {
- pop_scope(scanner);
- }
+ { pop_scope(scanner); }
;
declaration_specifiers:
struct_declaration_begin:
LBRAC
- {
- push_scope(scanner);
- }
+ { push_scope(scanner); }
;
struct_declaration_end:
RBRAC
- {
- pop_scope(scanner);
- }
+ { pop_scope(scanner); }
;
variant_type_specifier:
variant_declaration_begin:
LBRAC
- {
- push_scope(scanner);
- }
+ { push_scope(scanner); }
;
variant_declaration_end:
RBRAC
- {
- pop_scope(scanner);
- }
+ { pop_scope(scanner); }
;
type_specifier_or_integer_constant:
direct_type_declarator:
IDENTIFIER
- {
- add_type(scanner, $1->s);
- }
+ { add_type(scanner, $1->s); }
| LPAREN type_declarator RPAREN
| direct_type_declarator LSBRAC type_specifier_or_integer_constant RSBRAC
;
direct_abstract_type_declarator:
/* empty */
| IDENTIFIER
- {
- add_type(scanner, $1->s);
- }
+ { add_type(scanner, $1->s); }
| LPAREN abstract_type_declarator RPAREN
| direct_abstract_type_declarator LSBRAC type_specifier_or_integer_constant RSBRAC
| direct_abstract_type_declarator LSBRAC RSBRAC