1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//
2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//  regexcmp.h
3b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//
483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius//  Copyright (C) 2002-2012, International Business Machines Corporation and others.
5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//  All Rights Reserved.
6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//
7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//  This file contains declarations for the class RegexCompile
8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//
9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//  This class is internal to the regular expression implementation.
10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//  For the public Regular Expression API, see the file "unicode/regex.h"
11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//
12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef RBBISCAN_H
15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define RBBISCAN_H
16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h"
18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_REGULAR_EXPRESSIONS
19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/uobject.h"
21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/uniset.h"
22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/parseerr.h"
23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uhash.h"
24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "uvector.h"
25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_BEGIN
29b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
31b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//--------------------------------------------------------------------------------
32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//
33b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//  class RegexCompile    Contains the regular expression compiler.
34b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//
35b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru//--------------------------------------------------------------------------------
36b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustruct  RegexTableEl;
37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass   RegexPattern;
38b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
39b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
40b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruclass RegexCompile : public UMemory {
41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querupublic:
42b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
43c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    enum {
44c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru        kStackSize = 100            // The size of the state stack for
45c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    };                              //   pattern parsing.  Corresponds roughly
46c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                                    //   to the depth of parentheses nesting
47c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                                    //   that is allowed in the rules.
48c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    struct RegexPatternChar {
50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UChar32             fChar;
51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        UBool               fQuoted;
52b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    RegexCompile(RegexPattern *rp, UErrorCode &e);
55c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void       compile(const UnicodeString &pat, UParseError &pp, UErrorCode &e);
5750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    void       compile(UText *pat, UParseError &pp, UErrorCode &e);
5850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
59b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
60b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    virtual    ~RegexCompile();
61b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
62b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void        nextChar(RegexPatternChar &c);      // Get the next char from the input stream.
63b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
64b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    static void cleanup();                       // Memory cleanup
65b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
66b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
67b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
68b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    // Categories of parentheses in pattern.
69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //   The category is saved in the compile-time parentheses stack frame, and
70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //   determines the code to be generated when the matching close ) is encountered.
71b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    enum EParenClass {
72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        plain        = -1,               // No special handling
73c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru        capturing    = -2,
74b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        atomic       = -3,
75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        lookAhead    = -4,
76b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        negLookAhead = -5,
77b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        flags        = -6,
78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        lookBehind   = -7,
79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru        lookBehindN  = -8
80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    };
81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruprivate:
83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool       doParseActions(int32_t a);
86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void        error(UErrorCode e);                   // error reporting convenience function.
87b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UChar32     nextCharLL();
89b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UChar32     peekCharLL();
90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UnicodeSet  *scanProp();
91c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UnicodeSet  *scanPosixProp();
92b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void        handleCloseParen();
93b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t     blockTopLoc(UBool reserve);          // Locate a position in the compiled pattern
94b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //  at the top of the just completed block
95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //  or operation, and optionally ensure that
96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //  there is space to add an opcode there.
97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void        compileSet(UnicodeSet *theSet);      // Generate the compiled pattern for
98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   a reference to a UnicodeSet.
99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void        compileInterval(int32_t InitOp,      // Generate the code for a {min,max} quantifier.
100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                               int32_t LoopOp);
101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool       compileInlineInterval();             // Generate inline code for a {min,max} quantifier
102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void        literalChar(UChar32 c);              // Compile a literal char
10383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    void        fixLiterals(UBool split=FALSE);      // Generate code for pending literal characters.
104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void        insertOp(int32_t where);             // Open up a slot for a new op in the
105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   generated code at the specified location.
106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t     minMatchLength(int32_t start,
107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                               int32_t end);
108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t     maxMatchLength(int32_t start,
109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                               int32_t end);
110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void        matchStartType();
111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    void        stripNOPs();
112c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
113c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    void        setEval(int32_t op);
114c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    void        setPushOp(int32_t op);
115c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UChar32     scanNamedChar();
116c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UnicodeSet *createSetForProperty(const UnicodeString &propName, UBool negated);
117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UErrorCode                    *fStatus;
120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    RegexPattern                  *fRXPat;
121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UParseError                   *fParseErr;
122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //
124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //  Data associated with low level character scanning
125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //
12650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    int64_t                       fScanIndex;        // Index of current character being processed
127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   in the rule input string.
128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool                         fQuoteMode;        // Scan is in a \Q...\E quoted region
129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool                         fInBackslashQuote; // Scan is between a '\' and the following char.
130c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UBool                         fEOLComments;      // When scan is just after '(?',  inhibit #... to
131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   end of line comments, in favor of (?#...) comments.
13250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    int64_t                       fLineNum;          // Line number in input file.
13350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    int64_t                       fCharNum;          // Char position within the line.
134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UChar32                       fLastChar;         // Previous char, needed to count CR-LF
135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   as a single line, not two.
136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UChar32                       fPeekChar;         // Saved char, if we've scanned ahead.
137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    RegexPatternChar              fC;                // Current char for parse state machine
140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   processing.
141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //
143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //   Data for the state machine that parses the regular expression.
144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //
145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    RegexTableEl                  **fStateTable;     // State Transition Table for regex Rule
146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   parsing.  index by p[state][char-class]
147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    uint16_t                      fStack[kStackSize];  // State stack, holds state pushes
149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t                       fStackPtr;           //  and pops as specified in the state
150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                       //  transition rules.
151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //
153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //  Data associated with the generation of the pcode for the match engine
154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    //
155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t                       fModeFlags;        // Match Flags.  (Case Insensitive, etc.)
156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   Always has high bit (31) set so that flag values
157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   on the paren stack are distinguished from relocatable
158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   pcode addresses.
159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t                       fNewModeFlags;     // New flags, while compiling (?i, holds state
160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   until last flag is scanned.
161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UBool                         fSetModeFlag;      // true for (?ismx, false for (?-ismx
162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
16383a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius    UnicodeString                 fLiteralChars;     // Literal chars or strings from the pattern are accumulated here.
16483a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius                                                     //   Once completed, meaning that some non-literal pattern
16583a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius                                                     //   construct is encountered, the appropriate opcodes
16683a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius                                                     //   to match the literal will be generated, and this
16783a171d1a62abf406f7f44ae671823d5ec20db7dCraig Cornelius                                                     //   string will be cleared.
168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
16950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    int64_t                       fPatternLength;    // Length of the input pattern string.
17050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho
171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    UVector32                     fParenStack;       // parentheses stack.  Each frame consists of
172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   the positions of compiled pattern operations
173c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                                                     //   needing fixup, followed by negative value.  The
174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   first entry in each frame is the position of the
175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   spot reserved for use when a quantifier
176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   needs to add a SAVE at the start of a (block)
177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   The negative value (-1, -2,...) indicates
178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   the kind of paren that opened the frame.  Some
179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   need special handling on close.
180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t                       fMatchOpenParen;   // The position in the compiled pattern
183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   of the slot reserved for a state save
184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   at the start of the most recently processed
185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   parenthesized block.
186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t                       fMatchCloseParen;  // The position in the pattern of the first
187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   location after the most recently processed
188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   parenthesized block.
189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t                       fIntervalLow;      // {lower, upper} interval quantifier values.
191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru    int32_t                       fIntervalUpper;    // Placed here temporarily, when pattern is
192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   initially scanned.  Each new interval
193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   encountered overwrites these values.
194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   -1 for the upper interval value means none
195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   was specified (unlimited occurences.)
196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
19750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho    int64_t                       fNameStartPos;     // Starting position of a \N{NAME} name in a
198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   pattern, valid while remainder of name is
199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                                                     //   scanned.
200c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
201c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UStack                        fSetStack;         // Stack of UnicodeSets, used while evaluating
202c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                                                     //   (at compile time) set expressions within
203c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                                                     //   the pattern.
204c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UStack                        fSetOpStack;       // Stack of pending set operators (&&, --, union)
205c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
206c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    UChar32                       fLastSetLiteral;   // The last single code point added to a set.
207c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                                                     //   needed when "-y" is scanned, and we need
208c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru                                                     //   to turn "x-y" into a range.
209b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru};
210b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
211c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru// Constant values to be pushed onto fSetOpStack while scanning & evalueating [set expressions]
212c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru//   The high 16 bits are the operator precedence, and the low 16 are a code for the operation itself.
213c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
214c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queruenum SetOperations {
215c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    setStart         = 0 << 16 | 1,
216c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    setEnd           = 1 << 16 | 2,
217c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    setNegation      = 2 << 16 | 3,
218c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    setCaseClose     = 2 << 16 | 9,
219c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    setDifference2   = 3 << 16 | 4,    // '--' set difference operator
220c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    setIntersection2 = 3 << 16 | 5,    // '&&' set intersection operator
221c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    setUnion         = 4 << 16 | 6,    // implicit union of adjacent items
222c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    setDifference1   = 4 << 16 | 7,    // '-', single dash difference op, for compatibility with old UnicodeSet.
223c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    setIntersection1 = 4 << 16 | 8     // '&', single amp intersection op, for compatibility with old UnicodeSet.
224c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru    };
225c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste Queru
226b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_NAMESPACE_END
227b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif   // !UCONFIG_NO_REGULAR_EXPRESSIONS
228b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif   // RBBISCAN_H
229