@@ -82,7 +82,7 @@ bool IONAME(OutputNamelist)(Cookie cookie, const NamelistGroup &group) {
82
82
83
83
static constexpr bool IsLegalIdStart (char32_t ch) {
84
84
return (ch >= ' A' && ch <= ' Z' ) || (ch >= ' a' && ch <= ' z' ) || ch == ' _' ||
85
- ch == ' @' || ch == ' $ ' ;
85
+ ch == ' @' ;
86
86
}
87
87
88
88
static constexpr bool IsLegalIdChar (char32_t ch) {
@@ -378,12 +378,13 @@ static bool HandleComponent(IoStatementState &io, Descriptor &desc,
378
378
return false ;
379
379
}
380
380
381
- // Advance to the terminal '/' of a namelist group.
381
+ // Advance to the terminal '/' of a namelist group or leading '&'/'$'
382
+ // of the next.
382
383
static void SkipNamelistGroup (IoStatementState &io) {
383
384
std::size_t byteCount{0 };
384
385
while (auto ch{io.GetNextNonBlank (byteCount)}) {
385
386
io.HandleRelativePosition (byteCount);
386
- if (*ch == ' /' ) {
387
+ if (*ch == ' /' || *ch == ' & ' || *ch == ' $ ' ) {
387
388
break ;
388
389
} else if (*ch == ' \' ' || *ch == ' "' ) {
389
390
// Skip quoted character literal
@@ -418,7 +419,7 @@ bool IONAME(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
418
419
std::size_t byteCount{0 };
419
420
while (true ) {
420
421
next = io.GetNextNonBlank (byteCount);
421
- while (next && *next != ' &' ) {
422
+ while (next && *next != ' &' && *next != ' $ ' ) {
422
423
// Extension: comment lines without ! before namelist groups
423
424
if (!io.AdvanceRecord ()) {
424
425
next.reset ();
@@ -430,9 +431,10 @@ bool IONAME(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
430
431
handler.SignalEnd ();
431
432
return false ;
432
433
}
433
- if (*next != ' &' ) {
434
+ if (*next != ' &' && *next != ' $ ' ) {
434
435
handler.SignalError (
435
- " NAMELIST input group does not begin with '&' (at '%lc')" , *next);
436
+ " NAMELIST input group does not begin with '&' or '$' (at '%lc')" ,
437
+ *next);
436
438
return false ;
437
439
}
438
440
io.HandleRelativePosition (byteCount);
@@ -448,7 +450,7 @@ bool IONAME(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
448
450
// Read the group's items
449
451
while (true ) {
450
452
next = io.GetNextNonBlank (byteCount);
451
- if (!next || *next == ' /' ) {
453
+ if (!next || *next == ' /' || *next == ' & ' || *next == ' $ ' ) {
452
454
break ;
453
455
}
454
456
if (!GetLowerCaseName (io, name, sizeof name)) {
@@ -540,12 +542,15 @@ bool IONAME(InputNamelist)(Cookie cookie, const NamelistGroup &group) {
540
542
io.HandleRelativePosition (byteCount);
541
543
}
542
544
}
543
- if (!next || *next != ' /' ) {
545
+ if (next && *next == ' /' ) {
546
+ io.HandleRelativePosition (byteCount);
547
+ } else if (*next && (*next == ' &' || *next == ' $' )) {
548
+ // stop at beginning of next group
549
+ } else {
544
550
handler.SignalError (
545
551
" No '/' found after NAMELIST group '%s'" , group.groupName );
546
552
return false ;
547
553
}
548
- io.HandleRelativePosition (byteCount);
549
554
return true ;
550
555
}
551
556
@@ -565,7 +570,7 @@ bool IsNamelistNameOrSlash(IoStatementState &io) {
565
570
// TODO: how to deal with NaN(...) ambiguity?
566
571
return ch && (*ch == ' =' || *ch == ' (' || *ch == ' %' );
567
572
} else {
568
- return *ch == ' /' ;
573
+ return *ch == ' /' || *ch == ' & ' || *ch == ' $ ' ;
569
574
}
570
575
}
571
576
}
0 commit comments