FLANG

unparse.h
1 //===-- include/flang/Parser/unparse.h --------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef FORTRAN_PARSER_UNPARSE_H_
10 #define FORTRAN_PARSER_UNPARSE_H_
11
12 #include "char-block.h"
13 #include "characters.h"
14 #include <functional>
15 #include <iosfwd>
16
17 namespace llvm {
18 class raw_ostream;
19 }
20
21 namespace Fortran::evaluate {
22 struct GenericExprWrapper;
23 struct GenericAssignmentWrapper;
24 class ProcedureRef;
25 } // namespace Fortran::evaluate
26
27 namespace Fortran::parser {
28
29 struct Program;
30
31 // A function called before each Statement is unparsed.
32 using preStatementType =
33 std::function<void(const CharBlock &, llvm::raw_ostream &, int)>;
34
35 // Functions to handle unparsing of analyzed expressions and related
36 // objects rather than their original parse trees.
37 struct AnalyzedObjectsAsFortran {
38 std::function<void(llvm::raw_ostream &, const evaluate::GenericExprWrapper &)>
39 expr;
40 std::function<void(
41 llvm::raw_ostream &, const evaluate::GenericAssignmentWrapper &)>
42 assignment;
43 std::function<void(llvm::raw_ostream &, const evaluate::ProcedureRef &)> call;
44 };
45
46 // Converts parsed program to out as Fortran.
47 void Unparse(llvm::raw_ostream &out, const Program &program,
48 Encoding encoding = Encoding::UTF_8, bool capitalizeKeywords = true,
49 bool backslashEscapes = true, preStatementType *preStatement = nullptr,
50 AnalyzedObjectsAsFortran * = nullptr);
51 } // namespace Fortran::parser
52
53 #endif
Fortran::evaluate::GenericExprWrapper
Definition: expression.h:839
Fortran::evaluate::GenericAssignmentWrapper
Definition: expression.h:849
Fortran::evaluate::ProcedureRef
Definition: call.h:190
Fortran::parser::AnalyzedObjectsAsFortran
Definition: unparse.h:37
Fortran::parser
Definition: check-expression.h:19