The line, offset, and context fields are optional; parsing 37 * engines may choose not to use to use them. 38 * 39 *
The preContext and postContext strings include some part of the 40 * context surrounding the error. If the source text is "let for=7" 41 * and "for" is the error (e.g., because it is a reserved word), then 42 * some examples of what a parser might produce are the following: 43 * 44 *
45 * preContext postContext 46 * "" "" The parser does not support context 47 * "let " "=7" Pre- and post-context only 48 * "let " "for=7" Pre- and post-context and error text 49 * "" "for" Error text only 50 *
Examples of engines which use UParseError (or may use it in the 53 * future) are Transliterator, RuleBasedBreakIterator, and 54 * RegexPattern. 55 * 56 * @stable ICU 2.0 57 */ 58 typedef struct UParseError { 59 60 /** 61 * The line on which the error occurred. If the parser uses this 62 * field, it sets it to the line number of the source text line on 63 * which the error appears, which will be a value >= 1. If the 64 * parse does not support line numbers, the value will be <= 0. 65 * @stable ICU 2.0 66 */ 67 int32_t line; 68 69 /** 70 * The character offset to the error. If the line field is >= 1, 71 * then this is the offset from the start of the line. Otherwise, 72 * this is the offset from the start of the text. If the parser 73 * does not support this field, it will have a value < 0. 74 * @stable ICU 2.0 75 */ 76 int32_t offset; 77 78 /** 79 * Textual context before the error. Null-terminated. The empty 80 * string if not supported by parser. 81 * @stable ICU 2.0 82 */ 83 UChar preContext[U_PARSE_CONTEXT_LEN]; 84 85 /** 86 * The error itself and/or textual context after the error. 87 * Null-terminated. The empty string if not supported by parser. 88 * @stable ICU 2.0 89 */ 90 UChar postContext[U_PARSE_CONTEXT_LEN]; 91 92 } UParseError; 93 94 #endif