]> git.saurik.com Git - apple/icu.git/blob - icuSources/common/rbbitblb57.h
ICU-66108.tar.gz
[apple/icu.git] / icuSources / common / rbbitblb57.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 * Copyright (c) 2002-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
8 *
9 **********************************************************************
10 * Legacy version of RBBITableBuilder from ICU 57,
11 * only for use by Apple RuleBasedTokenizer
12 **********************************************************************
13 */
14
15 #ifndef RBBITBLB57_H
16 #define RBBITBLB57_H
17
18 #include "unicode/utypes.h"
19 #include "unicode/uobject.h"
20 #include "uvectr32.h"
21 #include "rbbitblb.h"
22 #include "rbbi57.h"
23 #include "rbbinode.h"
24
25
26 U_NAMESPACE_BEGIN
27
28 class RBBIRuleScanner57;
29 class RBBIRuleBuilder57;
30 class UVector32;
31
32 //
33 // class RBBITableBuilder57 is part of the RBBI rule compiler.
34 // It builds the state transition table used by the RBBI runtime
35 // from the expression syntax tree generated by the rule scanner.
36 //
37 // This class is part of the RBBI implementation only.
38 // There is no user-visible public API here.
39 //
40
41 class RBBITableBuilder57 : public UMemory {
42 public:
43 RBBITableBuilder57(RBBIRuleBuilder57 *rb, RBBINode **rootNode);
44 ~RBBITableBuilder57();
45
46 void build();
47 int32_t getTableSize() const; // Return the runtime size in bytes of
48 // the built state table
49 void exportTable(void *where); // fill in the runtime state table.
50 // Sufficient memory must exist at
51 // the specified location.
52
53
54 private:
55 void calcNullable(RBBINode *n);
56 void calcFirstPos(RBBINode *n);
57 void calcLastPos(RBBINode *n);
58 void calcFollowPos(RBBINode *n);
59 void calcChainedFollowPos(RBBINode *n);
60 void bofFixup();
61 void buildStateTable();
62 void flagAcceptingStates();
63 void flagLookAheadStates();
64 void flagTaggedStates();
65 void mergeRuleStatusVals();
66
67 void addRuleRootNodes(UVector *dest, RBBINode *node);
68
69 // Set functions for UVector.
70 // TODO: make a USet subclass of UVector
71
72 void setAdd(UVector *dest, UVector *source);
73 UBool setEquals(UVector *a, UVector *b);
74
75 void sortedAdd(UVector **dest, int32_t val);
76
77 public:
78 #ifdef RBBI_DEBUG
79 void printSet(UVector *s);
80 void printPosSets(RBBINode *n /* = NULL*/);
81 void printStates();
82 void printRuleStatusTable();
83 #else
84 #define printSet(s)
85 #define printPosSets(n)
86 #define printStates()
87 #define printRuleStatusTable()
88 #endif
89
90 private:
91 RBBIRuleBuilder57 *fRB;
92 RBBINode *&fTree; // The root node of the parse tree to build a
93 // table for.
94 UErrorCode *fStatus;
95
96 UVector *fDStates; // D states (Aho's terminology)
97 // Index is state number
98 // Contents are RBBIStateDescriptor pointers.
99
100
101 RBBITableBuilder57(const RBBITableBuilder57 &other); // forbid copying of this class
102 RBBITableBuilder57 &operator=(const RBBITableBuilder57 &other); // forbid copying of this class
103 };
104
105 // class RBBIStateDescriptor - use standard rbbitblb.h
106
107
108 U_NAMESPACE_END
109 #endif