@@ -527,10 +527,9 @@ void ScriptParser::readOutputFormat() {
527
527
528
528
void ScriptParser::readPhdrs () {
529
529
expect (" {" );
530
-
531
- while (!errorCount () && !consume (" }" )) {
530
+ while (auto tok = till (" }" )) {
532
531
PhdrsCommand cmd;
533
- cmd.name = next () ;
532
+ cmd.name = tok ;
534
533
cmd.type = readPhdrType ();
535
534
536
535
while (!errorCount () && !consume (" ;" )) {
@@ -626,15 +625,14 @@ SmallVector<SectionCommand *, 0> ScriptParser::readOverlay() {
626
625
627
626
void ScriptParser::readOverwriteSections () {
628
627
expect (" {" );
629
- while (! errorCount () && ! consume (" }" ))
630
- script->overwriteSections .push_back (readOutputSectionDescription (next () ));
628
+ while (auto tok = till (" }" ))
629
+ script->overwriteSections .push_back (readOutputSectionDescription (tok ));
631
630
}
632
631
633
632
void ScriptParser::readSections () {
634
633
expect (" {" );
635
634
SmallVector<SectionCommand *, 0 > v;
636
- while (!errorCount () && !consume (" }" )) {
637
- StringRef tok = next ();
635
+ while (auto tok = till (" }" )) {
638
636
if (tok == " OVERLAY" ) {
639
637
for (SectionCommand *cmd : readOverlay ())
640
638
v.push_back (cmd);
@@ -1005,8 +1003,7 @@ OutputDesc *ScriptParser::readOutputSectionDescription(StringRef outSec) {
1005
1003
osec->constraint = ConstraintKind::ReadWrite;
1006
1004
expect (" {" );
1007
1005
1008
- while (!errorCount () && !consume (" }" )) {
1009
- StringRef tok = next ();
1006
+ while (auto tok = till (" }" )) {
1010
1007
if (tok == " ;" ) {
1011
1008
// Empty commands are allowed. Do nothing here.
1012
1009
} else if (SymbolAssignment *assign = readAssignment (tok)) {
@@ -1806,8 +1803,7 @@ Expr ScriptParser::readMemoryAssignment(StringRef s1, StringRef s2,
1806
1803
// MEMORY { name [(attr)] : ORIGIN = origin, LENGTH = len ... }
1807
1804
void ScriptParser::readMemory () {
1808
1805
expect (" {" );
1809
- while (!errorCount () && !consume (" }" )) {
1810
- StringRef tok = next ();
1806
+ while (auto tok = till (" }" )) {
1811
1807
if (tok == " INCLUDE" ) {
1812
1808
readInclude ();
1813
1809
continue ;
0 commit comments