#ifndef FORTRAN_PARSER_PARSING_H_ #define FORTRAN_PARSER_PARSING_H_ #include "characters.h" #include "instrumented-parser.h" #include "message.h" #include "parse-tree.h" #include "provenance.h" #include #include #include #include #include namespace Fortran { namespace parser { struct Options { Options() {} using Predefinition = std::pair>; bool isFixedForm{false}; int fixedFormColumns{72}; bool enableBackslashEscapes{true}; bool enableOldDebugLines{false}; bool isStrictlyStandard{false}; Encoding encoding{Encoding::UTF8}; std::vector searchDirectories; std::vector predefinitions; bool instrumentedParse{false}; }; class Parsing { public: Parsing() {} bool consumedWholeFile() const { return consumedWholeFile_; } const char *finalRestingPlace() const { return finalRestingPlace_; } CookedSource &cooked() { return cooked_; } Messages &messages() { return messages_; } std::optional &parseTree() { return parseTree_; } void Prescan(const std::string &path, Options); void DumpCookedChars(std::ostream &) const; void DumpProvenance(std::ostream &) const; void DumpParsingLog(std::ostream &) const; void Parse(); void Identify(std::ostream &o, const char *at, const std::string &prefix, bool echoSourceLine = false) const { allSources_.Identify( o, cooked_.GetProvenance(at).start(), prefix, echoSourceLine); } bool ForTesting(std::string path, std::ostream &); private: Options options_; AllSources allSources_; CookedSource cooked_{allSources_}; Messages messages_; bool consumedWholeFile_{false}; const char *finalRestingPlace_{nullptr}; std::optional parseTree_; ParsingLog log_; }; } // namespace parser } // namespace Fortran #endif // FORTRAN_PARSER_PARSING_H_