Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Oct 17, 2024
1 parent 394c8c9 commit fd09975
Showing 1 changed file with 32 additions and 38 deletions.
70 changes: 32 additions & 38 deletions source/parsing/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,25 +1198,14 @@ void Lexer::scanWhitespace() {
addTrivia(TriviaKind::Whitespace);
}

bool detectTranslateOnOffPragma(std::string_view view, bool offMode)
{
bool detectTranslateOnOffPragma(std::string_view view, bool offMode) {
static std::vector<std::string_view> offCandidates = {
"pragma synthesis_off"sv,
"pragma translate_off"sv,
"synopsys synthesis_off"sv,
"synopsys translate_off"sv,
"synthesis translate_off"sv,
"xilinx translate_off"sv
};
"pragma synthesis_off"sv, "pragma translate_off"sv, "synopsys synthesis_off"sv,
"synopsys translate_off"sv, "synthesis translate_off"sv, "xilinx translate_off"sv};

static std::vector<std::string_view> onCandidates = {
"pragma synthesis_on"sv,
"pragma translate_on"sv,
"synopsys synthesis_on"sv,
"synopsys translate_on"sv,
"synthesis translate_on"sv,
"xilinx translate_on"sv
};
"pragma synthesis_on"sv, "pragma translate_on"sv, "synopsys synthesis_on"sv,
"synopsys translate_on"sv, "synthesis translate_on"sv, "xilinx translate_on"sv};

if (view.length() < 2)
return false;
Expand All @@ -1242,14 +1231,18 @@ bool detectTranslateOnOffPragma(std::string_view view, bool offMode)
return false;

cpos++;
} else {
while (clower < cupper && (*clower)[cpos] < *p) clower++;
while (cupper > clower && (*(cupper - 1))[cpos] > *p) cupper--;
}
else {
while (clower < cupper && (*clower)[cpos] < *p)
clower++;
while (cupper > clower && (*(cupper - 1))[cpos] > *p)
cupper--;

if (clower == cupper)
return false;

cpos++; p++;
cpos++;
p++;
}

if (cpos == clower->length()) {
Expand All @@ -1266,29 +1259,30 @@ bool detectTranslateOnOffPragma(std::string_view view, bool offMode)

void Lexer::scanTranslateOffSection() {
while (true) {
const char *commentStart = sourceBuffer;
const char* commentStart = sourceBuffer;

switch (peek()) {
case '\0':
if (reallyAtEnd()) {
addDiag(diag::UnclosedTranslateOff, currentOffset() - lexemeLength());
return;
}
break;
case '/':
advance();
if (peek() == '/') {
case '\0':
if (reallyAtEnd()) {
addDiag(diag::UnclosedTranslateOff, currentOffset() - lexemeLength());
return;
}
break;
case '/':
advance();
while (!isNewline(peek()) && !reallyAtEnd())
if (peek() == '/') {
advance();
while (!isNewline(peek()) && !reallyAtEnd())
advance();

std::string_view commentText = std::string_view(commentStart, sourceBuffer - commentStart);
if (detectTranslateOnOffPragma(commentText, false))
return;
}
continue;
default:
break;
std::string_view commentText = std::string_view(commentStart,
sourceBuffer - commentStart);
if (detectTranslateOnOffPragma(commentText, false))
return;
}
continue;
default:
break;
}
advance();
}
Expand Down

0 comments on commit fd09975

Please sign in to comment.