Line | Branch | Exec | Source |
---|---|---|---|
1 | #include <gyoji-frontend.hpp> | ||
2 | #include <gyoji-misc/input-source-file.hpp> | ||
3 | #include "jformat-tree.hpp" | ||
4 | |||
5 | using namespace Gyoji::context; | ||
6 | using namespace Gyoji::frontend; | ||
7 | using namespace Gyoji::frontend::tree; | ||
8 | using namespace Gyoji::frontend::namespaces; | ||
9 | using namespace Gyoji::cmdline; | ||
10 | |||
11 | 48 | int main(int argc, char **argv) | |
12 | { | ||
13 | |||
14 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
|
48 | if (argc != 2) { |
15 | ✗ | fprintf(stderr, "Invalid number of arguments %d\n", argc); | |
16 | ✗ | fprintf(stderr, "Usage: parser backend file\n"); | |
17 | ✗ | exit(1); | |
18 | } | ||
19 | |||
20 | 48 | int input = open(argv[1], O_RDONLY); | |
21 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
|
48 | if (input == -1) { |
22 | ✗ | fprintf(stderr, "Cannot open file %s\n", argv[1]); | |
23 | ✗ | exit(1); | |
24 | } | ||
25 | |||
26 | 48 | CompilerContext context(argv[1]); | |
27 | |||
28 | 48 | Gyoji::misc::InputSourceFile input_source(input); | |
29 | |||
30 | Gyoji::owned<ParseResult> parse_result = | ||
31 | Parser::parse( | ||
32 | context, | ||
33 | input_source | ||
34 | 48 | ); | |
35 | 48 | close(input); | |
36 |
1/2✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
|
48 | if (parse_result->has_errors()) { |
37 | ✗ | parse_result->get_errors().print(); | |
38 | ✗ | return -1; | |
39 | } | ||
40 | |||
41 | 48 | const TranslationUnit & translation_unit = parse_result->get_translation_unit(); | |
42 | |||
43 | 48 | JFormatTree formatter; | |
44 | 48 | formatter.process(translation_unit.get_syntax_node()); | |
45 | |||
46 | 48 | return 0; | |
47 | 48 | } | |
48 |