1 7 8 package com.ibm.icu.text; 9 10 import java.util.HashMap ; 11 import java.lang.IllegalArgumentException ; 12 import java.text.ParsePosition ; 13 14 import com.ibm.icu.lang.UCharacter; 15 import com.ibm.icu.impl.Assert; 16 import com.ibm.icu.impl.Utility; 17 18 24 class RBBIRuleScanner { 25 26 private final int kStackSize = 100; 31 static class RBBIRuleChar { 32 int fChar; 33 boolean fEscaped; 34 } 35 36 37 38 RBBIRuleBuilder fRB; 40 int fScanIndex; int fNextIndex; boolean fQuoteMode; int fLineNum; int fCharNum; int fLastChar; 50 RBBIRuleChar fC = new RBBIRuleChar(); String fVarName; 55 56 short fStack[] = new short[kStackSize]; int fStackPtr; 60 RBBINode fNodeStack[] = new RBBINode[kStackSize]; int fNodeStackPtr; 63 64 65 boolean fReverseRule; 69 boolean fLookAheadRule; 72 RBBISymbolTable fSymbolTable; 75 HashMap fSetTable = new HashMap (); 80 UnicodeSet fRuleSets[] = new UnicodeSet[10]; 86 int fRuleNum; 88 int fOptionStart; 91 92 93 static private String gRuleSet_rule_char_pattern = "[^[\\p{Z}\\u0020-\\u007f]-[\\p{L}]-[\\p{N}]]"; 94 static private String gRuleSet_name_char_pattern = "[_\\p{L}\\p{N}]"; 95 static private String gRuleSet_digit_char_pattern = "[0-9]"; 96 static private String gRuleSet_name_start_char_pattern = "[_\\p{L}]"; 97 static private String gRuleSet_white_space_pattern = "[\\p{Pattern_White_Space}]"; 98 static private String kAny = "any"; 99 100 101 102 103 RBBIRuleScanner(RBBIRuleBuilder rb) 109 { 110 fRB = rb; 111 fLineNum = 1; 112 113 fRuleSets[RBBIRuleParseTable.kRuleSet_rule_char-128] = new UnicodeSet(gRuleSet_rule_char_pattern); 118 fRuleSets[RBBIRuleParseTable.kRuleSet_white_space-128] = new UnicodeSet(gRuleSet_white_space_pattern); 119 fRuleSets[RBBIRuleParseTable.kRuleSet_name_char-128] = new UnicodeSet(gRuleSet_name_char_pattern); 120 fRuleSets[RBBIRuleParseTable.kRuleSet_name_start_char-128] = new UnicodeSet(gRuleSet_name_start_char_pattern); 121 fRuleSets[RBBIRuleParseTable.kRuleSet_digit_char-128] = new UnicodeSet(gRuleSet_digit_char_pattern); 122 123 fSymbolTable = new RBBISymbolTable(this, rb.fRules); 124 } 125 126 127 128 129 boolean doParseActions(int action) 138 { 139 RBBINode n = null; 140 141 boolean returnVal = true; 142 143 switch (action) { 144 145 case RBBIRuleParseTable.doExprStart: 146 pushNewNode(RBBINode.opStart); 147 fRuleNum++; 148 break; 149 150 151 case RBBIRuleParseTable.doExprOrOperator: 152 { 153 fixOpStack(RBBINode.precOpCat); 154 RBBINode operandNode = fNodeStack[fNodeStackPtr--]; 155 RBBINode orNode = pushNewNode(RBBINode.opOr); 156 orNode.fLeftChild = operandNode; 157 operandNode.fParent = orNode; 158 } 159 break; 160 161 case RBBIRuleParseTable.doExprCatOperator: 162 { 167 fixOpStack(RBBINode.precOpCat); 168 RBBINode operandNode = fNodeStack[fNodeStackPtr--]; 169 RBBINode catNode = pushNewNode(RBBINode.opCat); 170 catNode.fLeftChild = operandNode; 171 operandNode.fParent = catNode; 172 } 173 break; 174 175 case RBBIRuleParseTable.doLParen: 176 pushNewNode(RBBINode.opLParen); 182 break; 183 184 case RBBIRuleParseTable.doExprRParen: 185 fixOpStack(RBBINode.precLParen); 186 break; 187 188 case RBBIRuleParseTable.doNOP: 189 break; 190 191 case RBBIRuleParseTable.doStartAssign: 192 195 n = fNodeStack[fNodeStackPtr-1]; 200 n.fFirstPos = fNextIndex; 202 pushNewNode(RBBINode.opStart); 205 break; 206 207 208 209 210 case RBBIRuleParseTable.doEndAssign: 211 { 212 215 fixOpStack(RBBINode.precStart); 217 218 RBBINode startExprNode = fNodeStack[fNodeStackPtr-2]; 219 RBBINode varRefNode = fNodeStack[fNodeStackPtr-1]; 220 RBBINode RHSExprNode = fNodeStack[fNodeStackPtr]; 221 222 RHSExprNode.fFirstPos = startExprNode.fFirstPos; 225 RHSExprNode.fLastPos = fScanIndex; 226 RHSExprNode.fText = fRB.fRules.substring(RHSExprNode.fFirstPos, RHSExprNode.fLastPos); 228 229 varRefNode.fLeftChild = RHSExprNode; 231 RHSExprNode.fParent = varRefNode; 232 233 fSymbolTable.addEntry(varRefNode.fText, varRefNode); 235 236 fNodeStackPtr-=3; 238 break; 239 } 240 241 case RBBIRuleParseTable.doEndOfRule: 242 { 243 fixOpStack(RBBINode.precStart); 245 if (fRB.fDebugEnv!=null && fRB.fDebugEnv.indexOf("rtree") >= 0) {printNodeStack("end of rule");} 246 Assert.assrt(fNodeStackPtr == 1); 247 248 if (fLookAheadRule) { 251 RBBINode thisRule = fNodeStack[fNodeStackPtr]; 252 RBBINode endNode = pushNewNode(RBBINode.endMark); 253 RBBINode catNode = pushNewNode(RBBINode.opCat); 254 fNodeStackPtr -= 2; 255 catNode.fLeftChild = thisRule; 256 catNode.fRightChild = endNode; 257 fNodeStack[fNodeStackPtr] = catNode; 258 endNode.fVal = fRuleNum; 259 endNode.fLookAheadEnd = true; 260 } 261 262 271 int destRules = (fReverseRule? fRB.fReverseTree : fRB.fDefaultTree); 272 273 if (fRB.fTreeRoots[destRules] != null) { 274 RBBINode thisRule = fNodeStack[fNodeStackPtr]; 280 RBBINode prevRules = fRB.fTreeRoots[destRules]; 281 RBBINode orNode = pushNewNode(RBBINode.opOr); 282 orNode.fLeftChild = prevRules; 283 prevRules.fParent = orNode; 284 orNode.fRightChild = thisRule; 285 thisRule.fParent = orNode; 286 fRB.fTreeRoots[destRules] = orNode; 287 } 288 else 289 { 290 fRB.fTreeRoots[destRules] = fNodeStack[fNodeStackPtr]; 293 } 294 fReverseRule = false; fLookAheadRule = false; 296 fNodeStackPtr = 0; 297 } 298 break; 299 300 301 case RBBIRuleParseTable.doRuleError: 302 error(RBBIRuleBuilder.U_BRK_RULE_SYNTAX); 303 returnVal = false; 304 break; 305 306 307 case RBBIRuleParseTable.doVariableNameExpectedErr: 308 error(RBBIRuleBuilder.U_BRK_RULE_SYNTAX); 309 break; 310 311 312 case RBBIRuleParseTable.doUnaryOpPlus: 319 { 320 RBBINode operandNode = fNodeStack[fNodeStackPtr--]; 321 RBBINode plusNode = pushNewNode(RBBINode.opPlus); 322 plusNode.fLeftChild = operandNode; 323 operandNode.fParent = plusNode; 324 } 325 break; 326 327 case RBBIRuleParseTable.doUnaryOpQuestion: 328 { 329 RBBINode operandNode = fNodeStack[fNodeStackPtr--]; 330 RBBINode qNode = pushNewNode(RBBINode.opQuestion); 331 qNode.fLeftChild = operandNode; 332 operandNode.fParent = qNode; 333 } 334 break; 335 336 case RBBIRuleParseTable.doUnaryOpStar: 337 { 338 RBBINode operandNode = fNodeStack[fNodeStackPtr--]; 339 RBBINode starNode = pushNewNode(RBBINode.opStar); 340 starNode.fLeftChild = operandNode; 341 operandNode.fParent = starNode; 342 } 343 break; 344 345 case RBBIRuleParseTable.doRuleChar: 346 { 352 n = pushNewNode(RBBINode.setRef); 353 String s = (new StringBuffer ().append((char)fC.fChar)).toString(); 354 findSetFor(s, n, null); 355 n.fFirstPos = fScanIndex; 356 n.fLastPos = fNextIndex; 357 n.fText = fRB.fRules.substring(n.fFirstPos, n.fLastPos); 358 break; 359 } 360 361 case RBBIRuleParseTable.doDotAny: 362 { 364 n = pushNewNode(RBBINode.setRef); 365 findSetFor(kAny, n, null); 366 n.fFirstPos = fScanIndex; 367 n.fLastPos = fNextIndex; 368 n.fText = fRB.fRules.substring(n.fFirstPos, n.fLastPos); 369 break; 370 } 371 372 case RBBIRuleParseTable.doSlash: 373 n = pushNewNode(RBBINode.lookAhead); 375 n.fVal = fRuleNum; 376 n.fFirstPos = fScanIndex; 377 n.fLastPos = fNextIndex; 378 n.fText = fRB.fRules.substring(n.fFirstPos, n.fLastPos); 379 fLookAheadRule = true; 380 break; 381 382 383 case RBBIRuleParseTable.doStartTagValue: 384 n = pushNewNode(RBBINode.tag); 386 n.fVal = 0; 387 n.fFirstPos = fScanIndex; 388 n.fLastPos = fNextIndex; 389 break; 390 391 case RBBIRuleParseTable.doTagDigit: 392 { 394 n = fNodeStack[fNodeStackPtr]; 395 int v = Character.digit((char)fC.fChar, 10); 396 n.fVal = n.fVal*10 + v; 397 break; 398 } 399 400 case RBBIRuleParseTable.doTagValue: 401 n = fNodeStack[fNodeStackPtr]; 402 n.fLastPos = fNextIndex; 403 n.fText = fRB.fRules.substring(n.fFirstPos, n.fLastPos); 404 break; 405 406 case RBBIRuleParseTable.doTagExpectedError: 407 error(RBBIRuleBuilder.U_BRK_MALFORMED_RULE_TAG); 408 returnVal = false; 409 break; 410 411 case RBBIRuleParseTable.doOptionStart: 412 fOptionStart = fScanIndex; 414 break; 415 416 case RBBIRuleParseTable.doOptionEnd: 417 { 418 String opt = fRB.fRules.substring(fOptionStart, fScanIndex); 419 if (opt.equals("chain")) { 420 fRB.fChainRules = true; 421 } else if (opt.equals("LBCMNoChain")) { 422 fRB.fLBCMNoChain = true; 423 } else if (opt.equals("forward")) { 424 fRB.fDefaultTree = fRB.fForwardTree; 425 } else if (opt.equals("reverse")) { 426 fRB.fDefaultTree = fRB.fReverseTree; 427 } else if (opt.equals("safe_forward")) { 428 fRB.fDefaultTree = fRB.fSafeFwdTree; 429 } else if (opt.equals("safe_reverse")) { 430 fRB.fDefaultTree = fRB.fSafeRevTree; 431 } else if (opt.equals("lookAheadHardBreak")) { 432 fRB.fLookAheadHardBreak = true; 433 } else { 434 error(RBBIRuleBuilder.U_BRK_UNRECOGNIZED_OPTION); 435 } 436 break; 437 } 438 439 case RBBIRuleParseTable.doReverseDir: 440 fReverseRule = true; 441 break; 442 443 case RBBIRuleParseTable.doStartVariableName: 444 n = pushNewNode(RBBINode.varRef); 445 n.fFirstPos = fScanIndex; 446 break; 447 448 case RBBIRuleParseTable.doEndVariableName: 449 n = fNodeStack[fNodeStackPtr]; 450 if (n==null || n.fType != RBBINode.varRef) { 451 error(RBBIRuleBuilder.U_BRK_INTERNAL_ERROR); 452 break; 453 } 454 n.fLastPos = fScanIndex; 455 n.fText = fRB.fRules.substring(n.fFirstPos+1, n.fLastPos); 456 n.fLeftChild = fSymbolTable.lookupNode(n.fText); 461 break; 462 463 case RBBIRuleParseTable.doCheckVarDef: 464 n = fNodeStack[fNodeStackPtr]; 465 if (n.fLeftChild == null) { 466 error(RBBIRuleBuilder.U_BRK_UNDEFINED_VARIABLE); 467 returnVal = false; 468 } 469 break; 470 471 case RBBIRuleParseTable.doExprFinished: 472 break; 473 474 case RBBIRuleParseTable.doRuleErrorAssignExpr: 475 error(RBBIRuleBuilder.U_BRK_ASSIGN_ERROR); 476 returnVal = false; 477 break; 478 479 case RBBIRuleParseTable.doExit: 480 returnVal = false; 481 break; 482 483 case RBBIRuleParseTable.doScanUnicodeSet: 484 scanSet(); 485 break; 486 487 default: 488 error(RBBIRuleBuilder.U_BRK_INTERNAL_ERROR); 489 returnVal = false; 490 break; 491 } 492 return returnVal; 493 } 494 495 496 497 498 void error(int e) { 504 String s = "Error " + e + " at line " + fLineNum + " column " + fCharNum; 505 IllegalArgumentException ex = new IllegalArgumentException (s); 506 throw ex; 507 508 } 509 510 511 512 513 514 void fixOpStack(int p) { 530 RBBINode n; 531 for (;;) { 533 n = fNodeStack[fNodeStackPtr-1]; if (n.fPrecedence == 0) { 535 System.out.print("RBBIRuleScanner.fixOpStack, bad operator node"); 536 error(RBBIRuleBuilder.U_BRK_INTERNAL_ERROR); 537 return; 538 } 539 540 if (n.fPrecedence < p || n.fPrecedence <= RBBINode.precLParen) { 541 break; 544 } 545 n.fRightChild = fNodeStack[fNodeStackPtr]; 549 fNodeStack[fNodeStackPtr].fParent = n; 550 fNodeStackPtr--; 551 } 553 554 if (p <= RBBINode.precLParen) { 555 if (n.fPrecedence != p) { 560 error(RBBIRuleBuilder.U_BRK_MISMATCHED_PAREN); 563 } 564 fNodeStack[fNodeStackPtr-1] = fNodeStack[fNodeStackPtr]; 565 fNodeStackPtr--; 566 } 569 } 571 572 573 static class RBBISetTableEl { 585 String key; 586 RBBINode val; 587 } 588 589 590 void findSetFor(String s, RBBINode node, UnicodeSet setToAdopt) { 607 608 RBBISetTableEl el; 609 610 el = (RBBISetTableEl)fSetTable.get(s); 614 if (el != null) { 615 node.fLeftChild = el.val; 616 Assert.assrt(node.fLeftChild.fType == RBBINode.uset); 617 return; 618 } 619 620 if (setToAdopt == null) { 624 if (s.equals(kAny)) { 625 setToAdopt = new UnicodeSet(0x000000, 0x10ffff); 626 } else { 627 int c; 628 c = UTF16.charAt(s, 0); 629 setToAdopt = new UnicodeSet(c, c); 630 } 631 } 632 633 RBBINode usetNode = new RBBINode(RBBINode.uset); 638 usetNode.fInputSet = setToAdopt; 639 usetNode.fParent = node; 640 node.fLeftChild = usetNode; 641 usetNode.fText = s; 642 643 644 fRB.fUSetNodes.add(usetNode); 648 649 650 el = new RBBISetTableEl(); 654 el.key = s; 655 el.val = usetNode; 656 fSetTable.put(el.key, el); 657 658 return; 659 } 660 661 662 663 static final int chNEL = 0x85; static final int chLS = 0x2028; 671 672 static String stripRules(String rules) { 679 StringBuffer strippedRules = new StringBuffer (); 680 int rulesLength = rules.length(); 681 for (int idx = 0; idx < rulesLength; ) { 682 char ch = rules.charAt(idx++); 683 if (ch == '#') { 684 while (idx < rulesLength 685 && ch != '\r' && ch != '\n' && ch != chNEL) 686 { 687 ch = rules.charAt(idx++); 688 } 689 } 690 if (!UCharacter.isISOControl(ch)) { 691 strippedRules.append(ch); 692 } 693 } 694 return strippedRules.toString(); 695 } 696 697 698 int nextCharLL() { 706 int ch; 707 708 if (fNextIndex >= fRB.fRules.length()) { 709 return -1; 710 } 711 ch = UTF16.charAt(fRB.fRules, fNextIndex); 712 fNextIndex = UTF16.moveCodePointOffset(fRB.fRules, fNextIndex, 1); 713 714 if (ch == '\r' || 715 ch == chNEL || 716 ch == chLS || 717 ch == '\n' && fLastChar != '\r') { 718 fLineNum++; 721 fCharNum=0; 722 if (fQuoteMode) { 723 error(RBBIRuleBuilder.U_BRK_NEW_LINE_IN_QUOTED_STRING); 724 fQuoteMode = false; 725 } 726 } 727 else { 728 if (ch != '\n') { 731 fCharNum++; 732 } 733 } 734 fLastChar = ch; 735 return ch; 736 } 737 738 739 void nextChar(RBBIRuleChar c) { 747 748 751 fScanIndex = fNextIndex; 752 c.fChar = nextCharLL(); 753 c.fEscaped = false; 754 755 if (c.fChar == '\'') { 760 if (UTF16.charAt(fRB.fRules, fNextIndex) == '\'') { 761 c.fChar = nextCharLL(); c.fEscaped = true; } 764 else 765 { 766 fQuoteMode = !fQuoteMode; 770 if (fQuoteMode == true) { 771 c.fChar = '('; 772 } else { 773 c.fChar = ')'; 774 } 775 c.fEscaped = false; return; 777 } 778 } 779 780 if (fQuoteMode) { 781 c.fEscaped = true; 782 } 783 else 784 { 785 if (c.fChar == '#') { 788 for (;;) { 794 c.fChar = nextCharLL(); 795 if (c.fChar == (int)-1 || c.fChar == '\r' || 797 c.fChar == '\n' || 798 c.fChar == chNEL || 799 c.fChar == chLS) {break;} 800 } 801 } 802 if (c.fChar == (int)-1) { 803 return; 804 } 805 806 if (c.fChar == '\\') { 811 c.fEscaped = true; 812 int [] unescapeIndex = new int[1]; 813 unescapeIndex[0] = fNextIndex; 814 c.fChar = Utility.unescapeAt(fRB.fRules, unescapeIndex); 815 if (unescapeIndex[0] == fNextIndex) { 816 error(RBBIRuleBuilder.U_BRK_HEX_DIGITS_EXPECTED); 817 } 818 819 fCharNum += unescapeIndex[0]-fNextIndex; 820 fNextIndex = unescapeIndex[0]; 821 } 822 } 823 } 825 826 void parse() { 835 int state; 836 RBBIRuleParseTable.RBBIRuleTableElement tableEl; 837 838 839 state = 1; 840 nextChar(fC); 841 for (;;) { 850 if (state == 0) { 853 break; 854 } 855 856 tableEl = RBBIRuleParseTable.gRuleParseStateTable[state]; 863 if (fRB.fDebugEnv!=null && fRB.fDebugEnv.indexOf("scan")>=0) { 864 System.out.println("char, line, col = (\'" + (char)fC.fChar + "\', " + fLineNum + ", " + fCharNum + 865 " state = " + tableEl.fStateName); 866 } 867 868 for (int tableRow=state; ;tableRow++) { tableEl = RBBIRuleParseTable.gRuleParseStateTable[tableRow]; 870 if (fRB.fDebugEnv!=null && fRB.fDebugEnv.indexOf("scan")>=0) { System.out.print(".");} 871 if (tableEl.fCharClass < 127 && fC.fEscaped == false && tableEl.fCharClass == fC.fChar) { 872 break; 876 } 877 if (tableEl.fCharClass == 255) { 878 break; 880 } 881 if (tableEl.fCharClass == 254 && fC.fEscaped) { 882 break; 884 } 885 if (tableEl.fCharClass == 253 && fC.fEscaped && 886 (fC.fChar == 0x50 || fC.fChar == 0x70 )) { 887 break; 889 } 890 if (tableEl.fCharClass == 252 && fC.fChar == (int)-1) { 891 break; 893 } 894 895 if (tableEl.fCharClass >= 128 && tableEl.fCharClass < 240 && fC.fEscaped == false && fC.fChar != (int)-1) { UnicodeSet uniset = fRuleSets[tableEl.fCharClass-128]; 899 if (uniset.contains(fC.fChar)) { 900 break; 903 } 904 } 905 } 906 907 if (fRB.fDebugEnv!=null && fRB.fDebugEnv.indexOf("scan")>=0) { System.out.println("");} 908 if (doParseActions(tableEl.fAction) == false) { 913 break; 917 } 918 919 if (tableEl.fPushState != 0) { 920 fStackPtr++; 921 if (fStackPtr >= kStackSize) { 922 System.out.println("RBBIRuleScanner.parse() - state stack overflow."); 923 error(RBBIRuleBuilder.U_BRK_INTERNAL_ERROR); 924 } 925 fStack[fStackPtr] = tableEl.fPushState; 926 } 927 928 if (tableEl.fNextChar) { 929 nextChar(fC); 930 } 931 932 if (tableEl.fNextState != 255) { 935 state = tableEl.fNextState; 936 } else { 937 state = fStack[fStackPtr]; 938 fStackPtr--; 939 if (fStackPtr < 0) { 940 System.out.println("RBBIRuleScanner.parse() - state stack underflow."); 941 error(RBBIRuleBuilder.U_BRK_INTERNAL_ERROR); 942 } 943 } 944 945 } 946 947 if (fRB.fTreeRoots[RBBIRuleBuilder.fReverseTree] == null) { 951 fRB.fTreeRoots[RBBIRuleBuilder.fReverseTree] = pushNewNode(RBBINode.opStar); 952 RBBINode operand = pushNewNode(RBBINode.setRef); 953 findSetFor(kAny, operand, null); 954 fRB.fTreeRoots[RBBIRuleBuilder.fReverseTree].fLeftChild = operand; 955 operand.fParent = fRB.fTreeRoots[RBBIRuleBuilder.fReverseTree]; 956 fNodeStackPtr -= 2; 957 } 958 959 960 if (fRB.fDebugEnv!=null && fRB.fDebugEnv.indexOf("symbols")>=0) { 966 fSymbolTable.rbbiSymtablePrint(); 967 } 968 if (fRB.fDebugEnv!=null && fRB.fDebugEnv.indexOf("ptree")>=0) 969 { 970 System.out.println("Completed Forward Rules Parse Tree..."); 971 fRB.fTreeRoots[RBBIRuleBuilder.fForwardTree].printTree(true); 972 System.out.println("\nCompleted Reverse Rules Parse Tree..."); 973 fRB.fTreeRoots[RBBIRuleBuilder.fReverseTree].printTree(true); 974 System.out.println("\nCompleted Safe Point Forward Rules Parse Tree..."); 975 if (fRB.fTreeRoots[RBBIRuleBuilder.fSafeFwdTree] == null) { 976 System.out.println(" -- null -- "); 977 } else { 978 fRB.fTreeRoots[RBBIRuleBuilder.fSafeFwdTree].printTree(true); 979 } 980 System.out.println("\nCompleted Safe Point Reverse Rules Parse Tree..."); 981 if (fRB.fTreeRoots[RBBIRuleBuilder.fSafeRevTree] == null) { 982 System.out.println(" -- null -- "); 983 } else { 984 fRB.fTreeRoots[RBBIRuleBuilder.fSafeRevTree].printTree(true); 985 } 986 } 987 } 988 989 990 void printNodeStack(String title) { 996 int i; 997 System.out.println(title + ". Dumping node stack...\n"); 998 for (i=fNodeStackPtr; i>0; i--) {fNodeStack[i].printTree(true);} 999 } 1000 1001 1002 1003 1004RBBINode pushNewNode(int nodeType) { 1011 fNodeStackPtr++; 1012 if (fNodeStackPtr >= kStackSize) { 1013 System.out.println("RBBIRuleScanner.pushNewNode - stack overflow."); 1014 error(RBBIRuleBuilder.U_BRK_INTERNAL_ERROR); 1015 } 1016 fNodeStack[fNodeStackPtr] = new RBBINode(nodeType); 1017 return fNodeStack[fNodeStackPtr]; 1018} 1019 1020 1021 1022void scanSet() { 1037 UnicodeSet uset = null; 1038 int startPos; 1039 ParsePosition pos = new ParsePosition (fScanIndex); 1040 int i; 1041 1042 startPos = fScanIndex; 1043 try { 1044 uset = new UnicodeSet(fRB.fRules, pos, fSymbolTable, UnicodeSet.IGNORE_SPACE); 1045 } catch (Exception e) { error(RBBIRuleBuilder.U_BRK_MALFORMED_SET); 1048 } 1049 1050 if (uset.isEmpty()) { 1053 error(RBBIRuleBuilder.U_BRK_RULE_EMPTY_SET); 1059 } 1060 1061 1062 i = pos.getIndex(); 1066 for (;;) { 1067 if (fNextIndex >= i) { 1068 break; 1069 } 1070 nextCharLL(); 1071 } 1072 1073 RBBINode n; 1074 1075 n = pushNewNode(RBBINode.setRef); 1076 n.fFirstPos = startPos; 1077 n.fLastPos = fNextIndex; 1078 n.fText = fRB.fRules.substring(n.fFirstPos, n.fLastPos); 1079 findSetFor(n.fText, n, uset); 1086 } 1087 1088} 1089 1090 | Popular Tags |