#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
+#include <errno.h>
#include "ctf-scanner.h"
#include "ctf-parser.h"
#include "ctf-ast.h"
yydebug = 1;
scanner = ctf_scanner_alloc(stdin);
if (!scanner) {
- fprintf(stderr, "Error allocating scanner\n");
- return -1;
+ fprintf(stdout, "Error allocating scanner\n");
+ return -ENOMEM;
}
ctf_scanner_append_ast(scanner);
- if (ctf_visitor_print_xml(stdout, 0, &scanner->ast->root)) {
- fprintf(stderr, "error visiting AST for XML output\n");
- ret = -1;
+ ret = ctf_visitor_print_xml(stdout, 0, &scanner->ast->root);
+ if (ret) {
+ fprintf(stdout, "error visiting AST for XML output\n");
+ goto end;
}
- ctf_scanner_free(scanner);
+ ret = ctf_visitor_semantic_check(stdout, 0, &scanner->ast->root);
+ if (ret) {
+ fprintf(stdout, "CTF semantic validation error %d\n", ret);
+ goto end;
+ }
+end:
+ ctf_scanner_free(scanner);
return ret;
}