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