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
17namespace llvm {
18class raw_ostream;
19}
20
21namespace Fortran::common {
22class LangOptions;
23}
24
25namespace Fortran::evaluate {
28class ProcedureRef;
29} // namespace Fortran::evaluate
30
31namespace Fortran::parser {
32
33struct Program;
34struct Expr;
35
36// A function called before each Statement is unparsed.
37using preStatementType =
38 std::function<void(const CharBlock &, llvm::raw_ostream &, int)>;
39
40// Functions to handle unparsing of analyzed expressions and related
41// objects rather than their original parse trees.
43 std::function<void(llvm::raw_ostream &, const evaluate::GenericExprWrapper &)>
44 expr;
45 std::function<void(
46 llvm::raw_ostream &, const evaluate::GenericAssignmentWrapper &)>
47 assignment;
48 std::function<void(llvm::raw_ostream &, const evaluate::ProcedureRef &)> call;
49};
50
51// Converts parsed program (or fragment) to out as Fortran.
52template <typename A>
53void Unparse(llvm::raw_ostream &out, const A &root,
54 const common::LangOptions &langOpts, Encoding encoding = Encoding::UTF_8,
55 bool capitalizeKeywords = true, bool backslashEscapes = true,
56 preStatementType *preStatement = nullptr,
57 AnalyzedObjectsAsFortran * = nullptr);
58
59extern template void Unparse(llvm::raw_ostream &out, const Program &program,
60 const common::LangOptions &langOpts, Encoding encoding,
61 bool capitalizeKeywords, bool backslashEscapes,
62 preStatementType *preStatement, AnalyzedObjectsAsFortran *);
63extern template void Unparse(llvm::raw_ostream &out, const Expr &expr,
64 const common::LangOptions &langOpts, Encoding encoding,
65 bool capitalizeKeywords, bool backslashEscapes,
66 preStatementType *preStatement, AnalyzedObjectsAsFortran *);
67} // namespace Fortran::parser
68
69#endif
Definition LangOptions.h:58
Definition call.h:232
Definition char-block.h:28
Definition bit-population-count.h:20
Definition call.h:34
Definition check-expression.h:19
Definition expression.h:896
Definition parse-tree.h:1700