OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 | 71 |
72 | 72 |
73 // ---------------------------------------------------------------------------- | 73 // ---------------------------------------------------------------------------- |
74 // JavaScriptScanner | 74 // JavaScriptScanner |
75 | 75 |
76 JavaScriptScanner::JavaScriptScanner(UnicodeCache* scanner_contants) | 76 JavaScriptScanner::JavaScriptScanner(UnicodeCache* scanner_contants) |
77 : Scanner(scanner_contants), octal_pos_(Location::invalid()) { } | 77 : Scanner(scanner_contants), octal_pos_(Location::invalid()) { } |
78 | 78 |
79 | 79 |
| 80 void JavaScriptScanner::Initialize(UC16CharacterStream* source) { |
| 81 source_ = source; |
| 82 // Need to capture identifiers in order to recognize "get" and "set" |
| 83 // in object literals. |
| 84 Init(); |
| 85 // Skip initial whitespace allowing HTML comment ends just like |
| 86 // after a newline and scan first token. |
| 87 has_line_terminator_before_next_ = true; |
| 88 SkipWhiteSpace(); |
| 89 Scan(); |
| 90 } |
| 91 |
80 Token::Value JavaScriptScanner::Next() { | 92 Token::Value JavaScriptScanner::Next() { |
81 current_ = next_; | 93 current_ = next_; |
82 has_line_terminator_before_next_ = false; | 94 has_line_terminator_before_next_ = false; |
83 Scan(); | 95 Scan(); |
84 return current_.token; | 96 return current_.token; |
85 } | 97 } |
86 | 98 |
87 | 99 |
88 static inline bool IsByteOrderMark(uc32 c) { | 100 static inline bool IsByteOrderMark(uc32 c) { |
89 // The Unicode value U+FFFE is guaranteed never to be assigned as a | 101 // The Unicode value U+FFFE is guaranteed never to be assigned as a |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return; | 955 if (MatchKeywordStart(input, "with", 1, Token::WITH)) return; |
944 break; | 956 break; |
945 case UNMATCHABLE: | 957 case UNMATCHABLE: |
946 break; | 958 break; |
947 } | 959 } |
948 // On fallthrough, it's a failure. | 960 // On fallthrough, it's a failure. |
949 state_ = UNMATCHABLE; | 961 state_ = UNMATCHABLE; |
950 } | 962 } |
951 | 963 |
952 } } // namespace v8::internal | 964 } } // namespace v8::internal |
OLD | NEW |