annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/parseerr.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 // © 2016 and later: Unicode, Inc. and others.
jpayne@69 2 // License & terms of use: http://www.unicode.org/copyright.html
jpayne@69 3 /*
jpayne@69 4 **********************************************************************
jpayne@69 5 * Copyright (C) 1999-2005, International Business Machines
jpayne@69 6 * Corporation and others. All Rights Reserved.
jpayne@69 7 **********************************************************************
jpayne@69 8 * Date Name Description
jpayne@69 9 * 03/14/00 aliu Creation.
jpayne@69 10 * 06/27/00 aliu Change from C++ class to C struct
jpayne@69 11 **********************************************************************
jpayne@69 12 */
jpayne@69 13 #ifndef PARSEERR_H
jpayne@69 14 #define PARSEERR_H
jpayne@69 15
jpayne@69 16 #include "unicode/utypes.h"
jpayne@69 17
jpayne@69 18
jpayne@69 19 /**
jpayne@69 20 * \file
jpayne@69 21 * \brief C API: Parse Error Information
jpayne@69 22 */
jpayne@69 23 /**
jpayne@69 24 * The capacity of the context strings in UParseError.
jpayne@69 25 * @stable ICU 2.0
jpayne@69 26 */
jpayne@69 27 enum { U_PARSE_CONTEXT_LEN = 16 };
jpayne@69 28
jpayne@69 29 /**
jpayne@69 30 * A UParseError struct is used to returned detailed information about
jpayne@69 31 * parsing errors. It is used by ICU parsing engines that parse long
jpayne@69 32 * rules, patterns, or programs, where the text being parsed is long
jpayne@69 33 * enough that more information than a UErrorCode is needed to
jpayne@69 34 * localize the error.
jpayne@69 35 *
jpayne@69 36 * <p>The line, offset, and context fields are optional; parsing
jpayne@69 37 * engines may choose not to use to use them.
jpayne@69 38 *
jpayne@69 39 * <p>The preContext and postContext strings include some part of the
jpayne@69 40 * context surrounding the error. If the source text is "let for=7"
jpayne@69 41 * and "for" is the error (e.g., because it is a reserved word), then
jpayne@69 42 * some examples of what a parser might produce are the following:
jpayne@69 43 *
jpayne@69 44 * <pre>
jpayne@69 45 * preContext postContext
jpayne@69 46 * "" "" The parser does not support context
jpayne@69 47 * "let " "=7" Pre- and post-context only
jpayne@69 48 * "let " "for=7" Pre- and post-context and error text
jpayne@69 49 * "" "for" Error text only
jpayne@69 50 * </pre>
jpayne@69 51 *
jpayne@69 52 * <p>Examples of engines which use UParseError (or may use it in the
jpayne@69 53 * future) are Transliterator, RuleBasedBreakIterator, and
jpayne@69 54 * RegexPattern.
jpayne@69 55 *
jpayne@69 56 * @stable ICU 2.0
jpayne@69 57 */
jpayne@69 58 typedef struct UParseError {
jpayne@69 59
jpayne@69 60 /**
jpayne@69 61 * The line on which the error occurred. If the parser uses this
jpayne@69 62 * field, it sets it to the line number of the source text line on
jpayne@69 63 * which the error appears, which will be a value >= 1. If the
jpayne@69 64 * parse does not support line numbers, the value will be <= 0.
jpayne@69 65 * @stable ICU 2.0
jpayne@69 66 */
jpayne@69 67 int32_t line;
jpayne@69 68
jpayne@69 69 /**
jpayne@69 70 * The character offset to the error. If the line field is >= 1,
jpayne@69 71 * then this is the offset from the start of the line. Otherwise,
jpayne@69 72 * this is the offset from the start of the text. If the parser
jpayne@69 73 * does not support this field, it will have a value < 0.
jpayne@69 74 * @stable ICU 2.0
jpayne@69 75 */
jpayne@69 76 int32_t offset;
jpayne@69 77
jpayne@69 78 /**
jpayne@69 79 * Textual context before the error. Null-terminated. The empty
jpayne@69 80 * string if not supported by parser.
jpayne@69 81 * @stable ICU 2.0
jpayne@69 82 */
jpayne@69 83 UChar preContext[U_PARSE_CONTEXT_LEN];
jpayne@69 84
jpayne@69 85 /**
jpayne@69 86 * The error itself and/or textual context after the error.
jpayne@69 87 * Null-terminated. The empty string if not supported by parser.
jpayne@69 88 * @stable ICU 2.0
jpayne@69 89 */
jpayne@69 90 UChar postContext[U_PARSE_CONTEXT_LEN];
jpayne@69 91
jpayne@69 92 } UParseError;
jpayne@69 93
jpayne@69 94 #endif