//
// file: rbbiscan.cpp
//
-// Copyright (C) 2002-2004, International Business Machines Corporation and others.
+// Copyright (C) 2002-2006, International Business Machines Corporation and others.
// All Rights Reserved.
//
// This file contains the Rule Based Break Iterator Rule Builder functions for
U_CDECL_BEGIN
-static void U_EXPORT2 U_CALLCONV RBBISetTable_deleter(void *p) {
+static void U_CALLCONV RBBISetTable_deleter(void *p) {
RBBISetTableEl *px = (RBBISetTableEl *)p;
delete px->key;
// Note: px->val is owned by the linked list "fSetsListHead" in scanner.
}
fSymbolTable = new RBBISymbolTable(this, rb->fRules, *rb->fStatus);
- fSetTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, rb->fStatus);
+ fSetTable = uhash_open(uhash_hashUnicodeString, uhash_compareUnicodeString, NULL, rb->fStatus);
uhash_setValueDeleter(fSetTable, RBBISetTable_deleter);
}
// Make a symbol table entry for the $variableRef node.
fSymbolTable->addEntry(varRefNode->fText, varRefNode, *fRB->fStatus);
+ if (U_FAILURE(*fRB->fStatus)) {
+ // This is a round-about way to get the parse position set
+ // so that duplicate symbols error messages include a line number.
+ UErrorCode t = *fRB->fStatus;
+ *fRB->fStatus = U_ZERO_ERROR;
+ error(t);
+ }
// Clean up the stack.
delete startExprNode;
if (U_FAILURE(*fRB->fStatus)) { // parse tree rooted in TOS node.
break;
}
+#ifdef RBBI_DEBUG
if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "rtree")) {printNodeStack("end of rule");}
+#endif
U_ASSERT(fNodeStackPtr == 1);
// If this rule includes a look-ahead '/', add a endMark node to the
fRB->fRules.extractBetween(n->fFirstPos, n->fLastPos, n->fText);
break;
}
- break;
case doSlash:
// Scanned a '/', which identifies a look-ahead break position in a rule.
#endif
for (;;) {
- if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "scan")) { RBBIDebugPrintf(".");}
+ #ifdef RBBI_DEBUG
+ if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "scan")) { RBBIDebugPrintf(".");}
+ #endif
if (tableEl->fCharClass < 127 && fC.fEscaped == FALSE && tableEl->fCharClass == fC.fChar) {
// Table row specified an individual character, not a set, and
// the input character is not escaped, and
// No match on this row, advance to the next row for this state,
tableEl++;
}
- if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "scan")) { RBBIDebugPrintf("\n");}
+ if (fRB->fDebugEnv && uprv_strstr(fRB->fDebugEnv, "scan")) { RBBIDebugPuts("");}
//
// We've found the row of the state table that matches the current input
//
//---------------------------------------------------------------------------------
#ifdef RBBI_DEBUG
-void RBBIRuleScanner::printNodeStack(const char *) {}
-#else
void RBBIRuleScanner::printNodeStack(const char *title) {
int i;
RBBIDebugPrintf("%s. Dumping node stack...\n", title);
if (U_FAILURE(localStatus)) {
// TODO: Get more accurate position of the error from UnicodeSet's return info.
// UnicodeSet appears to not be reporting correctly at this time.
- RBBIDebugPrintf("UnicodeSet parse postion.ErrorIndex = %d\n", pos.getIndex());
+ #ifdef RBBI_DEBUG
+ RBBIDebugPrintf("UnicodeSet parse postion.ErrorIndex = %d\n", pos.getIndex());
+ #endif
error(localStatus);
delete uset;
return;
// Verify that the set contains at least one code point.
//
- if (uset->charAt(0) == -1) {
+ if (uset->isEmpty()) {
// This set is empty.
// Make it an error, because it almost certainly is not what the user wanted.
// Also, avoids having to think about corner cases in the tree manipulation code