note description: "Decimal number parsers, whose BNF syntax follows: %N sign ::= '+' | '-' %N digit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' %N indicator ::= 'e' | 'E' %N digits ::= digit [digit]... %N point ::= '.' | ',' %N decimal-part ::= digits point [digits] | [point] digits %N exponent-part ::= indicator [sign] digits %N infinity ::= 'Infinity' | 'Inf' %N nan ::= 'NaN' | 'sNaN' %N numeric-value ::= decimal-part [exponent-part] | infinity %N numeric-string ::= [sign] numeric-value | nan%N" library: "Gobo Eiffel Decimal Arithmetic Library" copyright: "Copyright (c) 2004, Paul G. Crismer and others" license: "MIT License" date: "$Date: 2016-05-06 19:15:38 +0000 (Fri, 06 May 2016) $" revision: "$Revision: 98678 $" class interface MA_DECIMAL_TEXT_PARSER create make feature -- Access sign: INTEGER_32 -- Sign of last parsed decimal exponent_sign: INTEGER_32 -- Sign of exponent of last parsed decimal state: INTEGER_32 -- Last state of parsing finite state automaton error_code: INTEGER_32 -- Description of last error coefficient_begin: INTEGER_32 -- Index of last parsed coefficient begin coefficient_end: INTEGER_32 -- Index of last parsed coefficient end coefficient_count: INTEGER_32 -- Number of characters in coefficient part fractional_part_count: INTEGER_32 -- Number of characters in the fractional part exponent_as_double: REAL_64 -- Exponent expressed as DOUBLE exponent_begin: INTEGER_32 -- Index of last parsed first exponent character exponent_end: INTEGER_32 -- Index of last parsed last exponent character exponent_significant_digits: INTEGER_32 -- Count of significant digits in exponent exponent_count: INTEGER_32 -- Count of significant digits in exponent; -- Synonym of exponent_significant_digits decimal_point_index: INTEGER_32 -- Index of decimal point if any last_parsed: detachable STRING_8 -- Last parsed string feature -- Status report error: BOOLEAN -- Has there been an error in last parse operation? is_comma_allowed: BOOLEAN -- Is ',' allowed as fractional part separator? is_infinity: BOOLEAN -- Is last parsed number an 'Infinity'? is_nan: BOOLEAN -- Is last parsed number a 'Not a Number'? is_snan: BOOLEAN -- Is last parsed number a 'Signaling NaN'? has_point: BOOLEAN -- Has last parsed number a fractional part? has_exponent: BOOLEAN -- Has last parsed number an exponent? decimal_point_is_comma: BOOLEAN -- Has last parsed number a comma as decimal point? feature -- Basic operations parse (s: STRING_8) -- Parse s. ensure then last_parsed_string_affected: last_parsed = s parse_with_decimal_point_comma (s: STRING_8) -- Parse s with comma as decimal point. require s_not_void: s /= Void s_not_empty: not s.is_empty ensure no_mode_change: is_comma_allowed = old is_comma_allowed last_parsed_string_affected: last_parsed = s last_decimal_not_void_when_no_error: not error implies last_decimal /= Void parse_ctx (s: STRING_8; ctx: MA_DECIMAL_CONTEXT; parse_comma_as_decimal_point: BOOLEAN) -- Parse s using ctx wrt parse_comma_as_decimal_point. require s_not_void: s /= Void s_not_empty: not s.is_empty ensure no_mode_change: is_comma_allowed = old is_comma_allowed last_parsed_string_affected: last_parsed = s last_decimal_not_void_when_no_error: not error implies last_decimal /= Void feature -- Constants State_start: INTEGER_32 = 1 State_nan: INTEGER_32 = 2 State_snan: INTEGER_32 = 3 State_starting_point: INTEGER_32 = 4 State_infinity: INTEGER_32 = 5 State_integer_part: INTEGER_32 = 6 State_point: INTEGER_32 = 7 State_fractional_part: INTEGER_32 = 8 State_exponent: INTEGER_32 = 9 State_sign: INTEGER_32 = 10 State_comma: INTEGER_32 = 11 State_start_exponent: INTEGER_32 = 12 State_exponent_sign: INTEGER_32 = 13 State_error: INTEGER_32 = 14 invariant decimal_point_is_comma_implies_has_fractional_part: decimal_point_is_comma implies has_point end -- class MA_DECIMAL_TEXT_PARSER
Generated by ISE EiffelStudio