OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_DATEPARSER_H_ | 28 #ifndef V8_DATEPARSER_H_ |
29 #define V8_DATEPARSER_H_ | 29 #define V8_DATEPARSER_H_ |
30 | 30 |
31 #include "scanner.h" | 31 #include "char-predicates-inl.h" |
| 32 #include "scanner-base.h" |
32 | 33 |
33 namespace v8 { | 34 namespace v8 { |
34 namespace internal { | 35 namespace internal { |
35 | 36 |
36 class DateParser : public AllStatic { | 37 class DateParser : public AllStatic { |
37 public: | 38 public: |
38 | 39 |
39 // Parse the string as a date. If parsing succeeds, return true after | 40 // Parse the string as a date. If parsing succeeds, return true after |
40 // filling out the output array as follows (all integers are Smis): | 41 // filling out the output array as follows (all integers are Smis): |
41 // [0]: year | 42 // [0]: year |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 int ReadWord(uint32_t* prefix, int prefix_size) { | 93 int ReadWord(uint32_t* prefix, int prefix_size) { |
93 int len; | 94 int len; |
94 for (len = 0; IsAsciiAlphaOrAbove(); Next(), len++) { | 95 for (len = 0; IsAsciiAlphaOrAbove(); Next(), len++) { |
95 if (len < prefix_size) prefix[len] = AsciiAlphaToLower(ch_); | 96 if (len < prefix_size) prefix[len] = AsciiAlphaToLower(ch_); |
96 } | 97 } |
97 for (int i = len; i < prefix_size; i++) prefix[i] = 0; | 98 for (int i = len; i < prefix_size; i++) prefix[i] = 0; |
98 return len; | 99 return len; |
99 } | 100 } |
100 | 101 |
101 // The skip methods return whether they actually skipped something. | 102 // The skip methods return whether they actually skipped something. |
102 bool Skip(uint32_t c) { return ch_ == c ? (Next(), true) : false; } | 103 bool Skip(uint32_t c) { |
| 104 if (ch_ == c) { |
| 105 Next(); |
| 106 return true; |
| 107 } |
| 108 return false; |
| 109 } |
103 | 110 |
104 bool SkipWhiteSpace() { | 111 bool SkipWhiteSpace() { |
105 return Scanner::kIsWhiteSpace.get(ch_) ? (Next(), true) : false; | 112 if (ScannerConstants::kIsWhiteSpace.get(ch_)) { |
| 113 Next(); |
| 114 return true; |
| 115 } |
| 116 return false; |
106 } | 117 } |
107 | 118 |
108 bool SkipParentheses() { | 119 bool SkipParentheses() { |
109 if (ch_ != '(') return false; | 120 if (ch_ != '(') return false; |
110 int balance = 0; | 121 int balance = 0; |
111 do { | 122 do { |
112 if (ch_ == ')') --balance; | 123 if (ch_ == ')') --balance; |
113 else if (ch_ == '(') ++balance; | 124 else if (ch_ == '(') ++balance; |
114 Next(); | 125 Next(); |
115 } while (balance > 0 && ch_); | 126 } while (balance > 0 && ch_); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 int comp_[kSize]; | 242 int comp_[kSize]; |
232 int index_; | 243 int index_; |
233 int named_month_; | 244 int named_month_; |
234 }; | 245 }; |
235 }; | 246 }; |
236 | 247 |
237 | 248 |
238 } } // namespace v8::internal | 249 } } // namespace v8::internal |
239 | 250 |
240 #endif // V8_DATEPARSER_H_ | 251 #endif // V8_DATEPARSER_H_ |
OLD | NEW |