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

1//===-- include/flang/Parser/parsing.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_PARSING_H_
10#define FORTRAN_PARSER_PARSING_H_
11
12#include "characters.h"
13#include "instrumented-parser.h"
14#include "message.h"
15#include "parse-tree.h"
16#include "provenance.h"
17#include "flang/Common/Fortran-features.h"
18#include "flang/Parser/preprocessor.h"
19#include "llvm/Support/raw_ostream.h"
20#include <optional>
21#include <string>
22#include <utility>
23#include <vector>
24
25namespace Fortran::parser {
26
27struct Options {
28 Options() {}
29
30 using Predefinition = std::pair<std::string, std::optional<std::string>>;
31
32 bool isFixedForm{false};
33 int fixedFormColumns{72};
34 common::LanguageFeatureControl features;
35 std::vector<std::string> searchDirectories;
36 std::vector<std::string> intrinsicModuleDirectories;
37 std::vector<Predefinition> predefinitions;
38 bool instrumentedParse{false};
39 bool isModuleFile{false};
40 bool needProvenanceRangeToCharBlockMappings{false};
41 Fortran::parser::Encoding encoding{Fortran::parser::Encoding::UTF_8};
42 bool prescanAndReformat{false}; // -E
43 bool showColors{false};
44};
45
46class Parsing {
47public:
48 explicit Parsing(AllCookedSources &);
49 ~Parsing();
50
51 bool consumedWholeFile() const { return consumedWholeFile_; }
52 const char *finalRestingPlace() const { return finalRestingPlace_; }
53 AllCookedSources &allCooked() { return allCooked_; }
54 const AllCookedSources &allCooked() const { return allCooked_; }
55 Messages &messages() { return messages_; }
56 std::optional<Program> &parseTree() { return parseTree_; }
57
58 const CookedSource &cooked() const { return DEREF(currentCooked_); }
59
60 const SourceFile *Prescan(const std::string &path, Options);
61 void EmitPreprocessedSource(
62 llvm::raw_ostream &, bool lineDirectives = true) const;
63 void EmitPreprocessorMacros(llvm::raw_ostream &) const;
64 void DumpCookedChars(llvm::raw_ostream &) const;
65 void DumpProvenance(llvm::raw_ostream &) const;
66 void DumpParsingLog(llvm::raw_ostream &) const;
67 void Parse(llvm::raw_ostream &debugOutput);
68 void ClearLog();
69
70 void EmitMessage(llvm::raw_ostream &o, const char *at,
71 const std::string &message, const std::string &prefix,
72 llvm::raw_ostream::Colors color = llvm::raw_ostream::SAVEDCOLOR,
73 bool echoSourceLine = false) const {
74 allCooked_.allSources().EmitMessage(o,
75 allCooked_.GetProvenanceRange(CharBlock(at)), message, prefix, color,
76 echoSourceLine);
77 }
78
79private:
80 Options options_;
81 AllCookedSources &allCooked_;
82 CookedSource *currentCooked_{nullptr};
83 Messages messages_;
84 bool consumedWholeFile_{false};
85 const char *finalRestingPlace_{nullptr};
86 std::optional<Program> parseTree_;
87 ParsingLog log_;
88 Preprocessor preprocessor_{allCooked_.allSources()};
89};
90} // namespace Fortran::parser
91#endif // FORTRAN_PARSER_PARSING_H_
92

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

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