11cb0ef41Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others.
21cb0ef41Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html
31cb0ef41Sopenharmony_ci/*
41cb0ef41Sopenharmony_ci**********************************************************************
51cb0ef41Sopenharmony_ci*   Copyright (C) 1999-2005, International Business Machines
61cb0ef41Sopenharmony_ci*   Corporation and others.  All Rights Reserved.
71cb0ef41Sopenharmony_ci**********************************************************************
81cb0ef41Sopenharmony_ci*   Date        Name        Description
91cb0ef41Sopenharmony_ci*   03/14/00    aliu        Creation.
101cb0ef41Sopenharmony_ci*   06/27/00    aliu        Change from C++ class to C struct
111cb0ef41Sopenharmony_ci**********************************************************************
121cb0ef41Sopenharmony_ci*/
131cb0ef41Sopenharmony_ci#ifndef PARSEERR_H
141cb0ef41Sopenharmony_ci#define PARSEERR_H
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci#include "unicode/utypes.h"
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ci/**
201cb0ef41Sopenharmony_ci * \file
211cb0ef41Sopenharmony_ci * \brief C API: Parse Error Information
221cb0ef41Sopenharmony_ci */
231cb0ef41Sopenharmony_ci/**
241cb0ef41Sopenharmony_ci * The capacity of the context strings in UParseError.
251cb0ef41Sopenharmony_ci * @stable ICU 2.0
261cb0ef41Sopenharmony_ci */
271cb0ef41Sopenharmony_cienum { U_PARSE_CONTEXT_LEN = 16 };
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci/**
301cb0ef41Sopenharmony_ci * A UParseError struct is used to returned detailed information about
311cb0ef41Sopenharmony_ci * parsing errors.  It is used by ICU parsing engines that parse long
321cb0ef41Sopenharmony_ci * rules, patterns, or programs, where the text being parsed is long
331cb0ef41Sopenharmony_ci * enough that more information than a UErrorCode is needed to
341cb0ef41Sopenharmony_ci * localize the error.
351cb0ef41Sopenharmony_ci *
361cb0ef41Sopenharmony_ci * <p>The line, offset, and context fields are optional; parsing
371cb0ef41Sopenharmony_ci * engines may choose not to use to use them.
381cb0ef41Sopenharmony_ci *
391cb0ef41Sopenharmony_ci * <p>The preContext and postContext strings include some part of the
401cb0ef41Sopenharmony_ci * context surrounding the error.  If the source text is "let for=7"
411cb0ef41Sopenharmony_ci * and "for" is the error (e.g., because it is a reserved word), then
421cb0ef41Sopenharmony_ci * some examples of what a parser might produce are the following:
431cb0ef41Sopenharmony_ci *
441cb0ef41Sopenharmony_ci * <pre>
451cb0ef41Sopenharmony_ci * preContext   postContext
461cb0ef41Sopenharmony_ci * ""           ""            The parser does not support context
471cb0ef41Sopenharmony_ci * "let "       "=7"          Pre- and post-context only
481cb0ef41Sopenharmony_ci * "let "       "for=7"       Pre- and post-context and error text
491cb0ef41Sopenharmony_ci * ""           "for"         Error text only
501cb0ef41Sopenharmony_ci * </pre>
511cb0ef41Sopenharmony_ci *
521cb0ef41Sopenharmony_ci * <p>Examples of engines which use UParseError (or may use it in the
531cb0ef41Sopenharmony_ci * future) are Transliterator, RuleBasedBreakIterator, and
541cb0ef41Sopenharmony_ci * RegexPattern.
551cb0ef41Sopenharmony_ci *
561cb0ef41Sopenharmony_ci * @stable ICU 2.0
571cb0ef41Sopenharmony_ci */
581cb0ef41Sopenharmony_citypedef struct UParseError {
591cb0ef41Sopenharmony_ci
601cb0ef41Sopenharmony_ci    /**
611cb0ef41Sopenharmony_ci     * The line on which the error occurred.  If the parser uses this
621cb0ef41Sopenharmony_ci     * field, it sets it to the line number of the source text line on
631cb0ef41Sopenharmony_ci     * which the error appears, which will be a value >= 1.  If the
641cb0ef41Sopenharmony_ci     * parse does not support line numbers, the value will be <= 0.
651cb0ef41Sopenharmony_ci     * @stable ICU 2.0
661cb0ef41Sopenharmony_ci     */
671cb0ef41Sopenharmony_ci    int32_t        line;
681cb0ef41Sopenharmony_ci
691cb0ef41Sopenharmony_ci    /**
701cb0ef41Sopenharmony_ci     * The character offset to the error.  If the line field is >= 1,
711cb0ef41Sopenharmony_ci     * then this is the offset from the start of the line.  Otherwise,
721cb0ef41Sopenharmony_ci     * this is the offset from the start of the text.  If the parser
731cb0ef41Sopenharmony_ci     * does not support this field, it will have a value < 0.
741cb0ef41Sopenharmony_ci     * @stable ICU 2.0
751cb0ef41Sopenharmony_ci     */
761cb0ef41Sopenharmony_ci    int32_t        offset;
771cb0ef41Sopenharmony_ci
781cb0ef41Sopenharmony_ci    /**
791cb0ef41Sopenharmony_ci     * Textual context before the error.  Null-terminated.  The empty
801cb0ef41Sopenharmony_ci     * string if not supported by parser.
811cb0ef41Sopenharmony_ci     * @stable ICU 2.0
821cb0ef41Sopenharmony_ci     */
831cb0ef41Sopenharmony_ci    UChar          preContext[U_PARSE_CONTEXT_LEN];
841cb0ef41Sopenharmony_ci
851cb0ef41Sopenharmony_ci    /**
861cb0ef41Sopenharmony_ci     * The error itself and/or textual context after the error.
871cb0ef41Sopenharmony_ci     * Null-terminated.  The empty string if not supported by parser.
881cb0ef41Sopenharmony_ci     * @stable ICU 2.0
891cb0ef41Sopenharmony_ci     */
901cb0ef41Sopenharmony_ci    UChar          postContext[U_PARSE_CONTEXT_LEN];
911cb0ef41Sopenharmony_ci
921cb0ef41Sopenharmony_ci} UParseError;
931cb0ef41Sopenharmony_ci
941cb0ef41Sopenharmony_ci#endif
95