Chromium Code Reviews| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 | 264 |
| 265 // Returns the current token again. | 265 // Returns the current token again. |
| 266 Token::Value current_token() { return current_.token; } | 266 Token::Value current_token() { return current_.token; } |
| 267 | 267 |
| 268 // One token look-ahead (past the token returned by Next()). | 268 // One token look-ahead (past the token returned by Next()). |
| 269 Token::Value peek() const { return next_.token; } | 269 Token::Value peek() const { return next_.token; } |
| 270 | 270 |
| 271 struct Location { | 271 struct Location { |
| 272 Location(int b, int e) : beg_pos(b), end_pos(e) { } | 272 Location(int b, int e) : beg_pos(b), end_pos(e) { } |
| 273 Location() : beg_pos(0), end_pos(0) { } | 273 Location() : beg_pos(0), end_pos(0) { } |
| 274 | |
| 275 bool IsValid() const { | |
| 276 return beg_pos >= 0 && end_pos >= 0; | |
|
Lasse Reichstein
2011/01/25 13:03:55
How about ... && end_pos >= beg_pos;
Seems more "v
Martin Maly
2011/01/25 17:21:25
Done. Using beg_pos >= 0 && end_pos >= beg_pos
be
| |
| 277 } | |
| 278 | |
| 274 int beg_pos; | 279 int beg_pos; |
| 275 int end_pos; | 280 int end_pos; |
| 276 }; | 281 }; |
| 277 | 282 |
| 283 static Location NoLocation() { | |
| 284 return Location(-1, -1); | |
| 285 } | |
| 286 | |
| 278 // Returns the location information for the current token | 287 // Returns the location information for the current token |
| 279 // (the token returned by Next()). | 288 // (the token returned by Next()). |
| 280 Location location() const { return current_.location; } | 289 Location location() const { return current_.location; } |
| 281 Location peek_location() const { return next_.location; } | 290 Location peek_location() const { return next_.location; } |
| 282 | 291 |
| 283 // Returns the literal string, if any, for the current token (the | 292 // Returns the literal string, if any, for the current token (the |
| 284 // token returned by Next()). The string is 0-terminated and in | 293 // token returned by Next()). The string is 0-terminated and in |
| 285 // UTF-8 format; they may contain 0-characters. Literal strings are | 294 // UTF-8 format; they may contain 0-characters. Literal strings are |
| 286 // collected for identifiers, strings, and numbers. | 295 // collected for identifiers, strings, and numbers. |
| 287 // These functions only give the correct result if the literal | 296 // These functions only give the correct result if the literal |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 617 // keyword with the current prefix). | 626 // keyword with the current prefix). |
| 618 const char* keyword_; | 627 const char* keyword_; |
| 619 int counter_; | 628 int counter_; |
| 620 Token::Value keyword_token_; | 629 Token::Value keyword_token_; |
| 621 }; | 630 }; |
| 622 | 631 |
| 623 | 632 |
| 624 } } // namespace v8::internal | 633 } } // namespace v8::internal |
| 625 | 634 |
| 626 #endif // V8_SCANNER_BASE_H_ | 635 #endif // V8_SCANNER_BASE_H_ |
| OLD | NEW |