]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/rbbitblb.h
6 **********************************************************************
7 * Copyright (c) 2002-2005, 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 // Set functions for UVector.
62 // TODO: make a USet subclass of UVector
64 void setAdd(UVector
*dest
, UVector
*source
);
65 UBool
setEquals(UVector
*a
, UVector
*b
);
67 void sortedAdd(UVector
**dest
, int32_t val
);
71 void printSet(UVector
*s
);
72 void printPosSets(RBBINode
*n
/* = NULL*/);
74 void printRuleStatusTable();
77 #define printPosSets(n)
79 #define printRuleStatusTable()
84 RBBINode
*&fTree
; // The root node of the parse tree to build a
88 UVector
*fDStates
; // D states (Aho's terminology)
89 // Index is state number
90 // Contents are RBBIStateDescriptor pointers.
93 RBBITableBuilder(const RBBITableBuilder
&other
); // forbid copying of this class
94 RBBITableBuilder
&operator=(const RBBITableBuilder
&other
); // forbid copying of this class
98 // RBBIStateDescriptor - The DFA is constructed as a set of these descriptors,
99 // one for each state.
100 class RBBIStateDescriptor
: public UMemory
{
107 UVector
*fPositions
; // Set of parse tree positions associated
108 // with this state. Unordered (it's a set).
109 // UVector contents are RBBINode *
111 UVector
*fDtran
; // Transitions out of this state.
112 // indexed by input character
113 // contents is int index of dest state
114 // in RBBITableBuilder.fDStates
116 RBBIStateDescriptor(int maxInputSymbol
, UErrorCode
*fStatus
);
117 ~RBBIStateDescriptor();
120 RBBIStateDescriptor(const RBBIStateDescriptor
&other
); // forbid copying of this class
121 RBBIStateDescriptor
&operator=(const RBBIStateDescriptor
&other
); // forbid copying of this class