@@ -119,7 +119,7 @@ inline std::optional<Expr> MultOperand::Parse(ParseState &state) {
119
119
// R1005 add-operand -> [add-operand mult-op] mult-operand
120
120
// R1008 mult-op -> * | /
121
121
// The left recursion in the grammar is implemented iteratively.
122
- constexpr struct AddOperand {
122
+ struct AddOperand {
123
123
using resultType = Expr;
124
124
constexpr AddOperand () {}
125
125
static inline std::optional<Expr> Parse (ParseState &state) {
@@ -142,7 +142,8 @@ constexpr struct AddOperand {
142
142
}
143
143
return result;
144
144
}
145
- } addOperand;
145
+ };
146
+ constexpr AddOperand addOperand;
146
147
147
148
// R1006 level-2-expr -> [[level-2-expr] add-op] add-operand
148
149
// R1009 add-op -> + | -
@@ -151,7 +152,7 @@ constexpr struct AddOperand {
151
152
// by means of a missing first operand; e.g., 2*-3 is valid in C but not
152
153
// standard Fortran. We accept unary + and - to appear before any primary
153
154
// as an extension.
154
- constexpr struct Level2Expr {
155
+ struct Level2Expr {
155
156
using resultType = Expr;
156
157
constexpr Level2Expr () {}
157
158
static inline std::optional<Expr> Parse (ParseState &state) {
@@ -179,13 +180,14 @@ constexpr struct Level2Expr {
179
180
}
180
181
return result;
181
182
}
182
- } level2Expr;
183
+ };
184
+ constexpr Level2Expr level2Expr;
183
185
184
186
// R1010 level-3-expr -> [level-3-expr concat-op] level-2-expr
185
187
// R1011 concat-op -> //
186
188
// Concatenation (//) is left-associative for parsing performance, although
187
189
// one would never notice if it were right-associated.
188
- constexpr struct Level3Expr {
190
+ struct Level3Expr {
189
191
using resultType = Expr;
190
192
constexpr Level3Expr () {}
191
193
static inline std::optional<Expr> Parse (ParseState &state) {
@@ -203,14 +205,15 @@ constexpr struct Level3Expr {
203
205
}
204
206
return result;
205
207
}
206
- } level3Expr;
208
+ };
209
+ constexpr Level3Expr level3Expr;
207
210
208
211
// R1012 level-4-expr -> [level-3-expr rel-op] level-3-expr
209
212
// R1013 rel-op ->
210
213
// .EQ. | .NE. | .LT. | .LE. | .GT. | .GE. |
211
214
// == | /= | < | <= | > | >= @ | <>
212
215
// N.B. relations are not recursive (i.e., LOGICAL is not ordered)
213
- constexpr struct Level4Expr {
216
+ struct Level4Expr {
214
217
using resultType = Expr;
215
218
constexpr Level4Expr () {}
216
219
static inline std::optional<Expr> Parse (ParseState &state) {
@@ -252,17 +255,19 @@ constexpr struct Level4Expr {
252
255
}
253
256
return result;
254
257
}
255
- } level4Expr;
258
+ };
259
+ constexpr Level4Expr level4Expr;
256
260
257
261
// R1014 and-operand -> [not-op] level-4-expr
258
262
// R1018 not-op -> .NOT.
259
263
// N.B. Fortran's .NOT. binds less tightly than its comparison operators do.
260
264
// PGI/Intel extension: accept multiple .NOT. operators
261
- constexpr struct AndOperand {
265
+ struct AndOperand {
262
266
using resultType = Expr;
263
267
constexpr AndOperand () {}
264
268
static inline std::optional<Expr> Parse (ParseState &);
265
- } andOperand;
269
+ };
270
+ constexpr AndOperand andOperand;
266
271
267
272
// Match a logical operator or, optionally, its abbreviation.
268
273
inline constexpr auto logicalOp (const char *op, const char *abbrev) {
@@ -283,7 +288,7 @@ inline std::optional<Expr> AndOperand::Parse(ParseState &state) {
283
288
// R1015 or-operand -> [or-operand and-op] and-operand
284
289
// R1019 and-op -> .AND.
285
290
// .AND. is left-associative
286
- constexpr struct OrOperand {
291
+ struct OrOperand {
287
292
using resultType = Expr;
288
293
constexpr OrOperand () {}
289
294
static inline std::optional<Expr> Parse (ParseState &state) {
@@ -303,12 +308,13 @@ constexpr struct OrOperand {
303
308
}
304
309
return result;
305
310
}
306
- } orOperand;
311
+ };
312
+ constexpr OrOperand orOperand;
307
313
308
314
// R1016 equiv-operand -> [equiv-operand or-op] or-operand
309
315
// R1020 or-op -> .OR.
310
316
// .OR. is left-associative
311
- constexpr struct EquivOperand {
317
+ struct EquivOperand {
312
318
using resultType = Expr;
313
319
constexpr EquivOperand () {}
314
320
static inline std::optional<Expr> Parse (ParseState &state) {
@@ -327,13 +333,14 @@ constexpr struct EquivOperand {
327
333
}
328
334
return result;
329
335
}
330
- } equivOperand;
336
+ };
337
+ constexpr EquivOperand equivOperand;
331
338
332
339
// R1017 level-5-expr -> [level-5-expr equiv-op] equiv-operand
333
340
// R1021 equiv-op -> .EQV. | .NEQV.
334
341
// Logical equivalence is left-associative.
335
342
// Extension: .XOR. as synonym for .NEQV.
336
- constexpr struct Level5Expr {
343
+ struct Level5Expr {
337
344
using resultType = Expr;
338
345
constexpr Level5Expr () {}
339
346
static inline std::optional<Expr> Parse (ParseState &state) {
@@ -358,7 +365,8 @@ constexpr struct Level5Expr {
358
365
}
359
366
return result;
360
367
}
361
- } level5Expr;
368
+ };
369
+ constexpr Level5Expr level5Expr;
362
370
363
371
// R1022 expr -> [expr defined-binary-op] level-5-expr
364
372
// Defined binary operators associate leftwards.
0 commit comments