FLANG
parsing.h
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 "instrumented-parser.h"
13#include "message.h"
14#include "options.h"
15#include "parse-tree.h"
16#include "provenance.h"
17#include "flang/Parser/preprocessor.h"
18#include "llvm/Support/raw_ostream.h"
19#include <optional>
20#include <string>
21
22namespace Fortran::parser {
23
24class Parsing {
25public:
26 explicit Parsing(AllCookedSources &);
27 ~Parsing();
28
29 bool consumedWholeFile() const { return consumedWholeFile_; }
30 const char *finalRestingPlace() const { return finalRestingPlace_; }
31 AllCookedSources &allCooked() { return allCooked_; }
32 const AllCookedSources &allCooked() const { return allCooked_; }
33 Messages &messages() { return messages_; }
34 std::optional<Program> &parseTree() { return parseTree_; }
35
36 const CookedSource &cooked() const { return DEREF(currentCooked_); }
37
38 const SourceFile *Prescan(const std::string &path, Options);
39 void EmitPreprocessedSource(
40 llvm::raw_ostream &, bool lineDirectives = true) const;
41 void EmitPreprocessorMacros(llvm::raw_ostream &) const;
42 void DumpCookedChars(llvm::raw_ostream &) const;
43 void DumpProvenance(llvm::raw_ostream &) const;
44 void DumpParsingLog(llvm::raw_ostream &) const;
45 void Parse(llvm::raw_ostream &debugOutput);
46 void ClearLog();
47
48 void EmitMessage(llvm::raw_ostream &o, const char *at,
49 const std::string &message, const std::string &prefix,
50 llvm::raw_ostream::Colors color = llvm::raw_ostream::SAVEDCOLOR,
51 bool echoSourceLine = false) const {
52 allCooked_.allSources().EmitMessage(o,
53 allCooked_.GetProvenanceRange(CharBlock(at)), message, prefix, color,
54 echoSourceLine);
55 }
56
57private:
58 Options options_;
59 AllCookedSources &allCooked_;
60 CookedSource *currentCooked_{nullptr};
61 Messages messages_;
62 bool consumedWholeFile_{false};
63 const char *finalRestingPlace_{nullptr};
64 std::optional<Program> parseTree_;
65 ParsingLog log_;
66 Preprocessor preprocessor_{allCooked_.allSources()};
67};
68} // namespace Fortran::parser
69#endif // FORTRAN_PARSER_PARSING_H_
Definition provenance.h:281
Definition char-block.h:28
Definition provenance.h:233
Definition message.h:320
Definition instrumented-parser.h:25
Definition preprocessor.h:73
Definition source.h:52
Definition check-expression.h:19
Definition options.h:21