GCC Code Coverage Report


Directory: src/
File: src/cmdline/jtokenize.cpp
Date: 2025-10-15 09:43:47
Exec Total Coverage
Lines: 23 28 82.1%
Functions: 1 1 100.0%
Branches: 6 8 75.0%

Line Branch Exec Source
1 #include <gyoji-misc/input-source-file.hpp>
2 #include <gyoji-frontend.hpp>
3 #include <gyoji-context.hpp>
4 #include <gyoji.l.hpp>
5 #include <gyoji.y.hpp>
6
7 using namespace Gyoji::context;
8 using namespace Gyoji::frontend::tree;
9 using namespace Gyoji::frontend::yacc;
10
11 48 int main(int argc, char **argv)
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: jformat-identity 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 48 Gyoji::frontend::namespaces::NS2Context ns2_context;
27
28 48 Gyoji::misc::InputSourceFile input_source(input);
29
30 LexContext lex_context(
31 ns2_context,
32 context,
33 48 input_source);
34
35 yyscan_t scanner;
36 48 yylex_init(&scanner);
37 48 yyset_extra(&lex_context, scanner);
38
39 while (true) {
40 4638 Gyoji::frontend::yacc::YaccParser::semantic_type lvalue;
41 4638 int rc = yylex (&lvalue, scanner);
42
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4590 times.
4638 if (rc == 0) {
43 48 break;
44 }
45 4590 const Gyoji::owned<Gyoji::frontend::tree::Terminal> & token = lvalue.as<Gyoji::owned<Gyoji::frontend::tree::Terminal>>();
46 13770 printf("%ld %ld : %d %s\n",
47 4590 token->get_source_ref().get_line(),
48 4590 token->get_source_ref().get_column(),
49 4590 token->get_type(),
50 4590 token->get_value().c_str());
51
2/2
✓ Branch 1 taken 4590 times.
✓ Branch 2 taken 48 times.
9228 }
52
53 48 return 0;
54 48 }
55