return true;
}
+/// Return true if |c| is part of an identifier.
static bool IsIdentChar(char c) {
- return
- ('a' <= c && c <= 'z') ||
- ('+' <= c && c <= '9') || // +,-./ and numbers
- ('A' <= c && c <= 'Z') ||
- (c == '_') || (c == '$') || (c == '\\');
+ // This function shows up hot on profiles. Instead of the natural
+ // 'if' statement, use a table as generated by this Python script:
+ // import string
+ // cs = set()
+ // for c in string.ascii_letters + string.digits + r'+,-./\_$':
+ // cs.add(ord(c))
+ // for i in range(128):
+ // if i in cs:
+ // print '1,',
+ // else:
+ // print '0,',
+ // if i % 16 == 15:
+ // print
+ static const bool kIdents[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1,
+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
+ };
+ return kIdents[(int)c];
}
bool Tokenizer::ExpectToken(Token::Type expected, string* err) {