GCC Code Coverage Report


Directory: src/
File: src/cmdline/jformat-identity.cpp
Date: 2025-10-15 09:43:47
Exec Total Coverage
Lines: 43 43 100.0%
Functions: 9 9 100.0%
Branches: 10 11 90.9%

Line Branch Exec Source
1 #include "jformat-identity.hpp"
2 #include <iostream>
3
4 using namespace Gyoji::frontend::ast;
5 using namespace Gyoji::frontend::tree;
6 using namespace Gyoji::cmdline;
7
8 48 JFormatIdentity::JFormatIdentity()
9 48 {}
10 48 JFormatIdentity::~JFormatIdentity()
11 48 {}
12
13 3838 static void print_whitespace(const TerminalNonSyntax & node)
14 {
15 3838 printf("%s", node.get_data().c_str());
16 3838 }
17 96 static void print_comment_single_line(const TerminalNonSyntax & node)
18 {
19 96 printf("%s", node.get_data().c_str());
20 96 }
21 12 static void print_comment_multi_line(const TerminalNonSyntax & node)
22 {
23 12 printf("%s", node.get_data().c_str());
24 12 }
25 4 static void print_file_metadata(const TerminalNonSyntax & node)
26 {
27 4 printf("%s", node.get_data().c_str());
28 4 }
29
30
31 3950 static void print_non_syntax(const TerminalNonSyntax & node)
32 {
33
4/5
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 3838 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
3950 switch (node.get_type()) {
34 12 case TerminalNonSyntax::Type::EXTRA_COMMENT_MULTI_LINE:
35 12 print_comment_multi_line(node);
36 12 break;
37 96 case TerminalNonSyntax::Type::EXTRA_COMMENT_SINGLE_LINE:
38 96 print_comment_single_line(node);
39 96 break;
40 3838 case TerminalNonSyntax::Type::EXTRA_WHITESPACE:
41 3838 print_whitespace(node);
42 3838 break;
43 4 case TerminalNonSyntax::Type::EXTRA_FILE_METADATA:
44 4 print_file_metadata(node);
45 4 break;
46 }
47 3950 }
48
49 12474 static void print_node(const SyntaxNode &node)
50 {
51
2/2
✓ Branch 1 taken 4642 times.
✓ Branch 2 taken 7832 times.
12474 if (node.has_data<Terminal>()) {
52 4642 const Terminal & terminal = node.get_data<Terminal>();
53
2/2
✓ Branch 5 taken 3950 times.
✓ Branch 6 taken 4642 times.
8592 for (const auto &non_syntax : terminal.non_syntax) {
54 3950 print_non_syntax(*non_syntax);
55 }
56 4642 printf("%s", terminal.get_value().c_str());
57 }
58
2/2
✓ Branch 6 taken 12426 times.
✓ Branch 7 taken 12474 times.
24900 for (auto child : node.get_children()) {
59 12426 print_node(child);
60 }
61 12474 }
62
63 48 int JFormatIdentity::process(const SyntaxNode &file)
64 {
65 48 print_node(file);
66 48 return 0;
67 }
68