Gyoji Compiler
Loading...
Searching...
No Matches
jformat-pretty.hpp
1/* Copyright 2025 Jonathan S. Arney
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * https://github.com/jarney/gyoji/blob/master/LICENSE
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#pragma once
16
17#include <gyoji-backend/jbackend.hpp>
18
19namespace Gyoji::backend {
20 using namespace Gyoji::frontend::ast;
26 class JBackendFormatPretty : public JBackend {
27 public:
30 virtual int process(const SyntaxNode * file);
31
32 std::string collect_comments(const SyntaxNode * node);
33 std::string break_multiline_comment(std::string str);
34
35 void print_whitespace(ASTDataNonSyntax::ptr node);
36 void print_comments(std::vector<ASTDataNonSyntax::ptr> &non_syntax_list);
37 void print_comment_single_line(ASTDataNonSyntax::ptr node);
38 void print_comment_multi_line(ASTDataNonSyntax::ptr node);
39 void print_file_metadata(ASTDataNonSyntax::ptr node);
40 void print_non_syntax(ASTDataNonSyntax::ptr node);
41
42 void print_node_generic(const SyntaxNode * node);
43 void print_node_plain(const SyntaxNode * node);
44 void print_node(const SyntaxNode * node);
45 void print_scope_body(const SyntaxNode * node);
46 void newline();
47
48 void print_node_function_def(const SyntaxNode * node);
49
50 int indent_level;
51 int depth;
52 };
53
54};
Definition jformat-pretty.hpp:26
Weakly-typed syntax node.
Definition syntax-node.hpp:69
Abstract syntax tree.
Definition syntax-node.hpp:36