intl/icu/source/common/rbbitblb.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/rbbitblb.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,127 @@
     1.4 +//
     1.5 +//  rbbitblb.h
     1.6 +//
     1.7 +
     1.8 +/*
     1.9 +**********************************************************************
    1.10 +*   Copyright (c) 2002-2005, International Business Machines
    1.11 +*   Corporation and others.  All Rights Reserved.
    1.12 +**********************************************************************
    1.13 +*/
    1.14 +
    1.15 +#ifndef RBBITBLB_H
    1.16 +#define RBBITBLB_H
    1.17 +
    1.18 +#include "unicode/utypes.h"
    1.19 +#include "unicode/uobject.h"
    1.20 +#include "unicode/rbbi.h"
    1.21 +#include "rbbinode.h"
    1.22 +
    1.23 +
    1.24 +U_NAMESPACE_BEGIN
    1.25 +
    1.26 +class RBBIRuleScanner;
    1.27 +class RBBIRuleBuilder;
    1.28 +
    1.29 +//
    1.30 +//  class RBBITableBuilder is part of the RBBI rule compiler.
    1.31 +//                         It builds the state transition table used by the RBBI runtime
    1.32 +//                         from the expression syntax tree generated by the rule scanner.
    1.33 +//
    1.34 +//                         This class is part of the RBBI implementation only.
    1.35 +//                         There is no user-visible public API here.
    1.36 +//
    1.37 +
    1.38 +class RBBITableBuilder : public UMemory {
    1.39 +public:
    1.40 +    RBBITableBuilder(RBBIRuleBuilder *rb, RBBINode **rootNode);
    1.41 +    ~RBBITableBuilder();
    1.42 +
    1.43 +    void     build();
    1.44 +    int32_t  getTableSize() const;      // Return the runtime size in bytes of
    1.45 +                                        //     the built state table
    1.46 +    void     exportTable(void *where);  // fill in the runtime state table.
    1.47 +                                        //     Sufficient memory must exist at
    1.48 +                                        //     the specified location.
    1.49 +
    1.50 +
    1.51 +private:
    1.52 +    void     calcNullable(RBBINode *n);
    1.53 +    void     calcFirstPos(RBBINode *n);
    1.54 +    void     calcLastPos(RBBINode  *n);
    1.55 +    void     calcFollowPos(RBBINode *n);
    1.56 +    void     calcChainedFollowPos(RBBINode *n);
    1.57 +    void     bofFixup();
    1.58 +    void     buildStateTable();
    1.59 +    void     flagAcceptingStates();
    1.60 +    void     flagLookAheadStates();
    1.61 +    void     flagTaggedStates();
    1.62 +    void     mergeRuleStatusVals();
    1.63 +
    1.64 +    // Set functions for UVector.
    1.65 +    //   TODO:  make a USet subclass of UVector
    1.66 +
    1.67 +    void     setAdd(UVector *dest, UVector *source);
    1.68 +    UBool    setEquals(UVector *a, UVector *b);
    1.69 +
    1.70 +    void     sortedAdd(UVector **dest, int32_t val);
    1.71 +
    1.72 +public:
    1.73 +#ifdef RBBI_DEBUG
    1.74 +    void     printSet(UVector *s);
    1.75 +    void     printPosSets(RBBINode *n /* = NULL*/);
    1.76 +    void     printStates();
    1.77 +    void     printRuleStatusTable();
    1.78 +#else
    1.79 +    #define  printSet(s)
    1.80 +    #define  printPosSets(n)
    1.81 +    #define  printStates()
    1.82 +    #define  printRuleStatusTable()
    1.83 +#endif
    1.84 +
    1.85 +private:
    1.86 +    RBBIRuleBuilder  *fRB;
    1.87 +    RBBINode         *&fTree;              // The root node of the parse tree to build a
    1.88 +                                           //   table for.
    1.89 +    UErrorCode       *fStatus;
    1.90 +
    1.91 +    UVector          *fDStates;            //  D states (Aho's terminology)
    1.92 +                                           //  Index is state number
    1.93 +                                           //  Contents are RBBIStateDescriptor pointers.
    1.94 +
    1.95 +
    1.96 +    RBBITableBuilder(const RBBITableBuilder &other); // forbid copying of this class
    1.97 +    RBBITableBuilder &operator=(const RBBITableBuilder &other); // forbid copying of this class
    1.98 +};
    1.99 +
   1.100 +//
   1.101 +//  RBBIStateDescriptor - The DFA is constructed as a set of these descriptors,
   1.102 +//                        one for each state.
   1.103 +class RBBIStateDescriptor : public UMemory {
   1.104 +public:
   1.105 +    UBool            fMarked;
   1.106 +    int32_t          fAccepting;
   1.107 +    int32_t          fLookAhead;
   1.108 +    UVector          *fTagVals;
   1.109 +    int32_t          fTagsIdx;
   1.110 +    UVector          *fPositions;          // Set of parse tree positions associated
   1.111 +                                           //   with this state.  Unordered (it's a set).
   1.112 +                                           //   UVector contents are RBBINode *
   1.113 +
   1.114 +    UVector          *fDtran;              // Transitions out of this state.
   1.115 +                                           //   indexed by input character
   1.116 +                                           //   contents is int index of dest state
   1.117 +                                           //   in RBBITableBuilder.fDStates
   1.118 +
   1.119 +    RBBIStateDescriptor(int maxInputSymbol,  UErrorCode *fStatus);
   1.120 +    ~RBBIStateDescriptor();
   1.121 +
   1.122 +private:
   1.123 +    RBBIStateDescriptor(const RBBIStateDescriptor &other); // forbid copying of this class
   1.124 +    RBBIStateDescriptor &operator=(const RBBIStateDescriptor &other); // forbid copying of this class
   1.125 +};
   1.126 +
   1.127 +
   1.128 +
   1.129 +U_NAMESPACE_END
   1.130 +#endif

mercurial