blob: 3ef2f91616904f79b577c4c5eb1558b83aff63b3 [file] [log] [blame]
ager@chromium.org9258b6b2008-09-11 09:11:10 +00001// Copyright 2006-2008 the V8 project authors. All rights reserved.
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27
28#ifndef V8_CHAR_PREDICATES_INL_H_
29#define V8_CHAR_PREDICATES_INL_H_
30
31#include "char-predicates.h"
32
33namespace v8 { namespace internal {
34
35
36inline bool IsCarriageReturn(uc32 c) {
37 return c == 0x000D;
38}
39
40
41inline bool IsLineFeed(uc32 c) {
42 return c == 0x000A;
43}
44
45
46inline bool IsDecimalDigit(uc32 c) {
47 // ECMA-262, 3rd, 7.8.3 (p 16)
48 return
49 '0' <= c && c <= '9';
50}
51
52
53inline bool IsHexDigit(uc32 c) {
54 // ECMA-262, 3rd, 7.6 (p 15)
55 return
56 ('0' <= c && c <= '9') ||
57 ('A' <= c && c <= 'F') ||
58 ('a' <= c && c <= 'f');
59}
60
61
ager@chromium.orga74f0da2008-12-03 16:05:52 +000062inline bool IsRegExpWord(uc16 c) {
63 return ('a' <= c && c <= 'z')
64 || ('A' <= c && c <= 'Z')
65 || ('0' <= c && c <= '9')
66 || (c == '_');
67}
68
69
70inline bool IsRegExpNewline(uc16 c) {
71 switch (c) {
72 // CR LF LS PS
73 case 0x000A: case 0x000D: case 0x2028: case 0x2029:
74 return false;
75 default:
76 return true;
77 }
78}
79
80
christian.plesner.hansen43d26ec2008-07-03 15:10:15 +000081} } // namespace v8::internal
82
83#endif // V8_CHAR_PREDICATES_INL_H_