NODE_EVENT,
NODE_STREAM,
+ NODE_ENV,
NODE_TRACE,
NODE_CLOCK,
*/
struct cds_list_head declaration_list;
struct cds_list_head trace;
+ struct cds_list_head env;
struct cds_list_head stream;
struct cds_list_head event;
struct cds_list_head clock;
*/
struct cds_list_head declaration_list;
} stream;
+ struct {
+ /*
+ * Children nodes are ctf_expression, typedef,
+ * typealias and type_specifier_list.
+ */
+ struct cds_list_head declaration_list;
+ } env;
struct {
/*
* Children nodes are ctf_expression, typedef,
clock setstring(yyextra, yylval, yytext); return CLOCK;
double setstring(yyextra, yylval, yytext); return DOUBLE;
enum setstring(yyextra, yylval, yytext); return ENUM;
+env setstring(yyextra, yylval, yytext); return ENV;
event setstring(yyextra, yylval, yytext); return EVENT;
floating_point setstring(yyextra, yylval, yytext); return FLOATING_POINT;
float setstring(yyextra, yylval, yytext); return FLOAT;
[ NODE_UNKNOWN ] = "NODE_UNKNOWN",
[ NODE_ROOT ] = "NODE_ROOT",
[ NODE_EVENT ] = "NODE_EVENT",
+ [ NODE_ENV ] = "NODE_ENV",
[ NODE_STREAM ] = "NODE_STREAM",
[ NODE_TRACE ] = "NODE_TRACE",
[ NODE_CLOCK ] = "NODE_CLOCK",
case NODE_STREAM:
CDS_INIT_LIST_HEAD(&node->u.stream.declaration_list);
break;
+ case NODE_ENV:
+ CDS_INIT_LIST_HEAD(&node->u.env.declaration_list);
+ break;
case NODE_TRACE:
CDS_INIT_LIST_HEAD(&node->u.trace.declaration_list);
break;
case NODE_STREAM:
_cds_list_splice_tail(&node->tmp_head, &parent->u.stream.declaration_list);
break;
+ case NODE_ENV:
+ _cds_list_splice_tail(&node->tmp_head, &parent->u.env.declaration_list);
+ break;
case NODE_TRACE:
_cds_list_splice_tail(&node->tmp_head, &parent->u.trace.declaration_list);
break;
case NODE_STREAM:
_cds_list_splice_tail(&node->tmp_head, &parent->u.stream.declaration_list);
break;
+ case NODE_ENV:
+ _cds_list_splice_tail(&node->tmp_head, &parent->u.env.declaration_list);
+ break;
case NODE_TRACE:
_cds_list_splice_tail(&node->tmp_head, &parent->u.trace.declaration_list);
break;
case NODE_STREAM:
_cds_list_splice_tail(&node->tmp_head, &parent->u.stream.declaration_list);
break;
+ case NODE_ENV:
+ _cds_list_splice_tail(&node->tmp_head, &parent->u.env.declaration_list);
+ break;
case NODE_TRACE:
_cds_list_splice_tail(&node->tmp_head, &parent->u.trace.declaration_list);
break;
case NODE_TYPE_SPECIFIER:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
case NODE_CLOCK:
case NODE_VARIANT:
case NODE_STREAM:
cds_list_add_tail(&node->siblings, &parent->u.stream.declaration_list);
break;
+ case NODE_ENV:
+ cds_list_add_tail(&node->siblings, &parent->u.env.declaration_list);
+ break;
case NODE_TRACE:
cds_list_add_tail(&node->siblings, &parent->u.trace.declaration_list);
break;
case NODE_ROOT:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
case NODE_CLOCK:
case NODE_VARIANT:
return -EPERM;
}
break;
+ case NODE_ENV:
+ if (parent->type == NODE_ROOT) {
+ _cds_list_splice_tail(&node->tmp_head, &parent->u.root.env);
+ } else {
+ return -EPERM;
+ }
+ break;
case NODE_TRACE:
if (parent->type == NODE_ROOT) {
_cds_list_splice_tail(&node->tmp_head, &parent->u.root.trace);
CDS_INIT_LIST_HEAD(&ast->root.tmp_head);
CDS_INIT_LIST_HEAD(&ast->root.u.root.declaration_list);
CDS_INIT_LIST_HEAD(&ast->root.u.root.trace);
+ CDS_INIT_LIST_HEAD(&ast->root.u.root.env);
CDS_INIT_LIST_HEAD(&ast->root.u.root.stream);
CDS_INIT_LIST_HEAD(&ast->root.u.root.event);
CDS_INIT_LIST_HEAD(&ast->root.u.root.clock);
*/
%expect 2
%start file
-%token CHARACTER_CONSTANT_START SQUOTE STRING_LITERAL_START DQUOTE ESCSEQ CHAR_STRING_TOKEN LSBRAC RSBRAC LPAREN RPAREN LBRAC RBRAC RARROW STAR PLUS MINUS LT GT TYPEASSIGN COLON SEMICOLON DOTDOTDOT DOT EQUAL COMMA CONST CHAR DOUBLE ENUM EVENT FLOATING_POINT FLOAT INTEGER INT LONG SHORT SIGNED STREAM STRING STRUCT TRACE CLOCK TYPEALIAS TYPEDEF UNSIGNED VARIANT VOID _BOOL _COMPLEX _IMAGINARY DECIMAL_CONSTANT OCTAL_CONSTANT HEXADECIMAL_CONSTANT TOK_ALIGN
+%token CHARACTER_CONSTANT_START SQUOTE STRING_LITERAL_START DQUOTE ESCSEQ CHAR_STRING_TOKEN LSBRAC RSBRAC LPAREN RPAREN LBRAC RBRAC RARROW STAR PLUS MINUS LT GT TYPEASSIGN COLON SEMICOLON DOTDOTDOT DOT EQUAL COMMA CONST CHAR DOUBLE ENUM ENV EVENT FLOATING_POINT FLOAT INTEGER INT LONG SHORT SIGNED STREAM STRING STRUCT TRACE CLOCK TYPEALIAS TYPEDEF UNSIGNED VARIANT VOID _BOOL _COMPLEX _IMAGINARY DECIMAL_CONSTANT OCTAL_CONSTANT HEXADECIMAL_CONSTANT TOK_ALIGN
%token <gs> IDENTIFIER ID_TYPE
%token ERROR
%union
%type <n> declaration
%type <n> event_declaration
%type <n> stream_declaration
+%type <n> env_declaration
%type <n> trace_declaration
%type <n> clock_declaration
%type <n> integer_declaration_specifiers
{ $$ = $1; }
| stream_declaration
{ $$ = $1; }
+ | env_declaration
+ { $$ = $1; }
| trace_declaration
{ $$ = $1; }
| clock_declaration
{ pop_scope(scanner); }
;
+env_declaration:
+ env_declaration_begin env_declaration_end
+ {
+ $$ = make_node(scanner, NODE_ENV);
+ }
+ | env_declaration_begin ctf_assignment_expression_list env_declaration_end
+ {
+ $$ = make_node(scanner, NODE_ENV);
+ if (set_parent_node($2, $$))
+ reparent_error(scanner, "env declaration");
+ }
+ ;
+
+env_declaration_begin:
+ ENV LBRAC
+ { push_scope(scanner); }
+ ;
+
+env_declaration_end:
+ RBRAC SEMICOLON
+ { pop_scope(scanner); }
+ ;
+
trace_declaration:
trace_declaration_begin trace_declaration_end
{
g_free(clock);
}
+static
+int ctf_env_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace *trace)
+{
+ fprintf(fd, "[warning] %s: environment declaration support not implement yet.\n", __func__);
+ return 0; /* continue */
+}
+
static
int ctf_root_declaration_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_trace *trace)
{
{
int ret = 0;
struct ctf_node *iter;
- int clock_done = 0;
+ int env_clock_done = 0;
printf_verbose("CTF visitor: metadata construction... ");
trace->byte_order = byte_order;
switch (node->type) {
case NODE_ROOT:
- if (!clock_done) {
+ if (!env_clock_done) {
+ cds_list_for_each_entry(iter, &node->u.root.env, siblings) {
+ ret = ctf_env_visit(fd, depth + 1, iter,
+ trace);
+ if (ret) {
+ fprintf(fd, "[error] %s: env declaration error\n", __func__);
+ goto error;
+ }
+ }
+
/*
* declarations need to query clock hash table,
* so clock need to be treated first.
goto error;
}
}
- clock_done = 1;
+ env_clock_done = 1;
}
cds_list_for_each_entry(iter, &node->u.root.declaration_list,
siblings) {
return ret;
}
break;
+ case NODE_ENV:
+ cds_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) {
+ iter->parent = node;
+ ret = ctf_visitor_parent_links(fd, depth + 1, iter);
+ if (ret)
+ return ret;
+ }
+ break;
case NODE_TRACE:
cds_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) {
iter->parent = node;
case NODE_ROOT:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
case NODE_CLOCK:
case NODE_TYPEDEF:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
case NODE_CLOCK:
case NODE_UNARY_EXPRESSION:
case NODE_ROOT:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
case NODE_CLOCK:
case NODE_UNARY_EXPRESSION:
case NODE_ROOT:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
case NODE_CLOCK:
case NODE_CTF_EXPRESSION:
return ret;
}
break;
+ case NODE_ENV:
+ switch (node->parent->type) {
+ case NODE_ROOT:
+ break; /* OK */
+ default:
+ goto errinval;
+ }
+
+ cds_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) {
+ ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
+ if (ret)
+ return ret;
+ }
+ break;
case NODE_TRACE:
switch (node->parent->type) {
case NODE_ROOT:
case NODE_ROOT:
case NODE_EVENT:
case NODE_STREAM:
+ case NODE_ENV:
case NODE_TRACE:
case NODE_CLOCK:
case NODE_FLOATING_POINT:
case NODE_ENUMERATOR:
case NODE_ENUM:
case NODE_CLOCK:
+ case NODE_ENV:
default:
goto errinval;
}
case NODE_ENUMERATOR:
case NODE_ENUM:
case NODE_CLOCK:
+ case NODE_ENV:
default:
goto errinval;
}
print_tabs(fd, depth);
fprintf(fd, "</stream>\n");
break;
+ case NODE_ENV:
+ print_tabs(fd, depth);
+ fprintf(fd, "<env>\n");
+ cds_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) {
+ ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+ if (ret)
+ return ret;
+ }
+ print_tabs(fd, depth);
+ fprintf(fd, "</env>\n");
+ break;
case NODE_TRACE:
print_tabs(fd, depth);
fprintf(fd, "<trace>\n");
print_tabs(fd, depth);
fprintf(fd, "</trace>\n");
break;
+ case NODE_CLOCK:
+ print_tabs(fd, depth);
+ fprintf(fd, "<clock>\n");
+ cds_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) {
+ ret = ctf_visitor_print_xml(fd, depth + 1, iter);
+ if (ret)
+ return ret;
+ }
+ print_tabs(fd, depth);
+ fprintf(fd, "</clock>\n");
+ break;
+
case NODE_CTF_EXPRESSION:
print_tabs(fd, depth);