]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/rbbitblb.h
6 **********************************************************************
7 * Copyright (c) 2002-2016, International Business Machines
8 * Corporation and others. All Rights Reserved.
9 **********************************************************************
15 #include "unicode/utypes.h"
16 #include "unicode/uobject.h"
17 #include "unicode/rbbi.h"
23 class RBBIRuleScanner
;
24 class RBBIRuleBuilder
;
27 // class RBBITableBuilder is part of the RBBI rule compiler.
28 // It builds the state transition table used by the RBBI runtime
29 // from the expression syntax tree generated by the rule scanner.
31 // This class is part of the RBBI implementation only.
32 // There is no user-visible public API here.
35 class RBBITableBuilder
: public UMemory
{
37 RBBITableBuilder(RBBIRuleBuilder
*rb
, RBBINode
**rootNode
);
41 int32_t getTableSize() const; // Return the runtime size in bytes of
42 // the built state table
43 void exportTable(void *where
); // fill in the runtime state table.
44 // Sufficient memory must exist at
45 // the specified location.
49 void calcNullable(RBBINode
*n
);
50 void calcFirstPos(RBBINode
*n
);
51 void calcLastPos(RBBINode
*n
);
52 void calcFollowPos(RBBINode
*n
);
53 void calcChainedFollowPos(RBBINode
*n
);
55 void buildStateTable();
56 void flagAcceptingStates();
57 void flagLookAheadStates();
58 void flagTaggedStates();
59 void mergeRuleStatusVals();
61 void addRuleRootNodes(UVector
*dest
, RBBINode
*node
);
63 // Set functions for UVector.
64 // TODO: make a USet subclass of UVector
66 void setAdd(UVector
*dest
, UVector
*source
);
67 UBool
setEquals(UVector
*a
, UVector
*b
);
69 void sortedAdd(UVector
**dest
, int32_t val
);
73 void printSet(UVector
*s
);
74 void printPosSets(RBBINode
*n
/* = NULL*/);
76 void printRuleStatusTable();
79 #define printPosSets(n)
81 #define printRuleStatusTable()
86 RBBINode
*&fTree
; // The root node of the parse tree to build a
90 UVector
*fDStates
; // D states (Aho's terminology)
91 // Index is state number
92 // Contents are RBBIStateDescriptor pointers.
95 RBBITableBuilder(const RBBITableBuilder
&other
); // forbid copying of this class
96 RBBITableBuilder
&operator=(const RBBITableBuilder
&other
); // forbid copying of this class
100 // RBBIStateDescriptor - The DFA is constructed as a set of these descriptors,
101 // one for each state.
102 class RBBIStateDescriptor
: public UMemory
{
109 UVector
*fPositions
; // Set of parse tree positions associated
110 // with this state. Unordered (it's a set).
111 // UVector contents are RBBINode *
113 UVector
*fDtran
; // Transitions out of this state.
114 // indexed by input character
115 // contents is int index of dest state
116 // in RBBITableBuilder.fDStates
118 RBBIStateDescriptor(int maxInputSymbol
, UErrorCode
*fStatus
);
119 ~RBBIStateDescriptor();
122 RBBIStateDescriptor(const RBBIStateDescriptor
&other
); // forbid copying of this class
123 RBBIStateDescriptor
&operator=(const RBBIStateDescriptor
&other
); // forbid copying of this class