17777dab0Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others.
27777dab0Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html
37777dab0Sopenharmony_ci/*
47777dab0Sopenharmony_ci**********************************************************************
57777dab0Sopenharmony_ci*   Copyright (C) 1999-2005, International Business Machines
67777dab0Sopenharmony_ci*   Corporation and others.  All Rights Reserved.
77777dab0Sopenharmony_ci**********************************************************************
87777dab0Sopenharmony_ci*   Date        Name        Description
97777dab0Sopenharmony_ci*   03/14/00    aliu        Creation.
107777dab0Sopenharmony_ci*   06/27/00    aliu        Change from C++ class to C struct
117777dab0Sopenharmony_ci**********************************************************************
127777dab0Sopenharmony_ci*/
137777dab0Sopenharmony_ci#ifndef PARSEERR_H
147777dab0Sopenharmony_ci#define PARSEERR_H
157777dab0Sopenharmony_ci
167777dab0Sopenharmony_ci#include "unicode/utypes.h"
177777dab0Sopenharmony_ci/**
187777dab0Sopenharmony_ci * \file
197777dab0Sopenharmony_ci * \brief C API: Parse Error Information
207777dab0Sopenharmony_ci */
217777dab0Sopenharmony_ci/**
227777dab0Sopenharmony_ci * The capacity of the context strings in UParseError.
237777dab0Sopenharmony_ci * @stable ICU 2.0
247777dab0Sopenharmony_ci */
257777dab0Sopenharmony_cienum { U_PARSE_CONTEXT_LEN = 16 };
267777dab0Sopenharmony_ci
277777dab0Sopenharmony_ci/**
287777dab0Sopenharmony_ci * A UParseError struct is used to returned detailed information about
297777dab0Sopenharmony_ci * parsing errors.  It is used by ICU parsing engines that parse long
307777dab0Sopenharmony_ci * rules, patterns, or programs, where the text being parsed is long
317777dab0Sopenharmony_ci * enough that more information than a UErrorCode is needed to
327777dab0Sopenharmony_ci * localize the error.
337777dab0Sopenharmony_ci *
347777dab0Sopenharmony_ci * <p>The line, offset, and context fields are optional; parsing
357777dab0Sopenharmony_ci * engines may choose not to use to use them.
367777dab0Sopenharmony_ci *
377777dab0Sopenharmony_ci * <p>The preContext and postContext strings include some part of the
387777dab0Sopenharmony_ci * context surrounding the error.  If the source text is "let for=7"
397777dab0Sopenharmony_ci * and "for" is the error (e.g., because it is a reserved word), then
407777dab0Sopenharmony_ci * some examples of what a parser might produce are the following:
417777dab0Sopenharmony_ci *
427777dab0Sopenharmony_ci * <pre>
437777dab0Sopenharmony_ci * preContext   postContext
447777dab0Sopenharmony_ci * ""           ""            The parser does not support context
457777dab0Sopenharmony_ci * "let "       "=7"          Pre- and post-context only
467777dab0Sopenharmony_ci * "let "       "for=7"       Pre- and post-context and error text
477777dab0Sopenharmony_ci * ""           "for"         Error text only
487777dab0Sopenharmony_ci * </pre>
497777dab0Sopenharmony_ci *
507777dab0Sopenharmony_ci * <p>Examples of engines which use UParseError (or may use it in the
517777dab0Sopenharmony_ci * future) are Transliterator, RuleBasedBreakIterator, and
527777dab0Sopenharmony_ci * RegexPattern.
537777dab0Sopenharmony_ci *
547777dab0Sopenharmony_ci * @stable ICU 2.0
557777dab0Sopenharmony_ci */
567777dab0Sopenharmony_citypedef struct UParseError {
577777dab0Sopenharmony_ci
587777dab0Sopenharmony_ci    /**
597777dab0Sopenharmony_ci     * The line on which the error occurred.  If the parser uses this
607777dab0Sopenharmony_ci     * field, it sets it to the line number of the source text line on
617777dab0Sopenharmony_ci     * which the error appears, which will be a value >= 1.  If the
627777dab0Sopenharmony_ci     * parse does not support line numbers, the value will be <= 0.
637777dab0Sopenharmony_ci     * @stable ICU 2.0
647777dab0Sopenharmony_ci     */
657777dab0Sopenharmony_ci    int32_t        line;
667777dab0Sopenharmony_ci
677777dab0Sopenharmony_ci    /**
687777dab0Sopenharmony_ci     * The character offset to the error.  If the line field is >= 1,
697777dab0Sopenharmony_ci     * then this is the offset from the start of the line.  Otherwise,
707777dab0Sopenharmony_ci     * this is the offset from the start of the text.  If the parser
717777dab0Sopenharmony_ci     * does not support this field, it will have a value < 0.
727777dab0Sopenharmony_ci     * @stable ICU 2.0
737777dab0Sopenharmony_ci     */
747777dab0Sopenharmony_ci    int32_t        offset;
757777dab0Sopenharmony_ci
767777dab0Sopenharmony_ci    /**
777777dab0Sopenharmony_ci     * Textual context before the error.  Null-terminated.  The empty
787777dab0Sopenharmony_ci     * string if not supported by parser.
797777dab0Sopenharmony_ci     * @stable ICU 2.0
807777dab0Sopenharmony_ci     */
817777dab0Sopenharmony_ci    UChar          preContext[U_PARSE_CONTEXT_LEN];
827777dab0Sopenharmony_ci
837777dab0Sopenharmony_ci    /**
847777dab0Sopenharmony_ci     * The error itself and/or textual context after the error.
857777dab0Sopenharmony_ci     * Null-terminated.  The empty string if not supported by parser.
867777dab0Sopenharmony_ci     * @stable ICU 2.0
877777dab0Sopenharmony_ci     */
887777dab0Sopenharmony_ci    UChar          postContext[U_PARSE_CONTEXT_LEN];
897777dab0Sopenharmony_ci
907777dab0Sopenharmony_ci} UParseError;
917777dab0Sopenharmony_ci
927777dab0Sopenharmony_ci#endif
93