// ---------------------------------------------------------------------------------------- // // Constructor. // // ---------------------------------------------------------------------------------------- internal RBBIRuleScanner(RBBIRuleBuilder rb) { this.kStackSize = 100; this.fC = new RBBIRuleScanner.RBBIRuleChar (); this.fStack = new short[kStackSize]; this.fNodeStack = new RBBINode[kStackSize]; this.fSetTable = new Hashtable(); this.fRuleSets = new UnicodeSet[10]; fRB = rb; fLineNum = 1; // // Set up the constant Unicode Sets. // Note: These could be made static and shared among // all instances of RBBIRuleScanners. fRuleSets[IBM.ICU.Text.RBBIRuleParseTable.kRuleSet_rule_char - 128] = new UnicodeSet( gRuleSet_rule_char_pattern); fRuleSets[IBM.ICU.Text.RBBIRuleParseTable.kRuleSet_white_space - 128] = new UnicodeSet( gRuleSet_white_space_pattern); fRuleSets[IBM.ICU.Text.RBBIRuleParseTable.kRuleSet_name_char - 128] = new UnicodeSet( gRuleSet_name_char_pattern); fRuleSets[IBM.ICU.Text.RBBIRuleParseTable.kRuleSet_name_start_char - 128] = new UnicodeSet( gRuleSet_name_start_char_pattern); fRuleSets[IBM.ICU.Text.RBBIRuleParseTable.kRuleSet_digit_char - 128] = new UnicodeSet( gRuleSet_digit_char_pattern); fSymbolTable = new RBBISymbolTable(this, rb.fRules); }
// ---------------------------------------------------------------------------------------- // // compileRules compile source rules, placing the compiled form into a // output stream // The compiled form is identical to that from ICU4C (Big Endian). // // ---------------------------------------------------------------------------------------- static internal 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") >= 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); }
// ------------------------------------------------------------------------ // // RBBISetBuilder Constructor // // ------------------------------------------------------------------------ internal RBBISetBuilder(RBBIRuleBuilder rb) { this.dm = new RBBISetBuilder.RBBIDataManipulate(this); fRB = rb; }
private IList 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 ArrayList(); }