[flang] Begin moving UserState action parsers into user-state.{h,cc}.

Original-commit: flang-compiler/f18@5c31402146
Reviewed-on: https://github.com/flang-compiler/f18/pull/66
Tree-same-pre-rewrite: false
This commit is contained in:
peter klausler 2018-04-20 14:27:49 -07:00
parent 8c110e0af1
commit 8800ae5e08
4 changed files with 11 additions and 10 deletions

View File

@ -13,4 +13,5 @@ add_library(FortranParser
source.cc source.cc
token-sequence.cc token-sequence.cc
unparse.cc unparse.cc
user-state.cc
) )

View File

@ -16,6 +16,7 @@
#include "char-block.h" #include "char-block.h"
#include "idioms.h" #include "idioms.h"
#include "indirection.h"
#include "message.h" #include "message.h"
#include "parse-state.h" #include "parse-state.h"
#include "provenance.h" #include "provenance.h"

View File

@ -259,16 +259,7 @@ constexpr auto scalarIntConstantExpr = scalar(intConstantExpr);
// R501 program -> program-unit [program-unit]... // R501 program -> program-unit [program-unit]...
// This is the top-level production for the Fortran language. // This is the top-level production for the Fortran language.
struct StartNewSubprogram { constexpr StartNewSubprogram startNewSubprogram;
using resultType = Success;
static std::optional<Success> Parse(ParseState &state) {
if (auto ustate = state.userState()) {
ustate->NewSubprogram();
}
return {Success{}};
}
} startNewSubprogram;
TYPE_PARSER( TYPE_PARSER(
construct<Program>{}( construct<Program>{}(
// statements consume only trailing noise; consume leading noise here. // statements consume only trailing noise; consume leading noise here.

View File

@ -6,8 +6,10 @@
// parse tree construction so as to avoid any need for representing // parse tree construction so as to avoid any need for representing
// state in static data. // state in static data.
#include "basic-parsers.h"
#include "char-block.h" #include "char-block.h"
#include <cinttypes> #include <cinttypes>
#include <optional>
#include <set> #include <set>
#include <unordered_set> #include <unordered_set>
@ -16,6 +18,7 @@ namespace parser {
class CookedSource; class CookedSource;
class ParsingLog; class ParsingLog;
class ParseState;
class UserState { class UserState {
public: public:
@ -75,6 +78,11 @@ private:
std::set<CharBlock> oldStructureComponents_; std::set<CharBlock> oldStructureComponents_;
}; };
struct StartNewSubprogram {
using resultType = Success;
static std::optional<Success> Parse(ParseState &);
};
} // namespace parser } // namespace parser
} // namespace Fortran } // namespace Fortran
#endif // FORTRAN_PARSER_USER_STATE_H_ #endif // FORTRAN_PARSER_USER_STATE_H_