intl/icu/source/common/rbbinode.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/rbbinode.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,118 @@
     1.4 +/********************************************************************
     1.5 + * COPYRIGHT:
     1.6 + * Copyright (c) 2001-2006, International Business Machines Corporation and
     1.7 + * others. All Rights Reserved.
     1.8 + ********************************************************************/
     1.9 +
    1.10 +#ifndef RBBINODE_H
    1.11 +#define RBBINODE_H
    1.12 +
    1.13 +#include "unicode/utypes.h"
    1.14 +#include "unicode/uobject.h"
    1.15 +
    1.16 +//
    1.17 +//  class RBBINode
    1.18 +//
    1.19 +//                    Represents a node in the parse tree generated when reading
    1.20 +//                    a rule file.
    1.21 +//
    1.22 +
    1.23 +U_NAMESPACE_BEGIN
    1.24 +
    1.25 +class    UnicodeSet;
    1.26 +class    UVector;
    1.27 +
    1.28 +class RBBINode : public UMemory {
    1.29 +    public:
    1.30 +        enum NodeType {
    1.31 +            setRef,
    1.32 +            uset,
    1.33 +            varRef,
    1.34 +            leafChar,
    1.35 +            lookAhead,
    1.36 +            tag,
    1.37 +            endMark,
    1.38 +            opStart,
    1.39 +            opCat,
    1.40 +            opOr,
    1.41 +            opStar,
    1.42 +            opPlus,
    1.43 +            opQuestion,
    1.44 +            opBreak,
    1.45 +            opReverse,
    1.46 +            opLParen
    1.47 +        };
    1.48 +
    1.49 +        enum OpPrecedence {      
    1.50 +            precZero,
    1.51 +            precStart,
    1.52 +            precLParen,
    1.53 +            precOpOr,
    1.54 +            precOpCat
    1.55 +        };
    1.56 +            
    1.57 +        NodeType      fType;
    1.58 +        RBBINode      *fParent;
    1.59 +        RBBINode      *fLeftChild;
    1.60 +        RBBINode      *fRightChild;
    1.61 +        UnicodeSet    *fInputSet;           // For uset nodes only.
    1.62 +        OpPrecedence  fPrecedence;          // For binary ops only.
    1.63 +        
    1.64 +        UnicodeString fText;                // Text corresponding to this node.
    1.65 +                                            //   May be lazily evaluated when (if) needed
    1.66 +                                            //   for some node types.
    1.67 +        int           fFirstPos;            // Position in the rule source string of the
    1.68 +                                            //   first text associated with the node.
    1.69 +                                            //   If there's a left child, this will be the same
    1.70 +                                            //   as that child's left pos.
    1.71 +        int           fLastPos;             //  Last position in the rule source string
    1.72 +                                            //    of any text associated with this node.
    1.73 +                                            //    If there's a right child, this will be the same
    1.74 +                                            //    as that child's last postion.
    1.75 +
    1.76 +        UBool         fNullable;            // See Aho.
    1.77 +        int32_t       fVal;                 // For leafChar nodes, the value.
    1.78 +                                            //   Values are the character category,
    1.79 +                                            //   corresponds to columns in the final
    1.80 +                                            //   state transition table.
    1.81 +
    1.82 +        UBool         fLookAheadEnd;        // For endMark nodes, set TRUE if
    1.83 +                                            //   marking the end of a look-ahead rule.
    1.84 +
    1.85 +        UVector       *fFirstPosSet;
    1.86 +        UVector       *fLastPosSet;         // TODO: rename fFirstPos & fLastPos to avoid confusion.
    1.87 +        UVector       *fFollowPos;
    1.88 +
    1.89 +
    1.90 +        RBBINode(NodeType t);
    1.91 +        RBBINode(const RBBINode &other);
    1.92 +        ~RBBINode();
    1.93 +        
    1.94 +        RBBINode    *cloneTree();
    1.95 +        RBBINode    *flattenVariables();
    1.96 +        void         flattenSets();
    1.97 +        void         findNodes(UVector *dest, RBBINode::NodeType kind, UErrorCode &status);
    1.98 +
    1.99 +#ifdef RBBI_DEBUG
   1.100 +        void        printNode();
   1.101 +        void        printTree(UBool withHeading);
   1.102 +#endif
   1.103 +
   1.104 +    private:
   1.105 +        RBBINode &operator = (const RBBINode &other); // No defs.
   1.106 +        UBool operator == (const RBBINode &other);    // Private, so these functions won't accidently be used.
   1.107 +
   1.108 +#ifdef RBBI_DEBUG
   1.109 +        int           fSerialNum;           //  Debugging aids.
   1.110 +#endif
   1.111 +};
   1.112 +
   1.113 +#ifdef RBBI_DEBUG
   1.114 +U_CFUNC void 
   1.115 +RBBI_DEBUG_printUnicodeString(const UnicodeString &s, int minWidth=0);
   1.116 +#endif
   1.117 +
   1.118 +U_NAMESPACE_END
   1.119 +
   1.120 +#endif
   1.121 +

mercurial