Home | History | Annotate | Download | only in i18n

Lines Matching refs:rule

259  * A class representing one side of a rule.  This class knows how to
260 * parse half of a rule. It is tightly coupled to the method
305 int32_t parse(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status);
307 int32_t parseSection(const UnicodeString& rule, int32_t pos, int32_t limit,
331 const UnicodeString& rule,
334 return parser.syntaxError(code, rule, start, status);
359 * Parse one side of a rule, stopping at either the limit,
364 int32_t RuleHalf::parse(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status) {
367 pos = parseSection(rule, pos, limit, text, UnicodeString(TRUE, ILLEGAL_TOP, -1), FALSE, status);
370 return syntaxError(U_MISPLACED_CURSOR_OFFSET, rule, start, status);
377 * Parse a section of one side of a rule, stopping at either
380 * top-level rule half and a segment within such a rule half.
383 * @param buf buffer into which to accumulate the rule pattern
384 * characters, either literal characters from the rule or
399 int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t limit,
416 UChar c = rule.charAt(pos++);
426 return syntaxError(U_UNCLOSED_SEGMENT, rule, start, status);
432 return syntaxError(U_MALFORMED_VARIABLE_REFERENCE, rule, start, status);
434 if (UnicodeSet::resemblesPattern(rule, pos-1)) {
436 buf.append(parser.parseSet(rule, pp, status));
438 return syntaxError(U_MALFORMED_SET, rule, start, status);
446 return syntaxError(U_TRAILING_BACKSLASH, rule, start, status);
448 UChar32 escaped = rule.unescapeAt(pos); // pos is already past '\\'
450 return syntaxError(U_MALFORMED_UNICODE_ESCAPE, rule, start, status);
453 return syntaxError(U_VARIABLE_RANGE_OVERLAP, rule, start, status);
460 int32_t iq = rule.indexOf(QUOTE, pos);
474 return syntaxError(U_UNTERMINATED_QUOTE, rule, start, status);
477 rule.extractBetween(pos, iq, scratch);
480 if (pos < limit && rule.charAt(pos) == QUOTE) {
482 iq = rule.indexOf(QUOTE, pos+1);
492 return syntaxError(U_VARIABLE_RANGE_OVERLAP, rule, start, status);
500 return syntaxError(U_VARIABLE_RANGE_OVERLAP, rule, start, status);
504 syntaxError(U_ILLEGAL_CHARACTER, rule, start, status);
517 rule, start, status);
532 pos = parseSection(rule, pos, limit, buf, UnicodeString(TRUE, ILLEGAL_SEG, -1), TRUE, status);
542 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
556 TransliteratorIDParser::parseFilterID(rule, iref);
559 !ICU_Utility::parseChar(rule, iref, SEGMENT_OPEN)) {
560 return syntaxError(U_INVALID_FUNCTION, rule, start, status);
566 return syntaxError(U_INVALID_FUNCTION, rule, start, status);
574 pos = parseSection(rule, iref, limit, buf, UnicodeString(TRUE, ILLEGAL_FUNC, -1), TRUE, status);
583 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
605 c = rule.charAt(pos);
608 r = ICU_Utility::parseNumber(rule, pos, 10);
611 rule, start, status);
617 parseReference(rule, pp, limit);
653 return syntaxError(U_MISPLACED_QUANTIFIER, rule, start, status);
677 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
694 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
715 return syntaxError(U_MULTIPLE_ANTE_CONTEXTS, rule, start, status);
721 return syntaxError(U_MULTIPLE_POST_CONTEXTS, rule, start, status);
727 return syntaxError(U_MULTIPLE_CURSORS, rule, start, status);
734 return syntaxError(U_MISPLACED_CURSOR_OFFSET, rule, start, status);
739 return syntaxError(U_MISPLACED_CURSOR_OFFSET, rule, start, status);
749 return syntaxError(U_MISPLACED_CURSOR_OFFSET, rule, start, status);
766 return syntaxError(U_UNQUOTED_SPECIAL, rule, start, status);
886 void TransliteratorParser::parseRules(const UnicodeString& rule,
928 int32_t limit = rule.length();
939 UChar c = rule.charAt(pos++);
946 pos = rule.indexOf((UChar)0x000A /*\n*/, pos) + 1;
948 break; // No "\n" found; rest of rule is a commnet
960 // We've found the start of a rule or ID. c is its first
966 rule.compare(pos, ID_TOKEN_LEN, ID_TOKEN) == 0) {
968 c = rule.charAt(pos);
971 c = rule.charAt(pos);
988 TransliteratorIDParser::parseSingleID(rule, p, direction, status);
989 if (p != pos && ICU_Utility::parseChar(rule, p, END_OF_RULE)) {
1002 UnicodeSet* f = TransliteratorIDParser::parseGlobalFilter(rule, p, direction, withParens, NULL);
1004 if (ICU_Utility::parseChar(rule, p, END_OF_RULE)
1009 syntaxError(U_MULTIPLE_COMPOUND_FILTERS, rule, pos, status);
1021 syntaxError(U_INVALID_ID, rule, pos, status);
1051 // variable range' pragma allows rule sets to modify this.
1055 if (resemblesPragma(rule, pos, limit)) {
1056 int32_t ppp = parsePragma(rule, pos, limit, status);
1058 syntaxError(U_MALFORMED_PRAGMA, rule, pos, status);
1061 // Parse a rule
1063 pos = parseRule(rule, pos, limit, status);
1163 * variable range does not overlap characters used in a rule.
1196 * Return true if the given rule looks like a pragma.
1198 * of the rule.
1199 * @param limit pointer past the last character of the rule.
1201 UBool TransliteratorParser::resemblesPragma(const UnicodeString& rule, int32_t pos, int32_t limit) {
1203 return ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_USE, 4), NULL) >= 0;
1210 * of the rule.
1211 * @param limit pointer past the last character of the rule.
1215 int32_t TransliteratorParser::parsePragma(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status) {
1228 int p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_VARIABLE_RANGE, -1), array);
1234 p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_MAXIMUM_BACKUP, -1), array);
1240 p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_NFD_RULES, -1), NULL);
1246 p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_NFC_RULES, -1), NULL);
1257 * MAIN PARSER. Parse the next rule in the given rule string, starting
1265 * parses the end-of-rule character. It recognizes context and cursor
1266 * indicators. Once it does a lexical breakdown of the rule at pos, it
1267 * creates a rule object and adds it to our rule list.
1269 int32_t TransliteratorParser::parseRule(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status) {
1285 pos = left->parse(rule, pos, limit, status);
1290 if (pos == limit || u_strchr(gOPERATORS, (op = rule.charAt(--pos))) == NULL) {
1291 return syntaxError(U_MISSING_OPERATOR, rule, start, status);
1297 (pos < limit && rule.charAt(pos) == FORWARD_RULE_OP)) {
1315 pos = right->parse(rule, pos, limit, status);
1321 if (rule.charAt(--pos) == END_OF_RULE) {
1325 return syntaxError(U_UNQUOTED_SPECIAL, rule, start, status);
1339 return syntaxError(U_BAD_VARIABLE_DEFINITION, rule, start, status);
1343 return syntaxError(U_MALFORMED_VARIABLE_DEFINITION, rule, start, status);
1347 return syntaxError(U_MALFORMED_VARIABLE_DEFINITION, rule, start, status);
1353 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
1360 // If this is not a variable definition rule, we shouldn't have
1365 rule, start, status);
1370 syntaxError(U_UNDEFINED_SEGMENT_REFERENCE, rule, start, status);
1374 syntaxError(U_INTERNAL_TRANSLITERATOR_ERROR, rule, start, status); // will never happen
1379 syntaxError(U_INTERNAL_TRANSLITERATOR_ERROR, rule, start, status); // will never happen
1383 // If the direction we want doesn't match the rule
1390 // Transform the rule into a forward rule by swapping the
1432 return syntaxError(U_MALFORMED_RULE, rule, start, status);
1441 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
1456 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
1465 * Called by main parser upon syntax error. Search the rule string
1466 * for the probable end of the rule. Of course, if the error is that
1467 * the end of rule marker is missing, then the rule end will not be found.
1468 * In any case the rule start will be correctly reported.
1470 * @param rule pattern string
1471 * @param start position of first character of current rule
1474 const UnicodeString& rule,
1486 rule.extract(start,stop-start,parseError.preContext);
1492 stop = uprv_min(pos + LEN, rule.length());
1494 rule.extract(start,stop-start,parseError.postContext);
1507 UChar TransliteratorParser::parseSet(const UnicodeString& rule,
1510 UnicodeSet* set = new UnicodeSet(rule, pos, USET_IGNORE_SPACE, parseData, status);