Add error printout, fix semantic visitor
[babeltrace.git] / formats / ctf / metadata / ctf-parser-test.c
CommitLineData
c59a87f5
MD
1/*
2 * ctf-parser-test.c
3 *
4 * Common Trace Format Parser Test
5 *
6 * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 */
18
34d3acc4
MD
19#include <stdlib.h>
20#include <stdio.h>
21#include <glib.h>
67905e42 22#include <errno.h>
34d3acc4
MD
23#include "ctf-scanner.h"
24#include "ctf-parser.h"
25#include "ctf-ast.h"
26
27extern int yydebug;
28
29int main(int argc, char **argv)
30{
31 struct ctf_scanner *scanner;
7de8808c 32 int ret = 0;
34d3acc4
MD
33
34 yydebug = 1;
35 scanner = ctf_scanner_alloc(stdin);
36 if (!scanner) {
34f7b02c 37 fprintf(stdout, "Error allocating scanner\n");
67905e42 38 return -ENOMEM;
34d3acc4
MD
39 }
40 ctf_scanner_append_ast(scanner);
7de8808c 41
67905e42
MD
42 ret = ctf_visitor_print_xml(stdout, 0, &scanner->ast->root);
43 if (ret) {
34f7b02c 44 fprintf(stdout, "error visiting AST for XML output\n");
67905e42 45 goto end;
7de8808c 46 }
7de8808c 47
67905e42
MD
48 ret = ctf_visitor_semantic_check(stdout, 0, &scanner->ast->root);
49 if (ret) {
34f7b02c 50 fprintf(stdout, "CTF semantic validation error %d\n", ret);
67905e42
MD
51 goto end;
52 }
53end:
54 ctf_scanner_free(scanner);
7de8808c 55 return ret;
34d3acc4
MD
56}
57
58
This page took 0.024578 seconds and 4 git commands to generate.