Path: blob/jdk8u272-b10-aarch32-20201026/jdk/src/share/native/common/unicode/parseerr.h
48773 views
// © 2016 and later: Unicode, Inc. and others.1// License & terms of use: http://www.unicode.org/copyright.html2/*3**********************************************************************4* Copyright (C) 1999-2005, International Business Machines5* Corporation and others. All Rights Reserved.6**********************************************************************7* Date Name Description8* 03/14/00 aliu Creation.9* 06/27/00 aliu Change from C++ class to C struct10**********************************************************************11*/12#ifndef PARSEERR_H13#define PARSEERR_H1415#include "unicode/utypes.h"161718/**19* \file20* \brief C API: Parse Error Information21*/22/**23* The capacity of the context strings in UParseError.24* @stable ICU 2.025*/26enum { U_PARSE_CONTEXT_LEN = 16 };2728/**29* A UParseError struct is used to returned detailed information about30* parsing errors. It is used by ICU parsing engines that parse long31* rules, patterns, or programs, where the text being parsed is long32* enough that more information than a UErrorCode is needed to33* localize the error.34*35* <p>The line, offset, and context fields are optional; parsing36* engines may choose not to use to use them.37*38* <p>The preContext and postContext strings include some part of the39* context surrounding the error. If the source text is "let for=7"40* and "for" is the error (e.g., because it is a reserved word), then41* some examples of what a parser might produce are the following:42*43* <pre>44* preContext postContext45* "" "" The parser does not support context46* "let " "=7" Pre- and post-context only47* "let " "for=7" Pre- and post-context and error text48* "" "for" Error text only49* </pre>50*51* <p>Examples of engines which use UParseError (or may use it in the52* future) are Transliterator, RuleBasedBreakIterator, and53* RegexPattern.54*55* @stable ICU 2.056*/57typedef struct UParseError {5859/**60* The line on which the error occurred. If the parser uses this61* field, it sets it to the line number of the source text line on62* which the error appears, which will be a value >= 1. If the63* parse does not support line numbers, the value will be <= 0.64* @stable ICU 2.065*/66int32_t line;6768/**69* The character offset to the error. If the line field is >= 1,70* then this is the offset from the start of the line. Otherwise,71* this is the offset from the start of the text. If the parser72* does not support this field, it will have a value < 0.73* @stable ICU 2.074*/75int32_t offset;7677/**78* Textual context before the error. Null-terminated. The empty79* string if not supported by parser.80* @stable ICU 2.081*/82UChar preContext[U_PARSE_CONTEXT_LEN];8384/**85* The error itself and/or textual context after the error.86* Null-terminated. The empty string if not supported by parser.87* @stable ICU 2.088*/89UChar postContext[U_PARSE_CONTEXT_LEN];9091} UParseError;9293#endif949596