#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
+#include <errno.h>
#include "ctf-scanner.h"
#include "ctf-parser.h"
#include "ctf-ast.h"
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;
+ fprintf(stdout, "Error allocating scanner\n");
+ return -ENOMEM;
}
- ctf_scanner_append_ast(scanner);
+ ret = ctf_scanner_append_ast(scanner);
+ if (ret) {
+ fprintf(stdout, "Error creating AST\n");
+ goto end;
+ }
+
+ ret = ctf_visitor_print_xml(stdout, 0, &scanner->ast->root);
+ if (ret) {
+ fprintf(stdout, "Error visiting AST for XML output\n");
+ goto end;
+ }
+
+ ret = ctf_visitor_semantic_check(stdout, 0, &scanner->ast->root);
+ if (ret) {
+ fprintf(stdout, "Error in CTF semantic validation %d\n", ret);
+ goto end;
+ }
+end:
ctf_scanner_free(scanner);
- return 0;
+ return ret;
}