Lines Matching full:rule
257 * A class representing one side of a rule. This class knows how to
258 * parse half of a rule. It is tightly coupled to the method
303 int32_t parse(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status);
305 int32_t parseSection(const UnicodeString& rule, int32_t pos, int32_t limit,
329 const UnicodeString& rule,
332 return parser.syntaxError(code, rule, start, status);
357 * Parse one side of a rule, stopping at either the limit,
362 int32_t RuleHalf::parse(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status) {
365 pos = parseSection(rule, pos, limit, text, UnicodeString(TRUE, ILLEGAL_TOP, -1), FALSE, status);
368 return syntaxError(U_MISPLACED_CURSOR_OFFSET, rule, start, status);
375 * Parse a section of one side of a rule, stopping at either
378 * top-level rule half and a segment within such a rule half.
381 * @param buf buffer into which to accumulate the rule pattern
382 * characters, either literal characters from the rule or
397 int32_t RuleHalf::parseSection(const UnicodeString& rule, int32_t pos, int32_t limit,
414 UChar c = rule.charAt(pos++);
424 return syntaxError(U_UNCLOSED_SEGMENT, rule, start, status);
430 return syntaxError(U_MALFORMED_VARIABLE_REFERENCE, rule, start, status);
432 if (UnicodeSet::resemblesPattern(rule, pos-1)) {
434 buf.append(parser.parseSet(rule, pp, status));
436 return syntaxError(U_MALFORMED_SET, rule, start, status);
444 return syntaxError(U_TRAILING_BACKSLASH, rule, start, status);
446 UChar32 escaped = rule.unescapeAt(pos); // pos is already past '\\'
448 return syntaxError(U_MALFORMED_UNICODE_ESCAPE, rule, start, status);
451 return syntaxError(U_VARIABLE_RANGE_OVERLAP, rule, start, status);
458 int32_t iq = rule.indexOf(QUOTE, pos);
472 rule, start, status);
475 rule.extractBetween(pos, iq, scratch);
478 if (pos < limit && rule.charAt(pos) == QUOTE) {
480 iq = rule.indexOf(QUOTE, pos+1);
490 return syntaxError(U_VARIABLE_RANGE_OVERLAP, rule, start, status);
498 return syntaxError(U_VARIABLE_RANGE_OVERLAP, rule, start, status);
502 syntaxError(U_ILLEGAL_CHARACTER, rule, start, status);
515 rule, start, status);
530 pos = parseSection(rule, pos, limit, buf, UnicodeString(TRUE, ILLEGAL_SEG, -1), TRUE, status);
540 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
554 TransliteratorIDParser::parseFilterID(rule, iref);
557 !ICU_Utility::parseChar(rule, iref, SEGMENT_OPEN)) {
558 return syntaxError(U_INVALID_FUNCTION, rule, start, status);
564 return syntaxError(U_INVALID_FUNCTION, rule, start, status);
572 pos = parseSection(rule, iref, limit, buf, UnicodeString(TRUE, ILLEGAL_FUNC, -1), TRUE, status);
581 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
603 c = rule.charAt(pos);
606 r = ICU_Utility::parseNumber(rule, pos, 10);
609 rule, start, status);
615 parseReference(rule, pp, limit);
651 return syntaxError(U_MISPLACED_QUANTIFIER, rule, start, status);
675 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
692 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
713 return syntaxError(U_MULTIPLE_ANTE_CONTEXTS, rule, start, status);
719 return syntaxError(U_MULTIPLE_POST_CONTEXTS, rule, start, status);
725 return syntaxError(U_MULTIPLE_CURSORS, rule, start, status);
732 return syntaxError(U_MISPLACED_CURSOR_OFFSET, rule, start, status);
737 return syntaxError(U_MISPLACED_CURSOR_OFFSET, rule, start, status);
747 return syntaxError(U_MISPLACED_CURSOR_OFFSET, rule, start, status);
764 return syntaxError(U_UNQUOTED_SPECIAL, rule, start, status);
884 void TransliteratorParser::parseRules(const UnicodeString& rule,
926 int32_t limit = rule.length();
937 UChar c = rule.charAt(pos++);
944 pos = rule.indexOf((UChar)0x000A /*\n*/, pos) + 1;
946 break; // No "\n" found; rest of rule is a commnet
958 // We've found the start of a rule or ID. c is its first
964 rule.compare(pos, ID_TOKEN_LEN, ID_TOKEN) == 0) {
966 c = rule.charAt(pos);
969 c = rule.charAt(pos);
986 TransliteratorIDParser::parseSingleID(rule, p, direction, status);
987 if (p != pos && ICU_Utility::parseChar(rule, p, END_OF_RULE)) {
1000 UnicodeSet* f = TransliteratorIDParser::parseGlobalFilter(rule, p, direction, withParens, NULL);
1002 if (ICU_Utility::parseChar(rule, p, END_OF_RULE)
1007 syntaxError(U_MULTIPLE_COMPOUND_FILTERS, rule, pos, status);
1019 syntaxError(U_INVALID_ID, rule, pos, status);
1049 // variable range' pragma allows rule sets to modify this.
1053 if (resemblesPragma(rule, pos, limit)) {
1054 int32_t ppp = parsePragma(rule, pos, limit, status);
1056 syntaxError(U_MALFORMED_PRAGMA, rule, pos, status);
1059 // Parse a rule
1061 pos = parseRule(rule, pos, limit, status);
1161 * variable range does not overlap characters used in a rule.
1194 * Return true if the given rule looks like a pragma.
1196 * of the rule.
1197 * @param limit pointer past the last character of the rule.
1199 UBool TransliteratorParser::resemblesPragma(const UnicodeString& rule, int32_t pos, int32_t limit) {
1201 return ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_USE, 4), NULL) >= 0;
1208 * of the rule.
1209 * @param limit pointer past the last character of the rule.
1213 int32_t TransliteratorParser::parsePragma(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status) {
1226 int p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_VARIABLE_RANGE, -1), array);
1232 p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_MAXIMUM_BACKUP, -1), array);
1238 p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_NFD_RULES, -1), NULL);
1244 p = ICU_Utility::parsePattern(rule, pos, limit, UnicodeString(TRUE, PRAGMA_NFC_RULES, -1), NULL);
1255 * MAIN PARSER. Parse the next rule in the given rule string, starting
1263 * parses the end-of-rule character. It recognizes context and cursor
1264 * indicators. Once it does a lexical breakdown of the rule at pos, it
1265 * creates a rule object and adds it to our rule list.
1267 int32_t TransliteratorParser::parseRule(const UnicodeString& rule, int32_t pos, int32_t limit, UErrorCode& status) {
1283 pos = left->parse(rule, pos, limit, status);
1288 if (pos == limit || u_strchr(gOPERATORS, (op = rule.charAt(--pos))) == NULL) {
1289 return syntaxError(U_MISSING_OPERATOR, rule, start, status);
1295 (pos < limit && rule.charAt(pos) == FORWARD_RULE_OP)) {
1313 pos = right->parse(rule, pos, limit, status);
1319 if (rule.charAt(--pos) == END_OF_RULE) {
1323 return syntaxError(U_UNQUOTED_SPECIAL, rule, start, status);
1337 return syntaxError(U_BAD_VARIABLE_DEFINITION, rule, start, status);
1341 return syntaxError(U_MALFORMED_VARIABLE_DEFINITION, rule, start, status);
1345 return syntaxError(U_MALFORMED_VARIABLE_DEFINITION, rule, start, status);
1351 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
1358 // If this is not a variable definition rule, we shouldn't have
1363 rule, start, status);
1368 syntaxError(U_UNDEFINED_SEGMENT_REFERENCE, rule, start, status);
1372 syntaxError(U_INTERNAL_TRANSLITERATOR_ERROR, rule, start, status); // will never happen
1377 syntaxError(U_INTERNAL_TRANSLITERATOR_ERROR, rule, start, status); // will never happen
1381 // If the direction we want doesn't match the rule
1388 // Transform the rule into a forward rule by swapping the
1430 return syntaxError(U_MALFORMED_RULE, rule, start, status);
1439 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
1454 return syntaxError(U_MEMORY_ALLOCATION_ERROR, rule, start, status);
1463 * Called by main parser upon syntax error. Search the rule string
1464 * for the probable end of the rule. Of course, if the error is that
1465 * the end of rule marker is missing, then the rule end will not be found.
1466 * In any case the rule start will be correctly reported.
1468 * @param rule pattern string
1469 * @param start position of first character of current rule
1472 const UnicodeString& rule,
1484 rule.extract(start,stop-start,parseError.preContext);
1490 stop = uprv_min(pos + LEN, rule.length());
1492 rule.extract(start,stop-start,parseError.postContext);
1505 UChar TransliteratorParser::parseSet(const UnicodeString& rule,
1508 UnicodeSet* set = new UnicodeSet(rule, pos, USET_IGNORE_SPACE, parseData, status);