OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_CHAR_PREDICATES_INL_H_ | 5 #ifndef V8_CHAR_PREDICATES_INL_H_ |
6 #define V8_CHAR_PREDICATES_INL_H_ | 6 #define V8_CHAR_PREDICATES_INL_H_ |
7 | 7 |
8 #include "src/char-predicates.h" | 8 #include "src/char-predicates.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 17 matching lines...) Expand all Loading... |
28 return c == 0x000A; | 28 return c == 0x000A; |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 inline bool IsInRange(int value, int lower_limit, int higher_limit) { | 32 inline bool IsInRange(int value, int lower_limit, int higher_limit) { |
33 DCHECK(lower_limit <= higher_limit); | 33 DCHECK(lower_limit <= higher_limit); |
34 return static_cast<unsigned int>(value - lower_limit) <= | 34 return static_cast<unsigned int>(value - lower_limit) <= |
35 static_cast<unsigned int>(higher_limit - lower_limit); | 35 static_cast<unsigned int>(higher_limit - lower_limit); |
36 } | 36 } |
37 | 37 |
| 38 inline bool IsAsciiIdentifier(uc32 c) { |
| 39 return IsAlphaNumeric(c) || c == '$' || c == '_'; |
| 40 } |
| 41 |
| 42 inline bool IsAlphaNumeric(uc32 c) { |
| 43 return IsInRange(AsciiAlphaToLower(c), 'a', 'z') || IsDecimalDigit(c); |
| 44 } |
38 | 45 |
39 inline bool IsDecimalDigit(uc32 c) { | 46 inline bool IsDecimalDigit(uc32 c) { |
40 // ECMA-262, 3rd, 7.8.3 (p 16) | 47 // ECMA-262, 3rd, 7.8.3 (p 16) |
41 return IsInRange(c, '0', '9'); | 48 return IsInRange(c, '0', '9'); |
42 } | 49 } |
43 | 50 |
44 | 51 |
45 inline bool IsHexDigit(uc32 c) { | 52 inline bool IsHexDigit(uc32 c) { |
46 // ECMA-262, 3rd, 7.6 (p 15) | 53 // ECMA-262, 3rd, 7.6 (p 15) |
47 return IsDecimalDigit(c) || IsInRange(AsciiAlphaToLower(c), 'a', 'f'); | 54 return IsDecimalDigit(c) || IsInRange(AsciiAlphaToLower(c), 'a', 'f'); |
(...skipping 26 matching lines...) Expand all Loading... |
74 return false; | 81 return false; |
75 default: | 82 default: |
76 return true; | 83 return true; |
77 } | 84 } |
78 } | 85 } |
79 | 86 |
80 | 87 |
81 } } // namespace v8::internal | 88 } } // namespace v8::internal |
82 | 89 |
83 #endif // V8_CHAR_PREDICATES_INL_H_ | 90 #endif // V8_CHAR_PREDICATES_INL_H_ |
OLD | NEW |