Skip to content

Commit 0f2bbb9

Browse files
committed
Add ast_printer.cc to the cxx-parser library
1 parent a2ddf4d commit 0f2bbb9

File tree

7 files changed

+12
-7
lines changed

7 files changed

+12
-7
lines changed

packages/cxx-gen-ast/src/gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ gen_ast_visitor_h({
6767
});
6868
gen_ast_dump_h({
6969
ast,
70-
output: path.join(outdir, "src/frontend/cxx/ast_printer.h"),
70+
output: path.join(outdir, "src/parser/cxx/ast_printer.h"),
7171
});
7272
gen_ast_dump_cc({
7373
ast,
74-
output: path.join(outdir, "src/frontend/cxx/ast_printer.cc"),
74+
output: path.join(outdir, "src/parser/cxx/ast_printer.cc"),
7575
});
7676
gen_ast_kind_h({ ast, output: path.join(outdir, "src/parser/cxx/ast_kind.h") });
7777
gen_ast_slot_h({ ast, output: path.join(outdir, "src/parser/cxx/ast_slot.h") });

packages/cxx-gen-ast/src/gen_ast_dump_cc.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ export function gen_ast_dump_cc({ ast, output }: { ast: AST; output: string }) {
108108
if (base == "ExpressionAST") {
109109
emit(` out_ << "${astName(name)}";`);
110110
emit(` if (ast->type) {`);
111-
emit(` out_ << std::format(" [{} {}]", to_string(ast->valueCategory), to_string(ast->type));`);
111+
emit(
112+
` out_ << std::format(" [{} {}]", to_string(ast->valueCategory), to_string(ast->type));`
113+
);
112114
emit(` }`);
113115
emit(` out_ << "\\n";`);
114116
} else {
@@ -137,8 +139,9 @@ export function gen_ast_dump_cc({ ast, output }: { ast: AST; output: string }) {
137139
});
138140

139141
const out = `${cpy_header}
140-
#include "ast_printer.h"
142+
#include <cxx/ast_printer.h>
141143
144+
// cxx
142145
#include <cxx/ast.h>
143146
#include <cxx/translation_unit.h>
144147
#include <cxx/names.h>

src/frontend/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020

2121
add_executable(cxx
22-
cxx/ast_printer.cc
2322
cxx/frontend.cc
2423
cxx/verify_diagnostics_client.cc
2524
)

src/frontend/cxx/frontend.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@
4141
#include <cxx/mlir/cxx_dialect.h>
4242
#endif
4343

44+
#include <cxx/ast_printer.h>
45+
4446
#include <format>
4547
#include <fstream>
4648
#include <iostream>
4749
#include <list>
4850
#include <regex>
4951
#include <string>
5052

51-
#include "ast_printer.h"
5253
#include "verify_diagnostics_client.h"
5354

5455
namespace {

src/parser/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ file(GLOB CXX_VIEWS_INCLUDE_HEADER_FILES cxx/views/*.h)
2323
add_library(cxx-parser
2424
cxx/ast_cursor.cc
2525
cxx/ast_interpreter.cc
26+
cxx/ast_printer.cc
2627
cxx/ast_rewriter.cc
2728
cxx/ast_slot.cc
2829
cxx/ast.cc

src/frontend/cxx/ast_printer.cc renamed to src/parser/cxx/ast_printer.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
// SOFTWARE.
2020

21-
#include "ast_printer.h"
21+
#include <cxx/ast_printer.h>
2222

23+
// cxx
2324
#include <cxx/ast.h>
2425
#include <cxx/literals.h>
2526
#include <cxx/names.h>
File renamed without changes.

0 commit comments

Comments
 (0)