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

Side by Side Diff: src/scanner.h

Issue 6334106: Improve ScanJsonNumber. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/parser.cc ('k') | src/scanner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 class JsonScanner : public Scanner { 142 class JsonScanner : public Scanner {
143 public: 143 public:
144 JsonScanner(); 144 JsonScanner();
145 145
146 void Initialize(UC16CharacterStream* source); 146 void Initialize(UC16CharacterStream* source);
147 147
148 // Returns the next token. 148 // Returns the next token.
149 Token::Value Next(); 149 Token::Value Next();
150 150
151 double number() {
tfarina 2011/02/04 14:46:48 double number() const { return number_; } I'd add
sandholm 2011/02/04 14:57:22 Done.
152 return number_;
153 }
154
155
151 protected: 156 protected:
152 // Skip past JSON whitespace (only space, tab, newline and carrige-return). 157 // Skip past JSON whitespace (only space, tab, newline and carrige-return).
153 bool SkipJsonWhiteSpace(); 158 bool SkipJsonWhiteSpace();
154 159
155 // Scan a single JSON token. The JSON lexical grammar is specified in the 160 // Scan a single JSON token. The JSON lexical grammar is specified in the
156 // ECMAScript 5 standard, section 15.12.1.1. 161 // ECMAScript 5 standard, section 15.12.1.1.
157 // Recognizes all of the single-character tokens directly, or calls a function 162 // Recognizes all of the single-character tokens directly, or calls a function
158 // to scan a number, string or identifier literal. 163 // to scan a number, string or identifier literal.
159 // The only allowed whitespace characters between tokens are tab, 164 // The only allowed whitespace characters between tokens are tab,
160 // carriage-return, newline and space. 165 // carriage-return, newline and space.
(...skipping 10 matching lines...) Expand all
171 // A JSON string (production JSONString) is subset of valid JavaScript string 176 // A JSON string (production JSONString) is subset of valid JavaScript string
172 // literals. The string must only be double-quoted (not single-quoted), and 177 // literals. The string must only be double-quoted (not single-quoted), and
173 // the only allowed backslash-escapes are ", /, \, b, f, n, r, t and 178 // the only allowed backslash-escapes are ", /, \, b, f, n, r, t and
174 // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid. 179 // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid.
175 Token::Value ScanJsonString(); 180 Token::Value ScanJsonString();
176 181
177 // Used to recognizes one of the literals "true", "false", or "null". These 182 // Used to recognizes one of the literals "true", "false", or "null". These
178 // are the only valid JSON identifiers (productions JSONBooleanLiteral, 183 // are the only valid JSON identifiers (productions JSONBooleanLiteral,
179 // JSONNullLiteral). 184 // JSONNullLiteral).
180 Token::Value ScanJsonIdentifier(const char* text, Token::Value token); 185 Token::Value ScanJsonIdentifier(const char* text, Token::Value token);
186
187 double number_;
181 }; 188 };
182 189
183 } } // namespace v8::internal 190 } } // namespace v8::internal
184 191
185 #endif // V8_SCANNER_H_ 192 #endif // V8_SCANNER_H_
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698