//===-- include/flang/Parser/unparse.h --------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef FORTRAN_PARSER_UNPARSE_H_ #define FORTRAN_PARSER_UNPARSE_H_ #include "char-block.h" #include "characters.h" #include #include namespace llvm { class raw_ostream; } namespace Fortran::evaluate { struct GenericExprWrapper; struct GenericAssignmentWrapper; class ProcedureRef; } // namespace Fortran::evaluate namespace Fortran::parser { struct Program; struct Expr; // A function called before each Statement is unparsed. using preStatementType = std::function; // Functions to handle unparsing of analyzed expressions and related // objects rather than their original parse trees. struct AnalyzedObjectsAsFortran { std::function expr; std::function assignment; std::function call; }; // Converts parsed program (or fragment) to out as Fortran. template void Unparse(llvm::raw_ostream &out, const A &root, Encoding encoding = Encoding::UTF_8, bool capitalizeKeywords = true, bool backslashEscapes = true, preStatementType *preStatement = nullptr, AnalyzedObjectsAsFortran * = nullptr); extern template void Unparse(llvm::raw_ostream &out, const Program &program, Encoding encoding, bool capitalizeKeywords, bool backslashEscapes, preStatementType *preStatement, AnalyzedObjectsAsFortran *); extern template void Unparse(llvm::raw_ostream &out, const Expr &expr, Encoding encoding, bool capitalizeKeywords, bool backslashEscapes, preStatementType *preStatement, AnalyzedObjectsAsFortran *); } // namespace Fortran::parser #endif