    indexing
    	description: "Lexical analyzers"
    	legal: "See notice at end of class."
    	status: "See notice at end of class."
    	date: "$Date: 2006-01-22 18:25:44 -0800 (Sun, 22 Jan 2006) $"
    	revision: "$Revision: 56675 $"

    class interface
    	LEXICAL

    create
    	make
    			-- Set up lexical analyzer for retrieval.

    	make_new
    			-- Set up a new lexical analyzer

    feature -- Initialization

    	make
    			-- Set up lexical analyzer for retrieval.

    	make_new
    			-- Set up a new lexical analyzer

    feature -- Access

    	buffer: STRING_8
    			-- Buffer filled by fill_buffer
    			-- (from TEXT_FILLER)

    	char_buffered_number: INTEGER_32
    			-- Number of characters read and written
    			-- in buffer since the beginning
    			-- (from TEXT_FILLER)

    	column_nb_array: LEX_ARRAY [INTEGER_32]
    			-- Array recording the column numbers of each buffered
    			-- character (the column number of the `i'-th character in the
    			-- buffer is the `i'-th entry of column_nb_array)
    			-- (from TEXT_FILLER)

    	end_of_text: BOOLEAN
    			-- Has end of input been reached?

    	file_name: STRING_8
    			-- Name of input file
    			-- (from TEXT_FILLER)

    	generating_type: STRING_8
    			-- Name of current object's generating type
    			-- (type of which it is a direct instance)
    			-- (from ANY)

    	generator: STRING_8
    			-- Name of current object's generating class
    			-- (base class of the type of which it is a direct instance)
    			-- (from ANY)

    	keyword_code (word: STRING_8): INTEGER_32
    			-- Keyword code for `word'.
    			-- -1 if not a keyword.

    	keyword_string (n: INTEGER_32): STRING_8
    			-- Keyword corresponding to keyword code `n'
    		ensure
    			keyword_found: Result /= Void

    	last_is_keyword: BOOLEAN
    			-- Is the last read token a keyword?
    		ensure
    			Result = is_keyword (last_string_read)

    	last_keyword_code: INTEGER_32
    			-- Keyword code for last token.
    			-- -1 if not a keyword.

    	last_keyword_text: STRING_8
    			-- Last read string if recognized as a keyword;
    			-- void otherwise.

    	last_string_read: STRING_8
    			-- String value of last token read

    	last_token: TOKEN
    			-- Last token read

    	line_nb_array: LEX_ARRAY [INTEGER_32]
    			-- Array recording the line numbers of each buffered
    			-- character (the line number of the `i'-th character in the
    			-- buffer is the `i'-th entry of line_nb_array)
    			-- (from TEXT_FILLER)

    	no_token: INTEGER_32 is 0
    			-- Token type for no token recognized.

    	other_possible_tokens: ARRAY [INTEGER_32]
    			-- Other candidate types for last recognized token

    	token_column_number: INTEGER_32
    			-- Column number of last token read
    		ensure
    			Result >= 1

    	token_line_number: INTEGER_32
    			-- Line number of last token read
    		ensure
    			Result >= 1

    	token_type: INTEGER_32
    			-- Type of last token read

    feature -- Comparison

    	frozen deep_equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void
    			-- or attached to isomorphic object structures?
    			-- (from ANY)
    		ensure -- from ANY
    			shallow_implies_deep: standard_equal (some, other) implies Result
    			both_or_none_void: (some = Void) implies (Result = (other = Void))
    			same_type: (Result and (some /= Void)) implies some.same_type (other)
    			symmetric: Result implies deep_equal (other, some)

    	frozen equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void or attached
    			-- to objects considered equal?
    			-- (from ANY)
    		ensure -- from ANY
    			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.is_equal (other))

    	is_equal (other: like Current): BOOLEAN
    			-- Is `other' attached to an object considered
    			-- equal to current object?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			symmetric: Result implies other.is_equal (Current)
    			consistent: standard_is_equal (other) implies Result

    	frozen standard_equal (some: ANY; other: like arg #1): BOOLEAN
    			-- Are `some' and `other' either both void or attached to
    			-- field-by-field identical objects of the same type?
    			-- Always uses default object comparison criterion.
    			-- (from ANY)
    		ensure -- from ANY
    			definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.standard_is_equal (other))

    	frozen standard_is_equal (other: like Current): BOOLEAN
    			-- Is `other' attached to an object of the same type
    			-- as current object, and field-by-field identical to it?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			same_type: Result implies same_type (other)
    			symmetric: Result implies other.standard_is_equal (Current)

    feature -- Status report

    	conforms_to (other: ANY): BOOLEAN
    			-- Does type of current object conform to type
    			-- of `other' (as per Eiffel: The Language, chapter 13)?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void

    	same_type (other: ANY): BOOLEAN
    			-- Is type of current object identical to type of `other'?
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			definition: Result = (conforms_to (other) and other.conforms_to (Current))

    feature -- Status setting

    	close_file
    			-- Close input file if any.
    			-- (from TEXT_FILLER)
    		ensure -- from TEXT_FILLER
    			file_is_void: file = Void

    	create_buffers (buf, lin: INTEGER_32)
    			-- Create buffers and mask.
    			-- (from TEXT_FILLER)
    		ensure -- from TEXT_FILLER
    			buffer_size = buf
    			line_length = lin

    	exclude (i, j: INTEGER_32)
    			-- Discard columns `i' to `j' from the input.
    			-- A zero value for `j' means all the way to the
    			-- end of the line.
    			-- (from TEXT_FILLER)
    		require -- from TEXT_FILLER
    			i_positive: i > 0
    			j_null_or_greater_than_i: j = 0 or j >= i

    	fill_buffer (b: INTEGER_32)
    			-- Copy the characters from the `b'+1-st to the last one in
    			-- the beginning of the buffer and then fill the end of
    			-- the buffer with the text. This routine skips the columns
    			-- forbidden by exclude, but always puts '\n' at the end
    			-- of a line; the line and column numbers are those of
    			-- the characters in the real file.
    			-- (from TEXT_FILLER)
    		require -- from TEXT_FILLER
    			buffer_created: buffer /= Void
    			c_buffer_created: column_nb_array /= Void
    			l_buffer_created: line_nb_array /= Void
    			b_not_too_large: b <= buffer_size
    			b_positive: b >= 0

    	fill_whole_buffer
    			-- Fill with new characters.
    			-- (from TEXT_FILLER)

    	resize_and_fill_buffer (buf, b: INTEGER_32)
    			-- When increasing buffer_size: resize the buffer and then
    			-- fill the new buffer.
    			-- When decreasing buffer_size: fill the buffer and then
    			-- resize it.
    			-- When filling the buffer: Copy the characters from the
    			-- `b'+1-st to the last one (of the buffer before resizing) in
    			-- the beginning of the buffer and then fill
    			-- the end of the buffer (after resizing) with the text.
    			-- This routine skips the columns
    			-- forbidden by exclude, but always puts '\n' at the end
    			-- of a line; the line and column numbers are those of
    			-- the characters in the real file.
    			-- (from TEXT_FILLER)
    		require -- from TEXT_FILLER
    			buffer_created: buffer /= Void
    			c_buffer_created: column_nb_array /= Void
    			l_buffer_created: line_nb_array /= Void
    			b_not_too_large: b <= buffer_size
    			b_positive: b >= 0
    		ensure -- from TEXT_FILLER
    			buffer_size = buf

    	set_file (f_name: STRING_8)
    			-- Use `f_name' as input file.
    			-- (from TEXT_FILLER)
    		require -- from TEXT_FILLER
    			file_name_not_void: f_name /= Void

    	set_separator_type (type: INTEGER_32)
    			-- Set `type' to be the type of tokens
    			-- used as separators.
    		ensure
    			separator_token_type = type

    	set_string (s: STRING_8)
    			-- Use `s' as the input string.
    			-- (from TEXT_FILLER)
    		require -- from TEXT_FILLER
    			string_not_void: s /= Void

    feature -- Duplication

    	copy (other: like Current)
    			-- Update current object using fields of object attached
    			-- to `other', so as to yield equal objects.
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    			type_identity: same_type (other)
    		ensure -- from ANY
    			is_equal: is_equal (other)

    	frozen deep_copy (other: like Current)
    			-- Effect equivalent to that of:
    			--		copy (`other' . deep_twin)
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    		ensure -- from ANY
    			deep_equal: deep_equal (Current, other)

    	frozen deep_twin: like Current
    			-- New object structure recursively duplicated from Current.
    			-- (from ANY)
    		ensure -- from ANY
    			deep_equal: deep_equal (Current, Result)

    	frozen standard_copy (other: like Current)
    			-- Copy every field of `other' onto corresponding field
    			-- of current object.
    			-- (from ANY)
    		require -- from ANY
    			other_not_void: other /= Void
    			type_identity: same_type (other)
    		ensure -- from ANY
    			is_standard_equal: standard_is_equal (other)

    	frozen standard_twin: like Current
    			-- New object field-by-field identical to `other'.
    			-- Always uses default copying semantics.
    			-- (from ANY)
    		ensure -- from ANY
    			standard_twin_not_void: Result /= Void
    			equal: standard_equal (Result, Current)

    	frozen twin: like Current
    			-- New object equal to `Current'
    			-- twin calls copy; to change copying/twining semantics, redefine copy.
    			-- (from ANY)
    		ensure -- from ANY
    			twin_not_void: Result /= Void
    			is_equal: Result.is_equal (Current)

    feature -- Basic operations

    	frozen default: like Current
    			-- Default value of object's type
    			-- (from ANY)

    	frozen default_pointer: POINTER
    			-- Default value of type `POINTER'
    			-- (Avoid the need to write `p'.default for
    			-- some `p' of type `POINTER'.)
    			-- (from ANY)

    	default_rescue
    			-- Process exception for routines with no Rescue clause.
    			-- (Default: do nothing.)
    			-- (from ANY)

    	frozen do_nothing
    			-- Execute a null action.
    			-- (from ANY)

    feature -- Implementation

    	buffer_size: INTEGER_32
    			-- Buffer size
    			-- (from TEXT_FILLER)

    	dfa: FIXED_DFA
    			-- Automaton used for the parsing

    feature -- Input

    	buffer_item_code (c: INTEGER_32): INTEGER_32

    	get_any_token
    			-- Try to read a new token.
    			-- Recognize longest possible string.
    		require
    			dfa_not_void: dfa /= Void
    			not_end_of_text: not end_of_text
    			buffers_created: buffer /= Void

    	get_fixed_token (l: INTEGER_32)
    			-- Read new token that matches one of the
    			-- lexical grammar's regular expressions.
    			-- Recognize longest possible string with
    			-- length less than or equal to `l'.
    		require
    			dfa_not_void: dfa /= Void
    			not_end_of_text: not end_of_text
    			buffers_created: buffer /= Void

    	get_short_token
    			-- Read shortest token that matches one of the
    			-- lexical grammar's regular expressions.
    		require
    			dfa_not_void: dfa /= Void
    			not_end_of_text: not end_of_text
    			buffers_created: buffer /= Void

    	get_token
    			-- Read new token matching one of the regular
    			-- expressions of the lexical grammar.
    			-- Recognize longest possible string;
    			-- ignore unrecognized tokens and separators.
    		ensure
    			end_of_text or (token_type /= separator_token_type and token_type /= 0)

    feature -- Output

    	io: STD_FILES
    			-- Handle to standard file setup
    			-- (from ANY)

    	out: STRING_8
    			-- New string containing terse printable representation
    			-- of current object
    			-- Was declared in ANY as synonym of tagged_out.
    			-- (from ANY)

    	print (some: ANY)
    			-- Write terse external representation of `some'
    			-- on standard output.
    			-- (from ANY)

    	frozen tagged_out: STRING_8
    			-- New string containing terse printable representation
    			-- of current object
    			-- Was declared in ANY as synonym of out.
    			-- (from ANY)

    	trace
    			-- Output information about the analyzer's
    			-- current status.

    feature -- Platform

    	operating_environment: OPERATING_ENVIRONMENT
    			-- Objects available from the operating system
    			-- (from ANY)

    invariant
    		-- from ANY
    	reflexive_equality: standard_is_equal (Current)
    	reflexive_conformance: conforms_to (Current)

    indexing
    	copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
    	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
    	source: "[
    		Eiffel Software
    		356 Storke Road, Goleta, CA 93117 USA
    		Telephone 805-685-1006, Fax 805-685-6869
    		Website http://www.eiffel.com
    		Customer support http://support.eiffel.com
    	]"

    end -- class LEXICAL