update and skip accepts check in lexers

We think we're getting away with this because our
tokens never go from legal to illegal to legal again,
right?

Change-Id: Iaaef797f7c4b487ba7b1d0e018846bd13086b34c
Reviewed-on: https://skia-review.googlesource.com/138275
Auto-Submit: Mike Klein <mtklein@chromium.org>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
Mike Klein 2018-06-28 18:04:02 -04:00 committed by Skia Commit-Bot
parent 7197e05eae
commit 38f118a2e7
5 changed files with 10 additions and 7 deletions

View File

@ -542,7 +542,8 @@ LayoutToken LayoutLexer::next() {
if (!state) {
break;
}
if (accepts[state]) {
// We seem to be getting away without doing this check.
/*if (accepts[state] != -1)*/ {
lastAccept = (LayoutToken::Kind)accepts[state];
lastAcceptEnd = offset;
}
@ -551,4 +552,4 @@ LayoutToken LayoutLexer::next() {
return LayoutToken(lastAccept, startOffset, lastAcceptEnd - startOffset);
}
} // namespace
} // namespace SkSL

View File

@ -123,5 +123,5 @@ private:
int fOffset;
};
} // namespace
} // namespace SkSL
#endif

View File

@ -957,7 +957,8 @@ Token Lexer::next() {
if (!state) {
break;
}
if (accepts[state]) {
// We seem to be getting away without doing this check.
/*if (accepts[state] != -1)*/ {
lastAccept = (Token::Kind)accepts[state];
lastAcceptEnd = offset;
}
@ -966,4 +967,4 @@ Token Lexer::next() {
return Token(lastAccept, startOffset, lastAcceptEnd - startOffset);
}
} // namespace
} // namespace SkSL

View File

@ -238,5 +238,5 @@ private:
int fOffset;
};
} // namespace
} // namespace SkSL
#endif

View File

@ -149,7 +149,8 @@ void writeCPP(const DFA& dfa, const char* lexer, const char* token, const char*
out << " if (!state) {\n";
out << " break;\n";
out << " }\n";
out << " if (accepts[state]) {\n";
out << " // We seem to be getting away without doing this check.\n";
out << " /*if (accepts[state] != -1)*/ {\n";
out << " lastAccept = (" << token << "::Kind) accepts[state];\n";
out << " lastAcceptEnd = offset;\n";
out << " }\n";