Warning: This file is not a C or C++ file. It does not have highlighting.

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

Warning: This file is not a C or C++ file. It does not have highlighting.

source code of flang/include/flang/Parser/unparse.h