Esempio n. 1
0
        //----------------------------------------------------------------------------------------
        //
        //  compileRules          compile source rules, placing the compiled form into a output stream
        //                        The compiled form is identical to that from ICU4C (Big Endian).
        //
        //----------------------------------------------------------------------------------------
        internal static void CompileRules(string rules, Stream os)
        {
            //
            // Read the input rules, generate a parse tree, symbol table,
            // and list of all Unicode Sets referenced by the rules.
            //
            RBBIRuleBuilder builder = new RBBIRuleBuilder(rules);

            builder.fScanner.Parse();

            //
            // UnicodeSet processing.
            //    Munge the Unicode Sets to create a set of character categories.
            //    Generate the mapping tables (TRIE) from input 32-bit characters to
            //    the character categories.
            //
            builder.fSetBuilder.Build();

            //
            //   Generate the DFA state transition table.
            //
            builder.fForwardTables = new RBBITableBuilder(builder, fForwardTree);
            builder.fReverseTables = new RBBITableBuilder(builder, fReverseTree);
            builder.fSafeFwdTables = new RBBITableBuilder(builder, fSafeFwdTree);
            builder.fSafeRevTables = new RBBITableBuilder(builder, fSafeRevTree);
            builder.fForwardTables.Build();
            builder.fReverseTables.Build();
            builder.fSafeFwdTables.Build();
            builder.fSafeRevTables.Build();
            if (builder.fDebugEnv != null &&
                builder.fDebugEnv.IndexOf("states", StringComparison.Ordinal) >= 0)
            {
                builder.fForwardTables.PrintRuleStatusTable();
            }

            //
            //   Package up the compiled data, writing it to an output stream
            //      in the serialization format.  This is the same as the ICU4C runtime format.
            //
            builder.FlattenData(os);
        }
Esempio n. 2
0
 //------------------------------------------------------------------------
 //
 //       RBBISetBuilder Constructor
 //
 //------------------------------------------------------------------------
 internal RBBISetBuilder(RBBIRuleBuilder rb)
 {
     fRB = rb;
 }
Esempio n. 3
0
        private IList <RBBIStateDescriptor> fDStates; //  D states (Aho's terminology)
                                                      //  Index is state number
                                                      //  Contents are RBBIStateDescriptor pointers.

        //-----------------------------------------------------------------------------
        //
        //  Constructor    for RBBITableBuilder.
        //
        //                 rootNode is an index into the array of root nodes that is held by
        //                          the overall RBBIRuleBuilder.
        //-----------------------------------------------------------------------------
        internal RBBITableBuilder(RBBIRuleBuilder rb, int rootNodeIx)
        {
            fRootIx  = rootNodeIx;
            fRB      = rb;
            fDStates = new JCG.List <RBBIStateDescriptor>();
        }