-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparser.h
More file actions
53 lines (48 loc) · 1.65 KB
/
parser.h
File metadata and controls
53 lines (48 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* License:
* This Source Code Form is subject to the terms of
* the Mozilla Public License, v. 2.0. If a copy of
* the MPL was not distributed with this file, You
* can obtain one at http://mozilla.org/MPL/2.0/.
*
* Authors:
* David Ellsworth <davide.by.zero@gmail.com>
*/
class ParsingStack
{
friend class RegexParser;
ParsingStack *below;
std::queue<RegexPattern*> alternatives;
std::queue<RegexSymbol*> symbols;
RegexGroup *group;
union
{
struct
{
Uint backrefIndexFirst;
Uint backrefIndexNext; // the next backrefIndex that a capturing group will get outside of this group
} BranchResetGroup;
};
};
class RegexParser
{
friend class Regex;
ParsingStack *stack;
RegexSymbol *symbol;
Uint backrefIndex; // zero-numbered; 0 corresponds to \1
Uint maxGroupDepth; // minimum is 1 (meaning, root group only)
Uint curGroupDepth;
Uint maxLookintoDepth;
Uint curLookintoDepth;
bool symbolCountSpecified;
bool symbolLazinessSpecified;
inline RegexSymbolType symbolWithLowercaseOpposite(RegexSymbolType neg, RegexSymbolType pos, char ch, char chNeg);
void addSymbol(const char *buf, RegexSymbol *symbol);
void fixLookaheadQuantifier();
static void skipWhitespace(const char *&buf);
void closeAlternative(RegexSymbol **&symbols, std::queue<RegexSymbol*> &symbolQueue);
void closeGroup(RegexPattern **&alternatives, std::queue<RegexPattern*> &patternQueue);
RegexGroup *parseLookinto(const char *&buf);
public:
RegexParser(RegexGroupRoot ®ex, const char *buf);
};