sl@0: /* sl@0: ********************************************************************** sl@0: * Copyright (C) 1999-2005, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: ********************************************************************** sl@0: * Date Name Description sl@0: * 03/14/00 aliu Creation. sl@0: * 06/27/00 aliu Change from C++ class to C struct sl@0: ********************************************************************** sl@0: */ sl@0: #ifndef PARSEERR_H sl@0: #define PARSEERR_H sl@0: sl@0: #include "unicode/utypes.h" sl@0: sl@0: sl@0: /** sl@0: * \file sl@0: * \brief C API: Parse Error Information sl@0: */ sl@0: /** sl@0: * The capacity of the context strings in UParseError. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: enum { U_PARSE_CONTEXT_LEN = 16 }; sl@0: sl@0: /** sl@0: * A UParseError struct is used to returned detailed information about sl@0: * parsing errors. It is used by ICU parsing engines that parse long sl@0: * rules, patterns, or programs, where the text being parsed is long sl@0: * enough that more information than a UErrorCode is needed to sl@0: * localize the error. sl@0: * sl@0: *

The line, offset, and context fields are optional; parsing sl@0: * engines may choose not to use to use them. sl@0: * sl@0: *

The preContext and postContext strings include some part of the sl@0: * context surrounding the error. If the source text is "let for=7" sl@0: * and "for" is the error (e.g., because it is a reserved word), then sl@0: * some examples of what a parser might produce are the following: sl@0: * sl@0: *

sl@0:  * preContext   postContext
sl@0:  * ""           ""            The parser does not support context
sl@0:  * "let "       "=7"          Pre- and post-context only
sl@0:  * "let "       "for=7"       Pre- and post-context and error text
sl@0:  * ""           "for"         Error text only
sl@0:  * 
sl@0: * sl@0: *

Examples of engines which use UParseError (or may use it in the sl@0: * future) are Transliterator, RuleBasedBreakIterator, and sl@0: * RegexPattern. sl@0: * sl@0: * @stable ICU 2.0 sl@0: */ sl@0: typedef struct UParseError { sl@0: sl@0: /** sl@0: * The line on which the error occured. If the parser uses this sl@0: * field, it sets it to the line number of the source text line on sl@0: * which the error appears, which will be be a value >= 1. If the sl@0: * parse does not support line numbers, the value will be <= 0. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: int32_t line; sl@0: sl@0: /** sl@0: * The character offset to the error. If the line field is >= 1, sl@0: * then this is the offset from the start of the line. Otherwise, sl@0: * this is the offset from the start of the text. If the parser sl@0: * does not support this field, it will have a value < 0. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: int32_t offset; sl@0: sl@0: /** sl@0: * Textual context before the error. Null-terminated. The empty sl@0: * string if not supported by parser. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: UChar preContext[U_PARSE_CONTEXT_LEN]; sl@0: sl@0: /** sl@0: * The error itself and/or textual context after the error. sl@0: * Null-terminated. The empty string if not supported by parser. sl@0: * @stable ICU 2.0 sl@0: */ sl@0: UChar postContext[U_PARSE_CONTEXT_LEN]; sl@0: sl@0: } UParseError; sl@0: sl@0: #endif