insertASpace_ = false;
}
+const char *Prescanner::SkipWhiteSpace(const char *p) {
+ while (*p == ' ' || *p == '\t') {
+ ++p;
+ }
+ return p;
+}
+
bool Prescanner::NextToken(TokenSequence &tokens) {
CHECK(at_ >= start_ && at_ < limit_);
if (InFixedFormSource()) {
}
preventHollerith_ = false;
} else if (IsLegalInIdentifier(*at_)) {
+ // Subtle: Don't misrecognize labeled DO statement label as Hollerith
+ // when the loop control variable starts with 'H'.
+ preventHollerith_ = true;
while (IsLegalInIdentifier(EmitCharAndAdvance(tokens, *at_))) {
}
if (*at_ == '\'' || *at_ == '"') {
QuotedCharacterLiteral(tokens);
}
- preventHollerith_ = false;
} else if (*at_ == '*') {
if (EmitCharAndAdvance(tokens, '*') == '*') {
EmitCharAndAdvance(tokens, '*');
}
bool Prescanner::IsFreeFormComment(const char *p) const {
- while (*p == ' ' || *p == '\t') {
- ++p;
- }
+ p = SkipWhiteSpace(p);
return *p == '!' || *p == '\n';
}
std::optional<std::size_t> Prescanner::IsIncludeLine(const char *start) const {
- const char *p{start};
- while (*p == ' ' || *p == '\t') {
- ++p;
- }
+ const char *p{SkipWhiteSpace(start)};
for (char ch : "include"s) {
if (ToLowerCaseLetter(*p++) != ch) {
return {};
}
}
- while (*p == ' ' || *p == '\t') {
- ++p;
- }
+ p = SkipWhiteSpace(p);
if (*p == '"' || *p == '\'') {
return {p - start};
}
GetProvenanceRange(firstQuote, p));
return;
}
- for (++p; *p == ' ' || *p == '\t'; ++p) {
- }
+ p = SkipWhiteSpace(p + 1);
if (*p != '\n' && *p != '!') {
const char *garbage{p};
for (; *p != '\n' && *p != '!'; ++p) {
return nullptr;
}
} else {
- for (; *p == ' ' || *p == '\t'; ++p) {
- }
+ p = SkipWhiteSpace(p);
if (*p != '#') {
return nullptr;
}
}
- for (++p; *p == ' ' || *p == '\t'; ++p) {
- }
- return p;
+ return SkipWhiteSpace(p + 1);
}
bool Prescanner::IsNextLinePreprocessorDirective() const {
if (p >= limit_) {
return nullptr;
}
- for (; *p == ' ' || *p == '\t'; ++p) {
- }
+ p = SkipWhiteSpace(p);
if (InCompilerDirective()) {
if (*p++ != '!') {
return nullptr;
return nullptr;
}
}
- for (; *p == ' ' || *p == '\t'; ++p) {
- }
+ p = SkipWhiteSpace(p);
if (*p == '&') {
if (!ampersand) {
insertASpace_ = true;
const char *p{at_};
bool ampersand{*p == '&'};
if (ampersand) {
- for (++p; *p == ' ' || *p == '\t'; ++p) {
- }
+ p = SkipWhiteSpace(p + 1);
}
if (*p != '\n' && (inCharLiteral_ || *p != '!')) {
return false;
std::optional<Prescanner::LineClassification>
Prescanner::IsFreeFormCompilerDirectiveLine(const char *start) const {
char sentinel[8];
- const char *p{start};
- while (*p == ' ' || *p == '\t') {
- ++p;
- }
+ const char *p{SkipWhiteSpace(start)};
if (*p++ != '!') {
return {};
}
break;
}
sentinel[j] = '\0';
- for (++p; *p == ' ' || *p == '\t'; ++p) {
- }
+ p = SkipWhiteSpace(p + 1);
if (*p == '!') {
break;
}