X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-parser.y;h=8d8c29ce1e4826841f819c8438a5f8f78f5d1afa;hb=05628561ca57ff5d269571a72a12cb86854c5f70;hp=67180f6e4385bc5d44faa1e780098c85a1f12166;hpb=0009a72566b746aaa6dc82d93e547a422af2587c;p=babeltrace.git diff --git a/formats/ctf/metadata/ctf-parser.y b/formats/ctf/metadata/ctf-parser.y index 67180f6e..8d8c29ce 100644 --- a/formats/ctf/metadata/ctf-parser.y +++ b/formats/ctf/metadata/ctf-parser.y @@ -22,13 +22,18 @@ #include #include #include -#include #include #include +#include +#include #include "ctf-scanner.h" #include "ctf-parser.h" #include "ctf-ast.h" +/* + * TODO: support enum, variant and struct declarations in scopes. + */ + /* Join two lists, put "add" at the end of "head". */ static inline void _cds_list_splice_tail (struct cds_list_head *add, struct cds_list_head *head) @@ -58,6 +63,39 @@ struct gc_string { char s[]; }; +static const char *node_type_to_str[] = { + [ NODE_UNKNOWN ] = "NODE_UNKNOWN", + [ NODE_ROOT ] = "NODE_ROOT", + [ NODE_EVENT ] = "NODE_EVENT", + [ NODE_STREAM ] = "NODE_STREAM", + [ NODE_TRACE ] = "NODE_TRACE", + [ NODE_CTF_EXPRESSION ] = "NODE_CTF_EXPRESSION", + [ NODE_UNARY_EXPRESSION ] = "NODE_UNARY_EXPRESSION", + [ NODE_TYPEDEF ] = "NODE_TYPEDEF", + [ NODE_TYPEALIAS_TARGET ] = "NODE_TYPEALIAS_TARGET", + [ NODE_TYPEALIAS_ALIAS ] = "NODE_TYPEALIAS_ALIAS", + [ NODE_TYPEALIAS ] = "NODE_TYPEALIAS", + [ NODE_TYPE_SPECIFIER ] = "NODE_TYPE_SPECIFIER", + [ NODE_POINTER ] = "NODE_POINTER", + [ NODE_TYPE_DECLARATOR ] = "NODE_TYPE_DECLARATOR", + [ NODE_FLOATING_POINT ] = "NODE_FLOATING_POINT", + [ NODE_INTEGER ] = "NODE_INTEGER", + [ NODE_STRING ] = "NODE_STRING", + [ NODE_ENUMERATOR ] = "NODE_ENUMERATOR", + [ NODE_ENUM ] = "NODE_ENUM", + [ NODE_STRUCT_OR_VARIANT_DECLARATION ] = "NODE_STRUCT_OR_VARIANT_DECLARATION", + [ NODE_VARIANT ] = "NODE_VARIANT", + [ NODE_STRUCT ] = "NODE_STRUCT", +}; + +const char *node_type(struct ctf_node *node) +{ + if (node->type < NR_NODE_TYPES) + return node_type_to_str[node->type]; + else + return NULL; +} + static struct gc_string *gc_string_alloc(struct ctf_scanner *scanner, size_t len) { @@ -153,7 +191,7 @@ static int lookup_type(struct ctf_scanner_scope *s, const char *id) { int ret; - ret = (int) g_hash_table_lookup(s->types, id); + ret = (int) (long) g_hash_table_lookup(s->types, id); printf_dbg("lookup %p %s %d\n", s, id, ret); return ret; } @@ -925,21 +963,21 @@ postfix_expression: { $$ = make_node(scanner, NODE_UNARY_EXPRESSION); $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT; - sscanf(yylval.gs->s, "%llu", + sscanf(yylval.gs->s, "%" PRIu64, &$$->u.unary_expression.u.unsigned_constant); } | OCTAL_CONSTANT { $$ = make_node(scanner, NODE_UNARY_EXPRESSION); $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT; - sscanf(yylval.gs->s, "0%llo", + sscanf(yylval.gs->s, "0%" PRIo64, &$$->u.unary_expression.u.unsigned_constant); } | HEXADECIMAL_CONSTANT { $$ = make_node(scanner, NODE_UNARY_EXPRESSION); $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT; - sscanf(yylval.gs->s, "0x%llx", + sscanf(yylval.gs->s, "0x%" PRIx64, &$$->u.unary_expression.u.unsigned_constant); } | STRING_LITERAL_START DQUOTE @@ -1465,21 +1503,21 @@ type_specifier_or_integer_constant: { $$ = make_node(scanner, NODE_UNARY_EXPRESSION); $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT; - sscanf(yylval.gs->s, "%llu", + sscanf(yylval.gs->s, "%" PRIu64, &$$->u.unary_expression.u.unsigned_constant); } | OCTAL_CONSTANT { $$ = make_node(scanner, NODE_UNARY_EXPRESSION); $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT; - sscanf(yylval.gs->s, "0%llo", + sscanf(yylval.gs->s, "0%" PRIo64, &$$->u.unary_expression.u.unsigned_constant); } | HEXADECIMAL_CONSTANT { $$ = make_node(scanner, NODE_UNARY_EXPRESSION); $$->u.unary_expression.type = UNARY_UNSIGNED_CONSTANT; - sscanf(yylval.gs->s, "0x%llx", + sscanf(yylval.gs->s, "0x%" PRIx64, &$$->u.unary_expression.u.unsigned_constant); } ;