intl/icu/source/common/rbbinode.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /********************************************************************
michael@0 2 * COPYRIGHT:
michael@0 3 * Copyright (c) 2001-2006, International Business Machines Corporation and
michael@0 4 * others. All Rights Reserved.
michael@0 5 ********************************************************************/
michael@0 6
michael@0 7 #ifndef RBBINODE_H
michael@0 8 #define RBBINODE_H
michael@0 9
michael@0 10 #include "unicode/utypes.h"
michael@0 11 #include "unicode/uobject.h"
michael@0 12
michael@0 13 //
michael@0 14 // class RBBINode
michael@0 15 //
michael@0 16 // Represents a node in the parse tree generated when reading
michael@0 17 // a rule file.
michael@0 18 //
michael@0 19
michael@0 20 U_NAMESPACE_BEGIN
michael@0 21
michael@0 22 class UnicodeSet;
michael@0 23 class UVector;
michael@0 24
michael@0 25 class RBBINode : public UMemory {
michael@0 26 public:
michael@0 27 enum NodeType {
michael@0 28 setRef,
michael@0 29 uset,
michael@0 30 varRef,
michael@0 31 leafChar,
michael@0 32 lookAhead,
michael@0 33 tag,
michael@0 34 endMark,
michael@0 35 opStart,
michael@0 36 opCat,
michael@0 37 opOr,
michael@0 38 opStar,
michael@0 39 opPlus,
michael@0 40 opQuestion,
michael@0 41 opBreak,
michael@0 42 opReverse,
michael@0 43 opLParen
michael@0 44 };
michael@0 45
michael@0 46 enum OpPrecedence {
michael@0 47 precZero,
michael@0 48 precStart,
michael@0 49 precLParen,
michael@0 50 precOpOr,
michael@0 51 precOpCat
michael@0 52 };
michael@0 53
michael@0 54 NodeType fType;
michael@0 55 RBBINode *fParent;
michael@0 56 RBBINode *fLeftChild;
michael@0 57 RBBINode *fRightChild;
michael@0 58 UnicodeSet *fInputSet; // For uset nodes only.
michael@0 59 OpPrecedence fPrecedence; // For binary ops only.
michael@0 60
michael@0 61 UnicodeString fText; // Text corresponding to this node.
michael@0 62 // May be lazily evaluated when (if) needed
michael@0 63 // for some node types.
michael@0 64 int fFirstPos; // Position in the rule source string of the
michael@0 65 // first text associated with the node.
michael@0 66 // If there's a left child, this will be the same
michael@0 67 // as that child's left pos.
michael@0 68 int fLastPos; // Last position in the rule source string
michael@0 69 // of any text associated with this node.
michael@0 70 // If there's a right child, this will be the same
michael@0 71 // as that child's last postion.
michael@0 72
michael@0 73 UBool fNullable; // See Aho.
michael@0 74 int32_t fVal; // For leafChar nodes, the value.
michael@0 75 // Values are the character category,
michael@0 76 // corresponds to columns in the final
michael@0 77 // state transition table.
michael@0 78
michael@0 79 UBool fLookAheadEnd; // For endMark nodes, set TRUE if
michael@0 80 // marking the end of a look-ahead rule.
michael@0 81
michael@0 82 UVector *fFirstPosSet;
michael@0 83 UVector *fLastPosSet; // TODO: rename fFirstPos & fLastPos to avoid confusion.
michael@0 84 UVector *fFollowPos;
michael@0 85
michael@0 86
michael@0 87 RBBINode(NodeType t);
michael@0 88 RBBINode(const RBBINode &other);
michael@0 89 ~RBBINode();
michael@0 90
michael@0 91 RBBINode *cloneTree();
michael@0 92 RBBINode *flattenVariables();
michael@0 93 void flattenSets();
michael@0 94 void findNodes(UVector *dest, RBBINode::NodeType kind, UErrorCode &status);
michael@0 95
michael@0 96 #ifdef RBBI_DEBUG
michael@0 97 void printNode();
michael@0 98 void printTree(UBool withHeading);
michael@0 99 #endif
michael@0 100
michael@0 101 private:
michael@0 102 RBBINode &operator = (const RBBINode &other); // No defs.
michael@0 103 UBool operator == (const RBBINode &other); // Private, so these functions won't accidently be used.
michael@0 104
michael@0 105 #ifdef RBBI_DEBUG
michael@0 106 int fSerialNum; // Debugging aids.
michael@0 107 #endif
michael@0 108 };
michael@0 109
michael@0 110 #ifdef RBBI_DEBUG
michael@0 111 U_CFUNC void
michael@0 112 RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth=0);
michael@0 113 #endif
michael@0 114
michael@0 115 U_NAMESPACE_END
michael@0 116
michael@0 117 #endif
michael@0 118

mercurial