9#ifndef FORTRAN_PARSER_USER_STATE_H_
10#define FORTRAN_PARSER_USER_STATE_H_
17#include "flang/Common/Fortran-features.h"
18#include "flang/Common/idioms.h"
19#include "flang/Parser/char-block.h"
20#include "flang/Parser/parse-tree.h"
21#include "llvm/Support/raw_ostream.h"
25#include <unordered_map>
29class AllCookedSources;
39 : allCooked_{allCooked}, features_{features} {}
44 llvm::raw_ostream *debugOutput()
const {
return debugOutput_; }
45 UserState &set_debugOutput(llvm::raw_ostream &out) {
56 bool instrumentedParse()
const {
return instrumentedParse_; }
57 UserState &set_instrumentedParse(
bool yes) {
58 instrumentedParse_ = yes;
62 void NewSubprogram() {
64 nonlabelDoConstructNestingDepth_ = 0;
65 oldStructureComponents_.clear();
68 using Label = std::uint64_t;
69 bool IsDoLabel(Label label)
const {
70 auto iter{doLabels_.find(label)};
71 return iter != doLabels_.end() &&
72 iter->second >= nonlabelDoConstructNestingDepth_;
74 void NewDoLabel(Label label) {
75 doLabels_[label] = nonlabelDoConstructNestingDepth_;
80 if (nonlabelDoConstructNestingDepth_ > 0) {
81 --nonlabelDoConstructNestingDepth_;
85 void NoteOldStructureComponent(
const CharBlock &name) {
86 oldStructureComponents_.insert(name);
88 bool IsOldStructureComponent(
const CharBlock &name)
const {
89 return oldStructureComponents_.find(name) != oldStructureComponents_.end();
95 llvm::raw_ostream *debugOutput_{
nullptr};
98 bool instrumentedParse_{
false};
100 std::unordered_map<Label, int> doLabels_;
101 int nonlabelDoConstructNestingDepth_{0};
103 std::set<CharBlock> oldStructureComponents_;
111 static std::optional<Success> Parse(
ParseState &);
116 static std::optional<resultType> Parse(
ParseState &);
121 static std::optional<resultType> Parse(
ParseState &);
126 static std::optional<Success> Parse(
ParseState &);
131 static std::optional<Success> Parse(
ParseState &);
136 static std::optional<Name> Parse(
ParseState &);
141 static std::optional<DataComponentDefStmt> Parse(
ParseState &);
146 static std::optional<StructureStmt> Parse(
ParseState &);
Definition: Fortran-features.h:84
Definition: provenance.h:281
Definition: char-block.h:28
Definition: parse-state.h:35
Definition: instrumented-parser.h:25
Definition: user-state.h:33
Definition: user-state.h:35
Definition: check-expression.h:19
Definition: user-state.h:114
Definition: parse-tree.h:1069
Definition: user-state.h:119
Definition: user-state.h:124
Definition: user-state.h:129
Definition: parse-tree.h:580
Definition: user-state.h:144
Definition: user-state.h:134
Definition: user-state.h:109
Definition: parse-tree.h:355
Definition: user-state.h:139
Definition: parse-tree.h:3417