OLD | NEW |
---|---|
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 Loading... | |
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 // Returns the value of a number token. | |
152 double number() { | |
tfarina
2011/02/04 15:04:44
I'll not insist in the const here, but I'd like to
Lasse Reichstein
2011/02/07 08:40:43
We generally don't use const in the V8 code.
It sh
| |
153 return number_; | |
154 } | |
155 | |
156 | |
151 protected: | 157 protected: |
152 // Skip past JSON whitespace (only space, tab, newline and carrige-return). | 158 // Skip past JSON whitespace (only space, tab, newline and carrige-return). |
153 bool SkipJsonWhiteSpace(); | 159 bool SkipJsonWhiteSpace(); |
154 | 160 |
155 // Scan a single JSON token. The JSON lexical grammar is specified in the | 161 // Scan a single JSON token. The JSON lexical grammar is specified in the |
156 // ECMAScript 5 standard, section 15.12.1.1. | 162 // ECMAScript 5 standard, section 15.12.1.1. |
157 // Recognizes all of the single-character tokens directly, or calls a function | 163 // Recognizes all of the single-character tokens directly, or calls a function |
158 // to scan a number, string or identifier literal. | 164 // to scan a number, string or identifier literal. |
159 // The only allowed whitespace characters between tokens are tab, | 165 // The only allowed whitespace characters between tokens are tab, |
160 // carriage-return, newline and space. | 166 // carriage-return, newline and space. |
(...skipping 10 matching lines...) Expand all Loading... | |
171 // A JSON string (production JSONString) is subset of valid JavaScript string | 177 // A JSON string (production JSONString) is subset of valid JavaScript string |
172 // literals. The string must only be double-quoted (not single-quoted), and | 178 // 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 | 179 // 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. | 180 // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid. |
175 Token::Value ScanJsonString(); | 181 Token::Value ScanJsonString(); |
176 | 182 |
177 // Used to recognizes one of the literals "true", "false", or "null". These | 183 // Used to recognizes one of the literals "true", "false", or "null". These |
178 // are the only valid JSON identifiers (productions JSONBooleanLiteral, | 184 // are the only valid JSON identifiers (productions JSONBooleanLiteral, |
179 // JSONNullLiteral). | 185 // JSONNullLiteral). |
180 Token::Value ScanJsonIdentifier(const char* text, Token::Value token); | 186 Token::Value ScanJsonIdentifier(const char* text, Token::Value token); |
187 | |
188 // Holds the value of a scanned number token. | |
189 double number_; | |
181 }; | 190 }; |
182 | 191 |
183 } } // namespace v8::internal | 192 } } // namespace v8::internal |
184 | 193 |
185 #endif // V8_SCANNER_H_ | 194 #endif // V8_SCANNER_H_ |
OLD | NEW |