|
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * vim: set ts=8 sts=4 et sw=4 tw=99: |
|
3 * |
|
4 * Copyright (C) 2009 Apple Inc. All rights reserved. |
|
5 * Copyright (C) 2010 Peter Varga (pvarga@inf.u-szeged.hu), University of Szeged |
|
6 * All rights reserved. |
|
7 * |
|
8 * Redistribution and use in source and binary forms, with or without |
|
9 * modification, are permitted provided that the following conditions |
|
10 * are met: |
|
11 * 1. Redistributions of source code must retain the above copyright |
|
12 * notice, this list of conditions and the following disclaimer. |
|
13 * 2. Redistributions in binary form must reproduce the above copyright |
|
14 * notice, this list of conditions and the following disclaimer in the |
|
15 * documentation and/or other materials provided with the distribution. |
|
16 * |
|
17 * THIS SOFTWARE IS PROVIDED BY UNIVERSITY OF SZEGED ``AS IS'' AND ANY |
|
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF SZEGED OR |
|
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
28 */ |
|
29 |
|
30 #ifndef yarr_Yarr_h |
|
31 #define yarr_Yarr_h |
|
32 |
|
33 #include <limits.h> |
|
34 #include "yarr/YarrInterpreter.h" |
|
35 #include "yarr/YarrPattern.h" |
|
36 |
|
37 namespace JSC { namespace Yarr { |
|
38 |
|
39 #define YarrStackSpaceForBackTrackInfoPatternCharacter 1 // Only for !fixed quantifiers. |
|
40 #define YarrStackSpaceForBackTrackInfoCharacterClass 1 // Only for !fixed quantifiers. |
|
41 #define YarrStackSpaceForBackTrackInfoBackReference 2 |
|
42 #define YarrStackSpaceForBackTrackInfoAlternative 1 // One per alternative. |
|
43 #define YarrStackSpaceForBackTrackInfoParentheticalAssertion 1 |
|
44 #define YarrStackSpaceForBackTrackInfoParenthesesOnce 1 // Only for !fixed quantifiers. |
|
45 #define YarrStackSpaceForBackTrackInfoParenthesesTerminal 1 |
|
46 #define YarrStackSpaceForBackTrackInfoParentheses 2 |
|
47 |
|
48 static const unsigned quantifyInfinite = UINT_MAX; |
|
49 static const unsigned offsetNoMatch = (unsigned)-1; |
|
50 static const unsigned offsetError = (unsigned)-2; |
|
51 |
|
52 // The below limit restricts the number of "recursive" match calls in order to |
|
53 // avoid spending exponential time on complex regular expressions. |
|
54 static const unsigned matchLimit = 2500000; |
|
55 |
|
56 enum JSRegExpResult { |
|
57 JSRegExpMatch = 1, |
|
58 JSRegExpNoMatch = 0, |
|
59 JSRegExpErrorNoMatch = -1, |
|
60 JSRegExpErrorHitLimit = -2, |
|
61 JSRegExpErrorNoMemory = -3, |
|
62 JSRegExpErrorInternal = -4 |
|
63 }; |
|
64 |
|
65 enum YarrCharSize { |
|
66 Char8, |
|
67 Char16 |
|
68 }; |
|
69 |
|
70 } } // namespace JSC::Yarr |
|
71 |
|
72 #endif /* yarr_Yarr_h */ |