1//===-- runtime/namelist.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// Defines the data structure used for NAMELIST I/O
10
11#ifndef FORTRAN_RUNTIME_NAMELIST_H_
12#define FORTRAN_RUNTIME_NAMELIST_H_
13
14#include "non-tbp-dio.h"
15
16#include <cstddef>
17
18namespace Fortran::runtime {
19class Descriptor;
20class IoStatementState;
21} // namespace Fortran::runtime
22
23namespace Fortran::runtime::io {
24
25// A NAMELIST group is a named ordered collection of distinct variable names.
26// It is packaged by lowering into an instance of this class.
27// If all the items are variables with fixed addresses, the NAMELIST group
28// description can be in a read-only section.
29class NamelistGroup {
30public:
31 struct Item {
32 const char *name; // NUL-terminated lower-case
33 const Descriptor &descriptor;
34 };
35 const char *groupName{nullptr}; // NUL-terminated lower-case
36 std::size_t items{0};
37 const Item *item{nullptr}; // in original declaration order
38
39 // When the uses of a namelist group appear in scopes with distinct sets
40 // of non-type-bound defined formatted I/O interfaces, they require the
41 // use of distinct NamelistGroups pointing to distinct NonTbpDefinedIoTables.
42 // Multiple NamelistGroup instances may share a NonTbpDefinedIoTable..
43 const NonTbpDefinedIoTable *nonTbpDefinedIo{nullptr};
44};
45
46// Look ahead on input for a '/' or an identifier followed by a '=', '(', or '%'
47// character; for use in disambiguating a name-like value (e.g. F or T) from a
48// NAMELIST group item name and for coping with short arrays. Always false
49// when not reading a NAMELIST.
50bool IsNamelistNameOrSlash(IoStatementState &);
51
52} // namespace Fortran::runtime::io
53#endif // FORTRAN_RUNTIME_NAMELIST_H_
54

source code of flang/runtime/namelist.h