Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

xml.parser.eiffel

Class XM_EIFFEL_PARSER_SKELETON


Direct ancestors

XM_NON_INCREMENTAL_PARSER, XM_FORWARD_CALLBACKS, XM_FORWARD_DTD_CALLBACKS, YY_PARSER_SKELETON, XM_EIFFEL_TOKENS, XM_EIFFEL_PARSER_ERRORS, UC_UNICODE_FACTORY, UC_IMPORTED_UTF8_ROUTINES, UC_IMPORTED_UNICODE_ROUTINES, XM_EIFFEL_UNICODE_STRUCTURE_FACTORY, KL_IMPORTED_INTEGER_ROUTINES, KL_IMPORTED_ANY_ROUTINES

Known direct descendants

XM_EIFFEL_PARSER

Features

Invariants

indexing

description

XML parser skeletons using a native Eiffel parser

implements

XML 1.0 (Second Edition) - W3C Recommendation 6 October 2000

library

Gobo Eiffel XML Library

copyright

Copyright (c) 2002, Eric Bezault and others

license

Eiffel Forum License v2 (see forum.txt)

date

$Date: 2005/06/04 22:35:30 $

revision

$Revision: 1.34 $

deferred class

XM_EIFFEL_PARSER_SKELETON

inherit

XM_NON_INCREMENTAL_PARSER
XM_FORWARD_CALLBACKS
XM_FORWARD_DTD_CALLBACKS
YY_PARSER_SKELETON
YY_PARSER
YY_PARSER_TOKENS

feature -- Initialization

reset

-- Reset parser before parsing next input.

feature -- Access

callbacks: XM_CALLBACKS

-- Callbacks event interface to which events are forwarded;
-- If void, a null callback is created on startup.

-- (From XM_FORWARD_CALLBACKS)

dtd_callbacks: XM_DTD_CALLBACKS

-- Callbacks event interface to which events are forwarded;
-- If void, a null callback is created on startup.

-- (From XM_FORWARD_DTD_CALLBACKS)

error_count: INTEGER

-- Number of errors detected during last parsing

-- (From YY_PARSER)

ensure
error_count_non_negative: Result >= 0
expected_tokens: ARRAY [INTEGER]

-- List of token codes that are a possible input at this stage
-- of parsing. (This routine can be called from the error actions
-- %error or from report_error in order to build a meaningful
-- error message.)

-- (From YY_PARSER_SKELETON)

ensure
expected_tokens_not_void: Result /= Void
token_name (a_token: INTEGER): STRING

-- Name of token a_token

-- (From YY_PARSER_TOKENS)

ensure
token_name_not_void: Result /= Void

feature {YY_PARSER_ACTION} -- Status report

is_expected_token (a_token: INTEGER): BOOLEAN

-- Is a_token a possible input at this stage of parsing?
-- (This routine can be called from one of the error actions
-- %error or from report_error in order to find out what
-- were the expected tokens when the error occurred.)

-- (From YY_PARSER_SKELETON)

require
a_token_positive: a_token >= 0
is_incremental: BOOLEAN

-- Non incremental parser

-- (From XM_PARSER)

is_recovering: BOOLEAN

-- Is current parser recovering from a syntax error?

-- (From YY_PARSER)

is_string_mode_ascii: BOOLEAN

-- Is string mode set to ascii only?
-- This means that all strings issued by this source
-- will be of dynamic type STRING.

-- (From XM_STRING_MODE)

is_string_mode_latin1: BOOLEAN

-- Is string mode set to latin-1 only?
-- This means that all strings issued by this source
-- will be of dynamic type STRING.

-- (From XM_STRING_MODE)

is_string_mode_mixed: BOOLEAN

-- Is string mode set to polymorphic strings?
-- This means that strings issued by this source will
-- be of dynamic type STRING for ascii, and dynamic
-- type UC_STRING or descendant when characters >127
-- are present in that string.

-- (From XM_STRING_MODE)

is_string_mode_unicode: BOOLEAN

-- Is string mode set to UC_STRING only?
-- This means that all strings issued by this source
-- will be of a dynamic type UC_STRING or descendant.

-- (From XM_STRING_MODE)

same_string_mode (other: XM_STRING_MODE): BOOLEAN

-- Is other with the same string mode?

-- (From XM_STRING_MODE)

require
other_not_void: other /= Void
syntax_error: BOOLEAN

-- Has last parsing been unsuccesful?

-- (From YY_PARSER)

feature -- Status setting

set_string_mode_ascii

-- Set all strings issued by this source to be ascii
-- (all characters <= 127) and be of dynamic type STRING.
-- The source will be in an error state if it has
-- characters that do not fit in a STRING.

-- (From XM_STRING_MODE)

ensure
string_mode_set: is_string_mode_ascii
set_string_mode_latin1

-- Set all strings issued by this source to be latin-1
-- (all characters <= 255) and be of dynamic type STRING.
-- The source will be in an error state if it has
-- characters that do not fit in a STRING.

-- (From XM_STRING_MODE)

ensure
string_mode_set: is_string_mode_latin1
set_string_mode_mixed

-- Set all strings issued by this source to be either of
-- type UC_STRING or descendant if they contain characters
-- >127 or of dynamic type STRING otherwise.
-- The client receiving these strings will have to
-- be careful about polymorphically unsafe features
-- of STRING, like append_string.

-- (From XM_STRING_MODE)

ensure
string_mode_set: is_string_mode_mixed
set_string_mode_unicode

-- Set all strings issued by this source to be of
-- dynamic type UC_STRING or descendant.

-- (From XM_STRING_MODE)

ensure
string_mode_set: is_string_mode_unicode

feature {YY_PARSER_ACTION} -- Element change

abort

-- Abort parsing.
-- Do not print error message.

-- (From YY_PARSER)

ensure
aborted: syntax_error
accept

-- Stop parsing successfully.

-- (From YY_PARSER)

ensure
accepted: not syntax_error
clear_all

-- Clear temporary objects so that they can be collected
-- by the garbage collector. (This routine is called by
-- parse before exiting. It can be redefined in descendants.)
-- Clear internal stacks by default.

-- (From YY_PARSER)

clear_stacks

-- Clear objects in internal stacks so that they can
-- be collected by the garbage collector.

-- (From YY_PARSER_SKELETON)

clear_token

-- Clear the previous lookahead token.
-- Used in error-recovery rule actions.

-- (From YY_PARSER)

raise_error

-- Raise a syntax error.
-- Report error using the error action %error associated
-- with current parsing state or report_error by default,
-- and perform normal error recovery if possible.

-- (From YY_PARSER)

recover

-- Recover immediately after a parse error.

-- (From YY_PARSER)

report_eof_expected_error

-- Report that an end-of-file is expected.
-- (This routine is called by default by parse when it detects
-- such syntax error and can be redefined in descendants.)

-- (From YY_PARSER_SKELETON)

feature -- Parsing

parse

-- Parse input stream.
-- Set syntax_error to True if
-- parsing has not been successful.

-- (From YY_PARSER)

parse_from_public (a_public: STRING; a_system: STRING)

-- Parse from public/system identifier using resolver.

-- (From XM_PARSER)

require
a_public_not_void: a_public /= Void
; a_system_not_void: a_system /= Void
parse_from_stream (a_stream: KI_CHARACTER_INPUT_STREAM)

-- Parse XML document from input stream.

-- (From XM_PARSER)

require
a_stream_not_void: a_stream /= Void
is_open_read: a_stream.is_open_read
parse_from_string (a_string: STRING)

-- Parse XML document from a_string.

-- (From XM_PARSER)

require
a_string_not_void: a_string /= Void
parse_from_system (a_system: STRING)

-- Parse from system identifier using resolver.

-- (From XM_PARSER)

require
a_system_not_void: a_system /= Void

feature -- Namespace mode

disable_namespaces

-- Disable namespace parsing and allow strict
-- XML 1.0 names (eg ":" or ":a:b:c:").
-- Namespace field in events is always Void.

ensure
disabled_namespaces: not use_namespaces
use_namespaces: BOOLEAN

-- Are namespaces parsed?

feature {XM_PARSER_STOP_ON_ERROR_FILTER}

force_unreported_error (an_error: STRING)

-- Stop the parser, but do not issue an event error because
-- the error is issued by a downstream event.

-- (From XM_PARSER)

require
an_error_not_void: an_error /= Void

feature -- Resolving external entity

dtd_resolver: XM_EXTERNAL_RESOLVER

-- Resolver for external DTD.

-- (From XM_PARSER)

entity_resolver: XM_EXTERNAL_RESOLVER

-- Resolver for external entities.

-- (From XM_PARSER)

set_dtd_resolver (a_resolver: like dtd_resolver)

-- Set resolver for external DTD.

-- (From XM_PARSER)

require
not_void: a_resolver /= Void
ensure
dtd_resolver_set: dtd_resolver = a_resolver
set_entity_resolver (a_resolver: like entity_resolver)

-- Set resolver for external entities.

-- (From XM_PARSER)

require
not_void: a_resolver /= Void
ensure
entity_resolver_set: entity_resolver = a_resolver
set_resolver (a_resolver: like dtd_resolver)

-- Set both entity and DTD resolvers to the same one.

-- (From XM_PARSER)

require
not_void: a_resolver /= Void
ensure
entity_resolver_set: entity_resolver = a_resolver
dtd_resolver_set: dtd_resolver = a_resolver

feature -- Incremental parsing

finish_incremental

-- Precondition always false.

-- (From XM_PARSER)

require
is_incremental: is_incremental
ensure then
not_possible: False
parse_incremental_from_stream (a_stream: KI_CHARACTER_INPUT_STREAM)

-- Precondition always false.

-- (From XM_PARSER)

require
is_incremental: is_incremental
a_stream_not_void: a_stream /= Void
is_open_read: a_stream.is_open_read
ensure then
not_possible: False
parse_incremental_from_string (data: STRING)

-- Precondition always false.

-- (From XM_PARSER)

require
is_incremental: is_incremental
a_data_not_void: a_data /= Void
ensure then
not_possible: False
set_end_of_document

-- Old name for finish_incremental.

-- (From XM_PARSER)

obsolete

Use finish_incremental instead.

feature -- Setting

set_callbacks (a_callbacks: like callbacks)

-- Set callbacks to a_callbacks.

-- (From XM_CALLBACKS_SOURCE)

require
a_callback_not_void: a_callback /= Void
set_dtd_callbacks (a_callbacks: like dtd_callbacks)

-- Set dtd_callbacks to a_callbacks.

-- (From XM_DTD_CALLBACKS_SOURCE)

require
a_callback_not_void: a_callback /= Void

feature -- Copy

copy_string_mode (other: XM_STRING_MODE)

-- Copy string mode.

-- (From XM_STRING_MODE)

require
other_not_void: other /= Void
ensure
copied: same_string_mode (other)

feature -- Error reporting

is_correct: BOOLEAN

-- Has no error been detected?

-- (From XM_PARSER)

last_error: INTEGER

-- Code of last error
-- (See XM_ERROR_CODES.)

-- (From XM_PARSER)

last_error_description: STRING

-- Textual description of last error

-- (From XM_PARSER)

require
has_error: not is_correct
last_error_extended_description: STRING

-- Verbose textual description of last error

-- (From XM_PARSER)

require
has_error: not is_correct
ensure
description_not_void: Result /= Void
new_stop_on_error_filter: XM_PARSER_STOP_ON_ERROR_FILTER

-- Create a stop on error filter that not only
-- stops forwarding events but also stops the
-- parser if the error comes from the preceding
-- event filters.
-- The result must be used only for processing events
-- coming from the current parser.

-- (From XM_PARSER)

ensure
result_not_void: Result /= Void
new_stop_on_error_filter_next (a_next: XM_CALLBACKS): XM_PARSER_STOP_ON_ERROR_FILTER

-- Like 'new_stop_on_error_filter' with next
-- filter.

-- (From XM_PARSER)

require
a_next_not_void: a_next /= Void
ensure
result_not_void: Result /= Void

feature -- Error

byte_position: INTEGER

-- Current byte index

ensure
definition: Result = position.byte_index
column: INTEGER

-- Current column

ensure
definition: Result = position.column
error_header: STRING

-- Header for error message
-- (:::)

ensure
error_header_not_void: Result /= Void
line: INTEGER

-- Current line

ensure
definition: Result = position.row
position: XM_POSITION

-- Current position in the source of the XML document

-- (From XM_PARSER)

ensure
position_not_void: Result /= Void
positions: DS_LIST [XM_POSITION]

-- Current stack of positions, starting with the current entity.

-- (From XM_PARSER)

ensure
positions_not_void: Result /= Void

feature -- Obsolete error

filename: STRING

-- Current file

obsolete

Use position.source_name

ensure
filename_not_void: Result /= Void
source: XM_SOURCE

-- Source of the XML document beeing parsed

-- (From XM_PARSER)

obsolete

Use position.source_name

ensure
source_not_void: Result /= Void

feature -- Constants

xml_err_none: INTEGER

-- No error occurred

-- (From XM_ERROR_CODES)

xml_err_unknown: INTEGER

-- An unknown error occurred

-- (From XM_ERROR_CODES)

feature -- Obsolete

parse_stream (a_stream: KI_CHARACTER_INPUT_STREAM)

-- Parse XML Document from input stream.

obsolete

[020815] Use parse_from_stream instead.

require
a_stream_not_void: a_stream /= Void
is_open_read: a_stream.is_open_read

feature {XM_STRING_MODE} -- Implementation

string_mode: INTEGER

-- STRING/UC_STRING mode

-- (From XM_STRING_MODE)

invariant

scanner_not_void: scanner /= Void
scanners_not_void: scanners /= Void
no_void_scanner: not scanners.has (Void)

-- From XM_PARSER
entity_resolver_not_void: entity_resolver /= Void
dtd_resolver_not_void: dtd_resolver /= Void

mode_set: BOOLEAN_.nxor (<<is_string_mode_ascii, is_string_mode_mixed, is_string_mode_unicode, is_string_mode_latin1>>)

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

-- From YY_PARSER_SKELETON
yyss_not_void: yyss /= Void
yytranslate_not_void: yytranslate /= Void
yyr1_not_void: yyr1 /= Void
yytypes1_not_void: yytypes1 /= Void
yytypes2_not_void: yytypes2 /= Void
yydefact_not_void: yydefact /= Void
yydefgoto_not_void: yydefgoto /= Void
yypact_not_void: yypact /= Void
yypgoto_not_void: yypgoto /= Void
yytable_not_void: yytable /= Void
yycheck_not_void: yycheck /= Void

end