Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(609)

Unified Diff: src/lexer/lexer-shell.cc

Issue 91833002: Experimental scanner: keeping track of octal numbers octal escapes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/lexer/experimental-scanner.h ('k') | src/lexer/lexer_py.re » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lexer/lexer-shell.cc
diff --git a/src/lexer/lexer-shell.cc b/src/lexer/lexer-shell.cc
index efa9f0dfcee3d54718752dfa28d76de66cad4882..35c34145d3ac1c3adc9bad52c6f223baa2af14d5 100644
--- a/src/lexer/lexer-shell.cc
+++ b/src/lexer/lexer-shell.cc
@@ -171,13 +171,23 @@ struct TokenWithLocation {
size_t end;
std::vector<int> literal;
bool is_ascii;
+ // The location of the latest octal position when the token was seen.
+ int octal_beg;
+ int octal_end;
TokenWithLocation() :
value(Token::ILLEGAL), beg(0), end(0), is_ascii(false) { }
- TokenWithLocation(Token::Value value, size_t beg, size_t end) :
- value(value), beg(beg), end(end), is_ascii(false) { }
+ TokenWithLocation(Token::Value value, size_t beg, size_t end,
+ int octal_beg, int octal_end) :
+ value(value), beg(beg), end(end), is_ascii(false), octal_beg(octal_beg),
+ octal_end(octal_end) { }
bool operator==(const TokenWithLocation& other) {
+ // The octal_end of the baseline scanner is inconsistent between octal
+ // numbers (end = one beyond the last digit) and octal escapes (end = the
+ // last digit). Ignore that.
return value == other.value && beg == other.beg && end == other.end &&
- literal == other.literal && is_ascii == other.is_ascii;
+ literal == other.literal && is_ascii == other.is_ascii &&
+ octal_beg == other.octal_beg &&
+ octal_end >= other.octal_end - 1 && octal_end <= other.octal_end + 1;
}
bool operator!=(const TokenWithLocation& other) {
return !(*this == other);
@@ -191,7 +201,7 @@ struct TokenWithLocation {
printf(is_ascii ? " %02x" : " %04x", literal[i]);
}
}
- printf("\n");
+ printf(" (last octal: %d %d)\n", octal_beg, octal_end);
}
};
@@ -217,7 +227,8 @@ template<typename Scanner>
TokenWithLocation GetTokenWithLocation(Scanner *scanner, Token::Value token) {
int beg = scanner->location().beg_pos;
int end = scanner->location().end_pos;
- TokenWithLocation result(token, beg, end);
+ TokenWithLocation result(token, beg, end, scanner->octal_position().beg_pos,
+ scanner->octal_position().end_pos);
if (HasLiteral(token)) {
result.is_ascii = scanner->is_literal_ascii();
if (scanner->is_literal_ascii()) {
« no previous file with comments | « src/lexer/experimental-scanner.h ('k') | src/lexer/lexer_py.re » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698