Add AST visitors: parent links creation and semantic validator
[babeltrace.git] / formats / ctf / metadata / ctf-parser-test.c
index 33fda7d12caeb68432aef6476dce99ffa778de23..9f481743d7a723be28ac8771f497b90e4dd2a2ff 100644 (file)
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <glib.h>
+#include <errno.h>
 #include "ctf-scanner.h"
 #include "ctf-parser.h"
 #include "ctf-ast.h"
@@ -28,16 +29,30 @@ extern int yydebug;
 int main(int argc, char **argv)
 {
        struct ctf_scanner *scanner;
+       int ret = 0;
 
        yydebug = 1;
        scanner = ctf_scanner_alloc(stdin);
        if (!scanner) {
                fprintf(stderr, "Error allocating scanner\n");
-               return -1;
+               return -ENOMEM;
        }
        ctf_scanner_append_ast(scanner);
+
+       ret = ctf_visitor_print_xml(stdout, 0, &scanner->ast->root);
+       if (ret) {
+               fprintf(stderr, "error visiting AST for XML output\n");
+               goto end;
+       }
+
+       ret = ctf_visitor_semantic_check(stdout, 0, &scanner->ast->root);
+       if (ret) {
+               fprintf(stderr, "CTF semantic validation error %d\n", ret);
+               goto end;
+       }
+end:
        ctf_scanner_free(scanner);
-       return 0;
+       return ret;
 } 
 
 
This page took 0.025626 seconds and 4 git commands to generate.