[flang][OpenMP]Add parsing support for MAP(MAPPER(name) ...) (#116274)
[llvm-project.git] / flang / lib / Parser / type-parsers.h
blobadbf6d23cbd99a44be830ab05a65e354cc95c57b
1 //===-- lib/Parser/type-parsers.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 //===----------------------------------------------------------------------===//
9 #ifndef FORTRAN_PARSER_TYPE_PARSERS_H_
10 #define FORTRAN_PARSER_TYPE_PARSERS_H_
12 #include "flang/Parser/instrumented-parser.h"
13 #include "flang/Parser/parse-tree.h"
14 #include <optional>
16 namespace Fortran::parser {
18 // Many parsers in the grammar are defined as instances of this Parser<>
19 // class template, i.e. as the anonymous sole parser for a given type.
20 // This usage requires that their Parse() member functions be defined
21 // separately, typically with a parsing expression wrapped up in an
22 // TYPE_PARSER() macro call.
23 template <typename A> struct Parser {
24 using resultType = A;
25 constexpr Parser() {}
26 constexpr Parser(const Parser &) = default;
27 static std::optional<resultType> Parse(ParseState &);
30 #define CONTEXT_PARSER(contextText, pexpr) \
31 instrumented((contextText), inContext((contextText), (pexpr)))
33 // To allow use of the Fortran grammar (or parts of it) outside the
34 // context of constructing the actual parser.
35 #define TYPE_PARSER(pexpr)
36 #define TYPE_CONTEXT_PARSER(context, pexpr)
38 // Some specializations of Parser<> are used multiple times, or are
39 // of some special importance, so we instantiate them once here and
40 // give them names rather than referencing them as anonymous Parser<T>{}
41 // objects in the right-hand sides of productions.
42 constexpr Parser<Program> program; // R501 - the "top level" production
43 constexpr Parser<SpecificationPart> specificationPart; // R504
44 constexpr Parser<ImplicitPart> implicitPart; // R505
45 constexpr Parser<DeclarationConstruct> declarationConstruct; // R507
46 constexpr Parser<SpecificationConstruct> specificationConstruct; // R508
47 constexpr Parser<ExecutionPart> executionPart; // R509
48 constexpr Parser<ExecutionPartConstruct> executionPartConstruct; // R510
49 constexpr Parser<InternalSubprogramPart> internalSubprogramPart; // R511
50 constexpr Parser<ActionStmt> actionStmt; // R515
51 constexpr Parser<Name> name; // R603
52 constexpr Parser<LiteralConstant> literalConstant; // R605
53 constexpr Parser<NamedConstant> namedConstant; // R606
54 constexpr Parser<TypeParamValue> typeParamValue; // R701
55 constexpr Parser<TypeSpec> typeSpec; // R702
56 constexpr Parser<DeclarationTypeSpec> declarationTypeSpec; // R703
57 constexpr Parser<IntrinsicTypeSpec> intrinsicTypeSpec; // R704
58 constexpr Parser<IntegerTypeSpec> integerTypeSpec; // R705
59 constexpr Parser<KindSelector> kindSelector; // R706
60 constexpr Parser<SignedIntLiteralConstant> signedIntLiteralConstant; // R707
61 constexpr Parser<IntLiteralConstant> intLiteralConstant; // R708
62 constexpr Parser<KindParam> kindParam; // R709
63 constexpr Parser<RealLiteralConstant> realLiteralConstant; // R714
64 constexpr Parser<CharLength> charLength; // R723
65 constexpr Parser<CharLiteralConstant> charLiteralConstant; // R724
66 constexpr Parser<Initialization> initialization; // R743 & R805
67 constexpr Parser<DerivedTypeSpec> derivedTypeSpec; // R754
68 constexpr Parser<TypeDeclarationStmt> typeDeclarationStmt; // R801
69 constexpr Parser<NullInit> nullInit; // R806
70 constexpr Parser<AccessSpec> accessSpec; // R807
71 constexpr Parser<LanguageBindingSpec> languageBindingSpec; // R808, R1528
72 constexpr Parser<EntityDecl> entityDecl; // R803
73 constexpr Parser<CoarraySpec> coarraySpec; // R809
74 constexpr Parser<ArraySpec> arraySpec; // R815
75 constexpr Parser<ExplicitShapeSpec> explicitShapeSpec; // R816
76 constexpr Parser<DeferredShapeSpecList> deferredShapeSpecList; // R820
77 constexpr Parser<AssumedImpliedSpec> assumedImpliedSpec; // R821
78 constexpr Parser<IntentSpec> intentSpec; // R826
79 constexpr Parser<DataStmt> dataStmt; // R837
80 constexpr Parser<DataImpliedDo> dataImpliedDo; // R840
81 constexpr Parser<ParameterStmt> parameterStmt; // R851
82 constexpr Parser<OldParameterStmt> oldParameterStmt;
83 constexpr Parser<Designator> designator; // R901
84 constexpr Parser<Variable> variable; // R902
85 constexpr Parser<Substring> substring; // R908
86 constexpr Parser<DataRef> dataRef; // R911, R914, R917
87 constexpr Parser<StructureComponent> structureComponent; // R913
88 constexpr Parser<SubscriptTriplet> subscriptTriplet; // R921
89 constexpr Parser<AllocateStmt> allocateStmt; // R927
90 constexpr Parser<StatVariable> statVariable; // R929
91 constexpr Parser<StatOrErrmsg> statOrErrmsg; // R942 & R1165
92 constexpr Parser<DefinedOpName> definedOpName; // R1003, R1023, R1414, & R1415
93 constexpr Parser<Expr> expr; // R1022
94 constexpr Parser<SpecificationExpr> specificationExpr; // R1028
95 constexpr Parser<AssignmentStmt> assignmentStmt; // R1032
96 constexpr Parser<PointerAssignmentStmt> pointerAssignmentStmt; // R1033
97 constexpr Parser<WhereStmt> whereStmt; // R1041, R1045, R1046
98 constexpr Parser<WhereConstruct> whereConstruct; // R1042
99 constexpr Parser<WhereBodyConstruct> whereBodyConstruct; // R1044
100 constexpr Parser<ForallConstruct> forallConstruct; // R1050
101 constexpr Parser<ForallAssignmentStmt> forallAssignmentStmt; // R1053
102 constexpr Parser<ForallStmt> forallStmt; // R1055
103 constexpr Parser<Selector> selector; // R1105
104 constexpr Parser<EndSelectStmt> endSelectStmt; // R1143 & R1151 & R1155
105 constexpr Parser<LoopControl> loopControl; // R1123
106 constexpr Parser<ConcurrentHeader> concurrentHeader; // R1125
107 constexpr Parser<IoUnit> ioUnit; // R1201, R1203
108 constexpr Parser<FileUnitNumber> fileUnitNumber; // R1202
109 constexpr Parser<IoControlSpec> ioControlSpec; // R1213, R1214
110 constexpr Parser<Format> format; // R1215
111 constexpr Parser<InputItem> inputItem; // R1216
112 constexpr Parser<OutputItem> outputItem; // R1217
113 constexpr Parser<InputImpliedDo> inputImpliedDo; // R1218, R1219
114 constexpr Parser<OutputImpliedDo> outputImpliedDo; // R1218, R1219
115 constexpr Parser<PositionOrFlushSpec> positionOrFlushSpec; // R1227 & R1229
116 constexpr Parser<FormatStmt> formatStmt; // R1301
117 constexpr Parser<InterfaceBlock> interfaceBlock; // R1501
118 constexpr Parser<GenericSpec> genericSpec; // R1508
119 constexpr Parser<ProcInterface> procInterface; // R1513
120 constexpr Parser<ProcDecl> procDecl; // R1515
121 constexpr Parser<FunctionReference> functionReference; // R1520
122 constexpr Parser<ActualArgSpec> actualArgSpec; // R1523
123 constexpr Parser<PrefixSpec> prefixSpec; // R1527
124 constexpr Parser<FunctionSubprogram> functionSubprogram; // R1529
125 constexpr Parser<FunctionStmt> functionStmt; // R1530
126 constexpr Parser<Suffix> suffix; // R1532
127 constexpr Parser<EndFunctionStmt> endFunctionStmt; // R1533
128 constexpr Parser<SubroutineSubprogram> subroutineSubprogram; // R1534
129 constexpr Parser<SubroutineStmt> subroutineStmt; // R1535
130 constexpr Parser<DummyArg> dummyArg; // R1536
131 constexpr Parser<EndSubroutineStmt> endSubroutineStmt; // R1537
132 constexpr Parser<EntryStmt> entryStmt; // R1541
133 constexpr Parser<ContainsStmt> containsStmt; // R1543
134 constexpr Parser<CompilerDirective> compilerDirective;
135 constexpr Parser<OpenACCConstruct> openaccConstruct;
136 constexpr Parser<OpenACCDeclarativeConstruct> openaccDeclarativeConstruct;
137 constexpr Parser<OpenMPConstruct> openmpConstruct;
138 constexpr Parser<OpenMPDeclarativeConstruct> openmpDeclarativeConstruct;
139 constexpr Parser<OmpEndLoopDirective> ompEndLoopDirective;
140 constexpr Parser<IntrinsicVectorTypeSpec> intrinsicVectorTypeSpec; // Extension
141 constexpr Parser<VectorTypeSpec> vectorTypeSpec; // Extension
142 constexpr Parser<UnsignedTypeSpec> unsignedTypeSpec; // Extension
143 } // namespace Fortran::parser
144 #endif // FORTRAN_PARSER_TYPE_PARSERS_H_