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