]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/unicode/parseerr.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (C) 1999-2005, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
8 * Date Name Description
9 * 03/14/00 aliu Creation.
10 * 06/27/00 aliu Change from C++ class to C struct
11 **********************************************************************
16 #include "unicode/utypes.h"
21 * \brief C API: Parse Error Information
24 * The capacity of the context strings in UParseError.
27 enum { U_PARSE_CONTEXT_LEN
= 16 };
30 * A UParseError struct is used to returned detailed information about
31 * parsing errors. It is used by ICU parsing engines that parse long
32 * rules, patterns, or programs, where the text being parsed is long
33 * enough that more information than a UErrorCode is needed to
36 * <p>The line, offset, and context fields are optional; parsing
37 * engines may choose not to use to use them.
39 * <p>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:
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
52 * <p>Examples of engines which use UParseError (or may use it in the
53 * future) are Transliterator, RuleBasedBreakIterator, and
58 typedef struct UParseError
{
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.
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.
79 * Textual context before the error. Null-terminated. The empty
80 * string if not supported by parser.
83 UChar preContext
[U_PARSE_CONTEXT_LEN
];
86 * The error itself and/or textual context after the error.
87 * Null-terminated. The empty string if not supported by parser.
90 UChar postContext
[U_PARSE_CONTEXT_LEN
];