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

Unified Diff: src/scanner.h

Issue 3137037: Ensure that scanner state is correctly reset when an error is encountered. (Closed)
Patch Set: Created 10 years, 4 months 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 | « no previous file | src/scanner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.h
diff --git a/src/scanner.h b/src/scanner.h
index 1c256f15b88147e0203fe34742f2a889809c682f..021687b23a033661f7009424d21072484f6a21ab 100644
--- a/src/scanner.h
+++ b/src/scanner.h
@@ -58,6 +58,14 @@ class UTF8Buffer {
return Vector<const char>(sequence.start(), sequence.length());
}
+ void DropLiteral() {
+ buffer_.DropSequence();
+ }
+
+ void Reset() {
+ buffer_.Reset();
+ }
+
// The end marker added after a parsed literal.
// Using zero allows the usage of strlen and similar functions on
// identifiers and numbers (but not strings, since they may contain zero
@@ -262,6 +270,18 @@ class Scanner {
public:
typedef unibrow::Utf8InputBuffer<1024> Utf8Decoder;
+ class LiteralScope {
+ public:
+ explicit LiteralScope(Scanner* self);
+
+ ~LiteralScope();
+
+ void Complete();
+ private:
Mads Ager (chromium) 2010/08/24 12:19:32 Strange spacing going on here. Please add blank li
Lasse Reichstein 2010/08/24 12:30:21 Done.
+ Scanner* scanner_;
+ bool complete_;
+ };
+
// Construction
explicit Scanner(ParserMode parse_mode);
@@ -382,6 +402,8 @@ class Scanner {
inline void AddChar(uc32 ch);
inline void AddCharAdvance();
inline void TerminateLiteral();
+ // Stops scanning of a literal, e.g., due to an encountered error.
+ inline void DropLiteral();
// Low-level scanning support.
void Advance() { c0_ = source_->Advance(); }
« no previous file with comments | « no previous file | src/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698