Optimized code, and removed extra dependencies.
Added void-safe version
This commit is contained in:
27
json/json-safe.ecf
Normal file
27
json/json-safe.ecf
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-5-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-5-0 http://www.eiffel.com/developers/xml/configuration-1-5-0.xsd" name="json" uuid="4E21C3BD-7951-4C6E-A673-431E762D7414" library_target="json">
|
||||
<target name="json">
|
||||
<root all_classes="true"/>
|
||||
<option trace="false" profile="false" debug="false" warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="obsolete" namespace="EJSON.Library">
|
||||
<assertions/>
|
||||
<warning name="export_class_missing" enabled="false"/>
|
||||
<warning name="old_verbatim_strings" enabled="false"/>
|
||||
<warning name="syntax" enabled="false"/>
|
||||
<warning name="vjrv" enabled="false"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf" readonly="true"/>
|
||||
<cluster name="json" location=".\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
</file_rule>
|
||||
<file_rule>
|
||||
<exclude>^/scanner$</exclude>
|
||||
<exclude>^/visitor$</exclude>
|
||||
</file_rule>
|
||||
<cluster name="scanner" location=".\scanner\"/>
|
||||
<cluster name="visitor" location=".\visitor\"/>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
@@ -2,7 +2,7 @@
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-3-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-3-0 http://www.eiffel.com/developers/xml/configuration-1-3-0.xsd" name="json" uuid="4E21C3BD-7951-4C6E-A673-431E762D7414" library_target="json">
|
||||
<target name="json">
|
||||
<root all_classes="true"/>
|
||||
<option trace="false" profile="false" debug="false" warning="true" namespace="EJSON.Library">
|
||||
<option trace="false" profile="false" debug="false" warning="true" full_class_checking="true" namespace="EJSON.Library">
|
||||
<assertions/>
|
||||
<warning name="export_class_missing" enabled="false"/>
|
||||
<warning name="old_verbatim_strings" enabled="false"/>
|
||||
@@ -10,25 +10,6 @@
|
||||
<warning name="vjrv" enabled="false"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf" readonly="true"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf" readonly="true"/>
|
||||
<cluster name="dp_pattern" location="${GOBO}\library\pattern\">
|
||||
<cluster name="dp_bridge" location="$|bridge\"/>
|
||||
<cluster name="dp_command" location="$|command\"/>
|
||||
</cluster>
|
||||
<cluster name="ds_structure" location="${GOBO}\library\structure\">
|
||||
<cluster name="ds_container" location="$|container\"/>
|
||||
<cluster name="ds_dispenser" location="$|dispenser\"/>
|
||||
<cluster name="ds_list" location="$|list\"/>
|
||||
<cluster name="ds_set" location="$|set\"/>
|
||||
<cluster name="ds_sort" location="$|sort\"/>
|
||||
<cluster name="ds_support" location="$|support\"/>
|
||||
<cluster name="ds_table" location="$|table\"/>
|
||||
</cluster>
|
||||
<cluster name="dt_time" location="${GOBO}\library\time\">
|
||||
<cluster name="dt_clock" location="$|clock\"/>
|
||||
<cluster name="dt_date" location="$|date\"/>
|
||||
<cluster name="dt_time_zone" location="$|time_zone\"/>
|
||||
</cluster>
|
||||
<cluster name="json" location=".\" recursive="true">
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
@@ -42,63 +23,5 @@
|
||||
<cluster name="scanner" location=".\scanner\"/>
|
||||
<cluster name="visitor" location=".\visitor\"/>
|
||||
</cluster>
|
||||
<cluster name="kl_kernel" location="${GOBO}\library\kernel\">
|
||||
<cluster name="kl_basic" location="$|basic\"/>
|
||||
<cluster name="kl_elks" location="$|elks\"/>
|
||||
<cluster name="kl_io" location="$|io\"/>
|
||||
<cluster name="kl_misc" location="$|misc\"/>
|
||||
<cluster name="kl_unicode" location="$|unicode\"/>
|
||||
<cluster name="kl_support" location="$|support\"/>
|
||||
<cluster name="kl_spec" location="$|spec\">
|
||||
<cluster name="kl_spec_ise" location="$|ise\"/>
|
||||
</cluster>
|
||||
</cluster>
|
||||
<cluster name="lx_lexical" location="${GOBO}\library\lexical\">
|
||||
<cluster name="lx_automaton" location="$|automaton\"/>
|
||||
<cluster name="lx_error" location="$|error\"/>
|
||||
<cluster name="lx_generation" location="$|generation\"/>
|
||||
<cluster name="lx_lex" location="$|lex\"/>
|
||||
<cluster name="lx_regexp" location="$|regexp\"/>
|
||||
<cluster name="lx_scanner" location="$|scanner\"/>
|
||||
<cluster name="lx_skeleton" location="$|skeleton\"/>
|
||||
<cluster name="lx_support" location="$|support\"/>
|
||||
</cluster>
|
||||
<cluster name="ma_math" location="${GOBO}\library\math\">
|
||||
<cluster name="ma_decimal" location="$|decimal\"/>
|
||||
</cluster>
|
||||
<cluster name="pr_parse" location="${GOBO}\library\parse\">
|
||||
<cluster name="pr_error" location="$|error\"/>
|
||||
<cluster name="pr_fsm" location="$|fsm\"/>
|
||||
<cluster name="pr_generation" location="$|generation\"/>
|
||||
<cluster name="pr_grammar" location="$|grammar\"/>
|
||||
<cluster name="pr_parser" location="$|parser\"/>
|
||||
<cluster name="pr_skeleton" location="$|skeleton\"/>
|
||||
<cluster name="pr_support" location="$|support\"/>
|
||||
<cluster name="pr_yacc" location="$|yacc\"/>
|
||||
</cluster>
|
||||
<cluster name="rx_regexp" location="${GOBO}\library\regexp\">
|
||||
<cluster name="rx_interface" location="$|interface\"/>
|
||||
<cluster name="rx_pcre" location="$|pcre\"/>
|
||||
<cluster name="rx_support" location="$|support\"/>
|
||||
</cluster>
|
||||
<cluster name="st_string" location="${GOBO}\library\string\">
|
||||
<cluster name="st_collation" location="$|collation\"/>
|
||||
<cluster name="st_unicode" location="$|unicode\"/>
|
||||
<cluster name="st_support" location="$|support\"/>
|
||||
<cluster name="st_date" location="$|date\"/>
|
||||
<cluster name="st_formatter" location="$|formatter\">
|
||||
<cluster name="st_general" location="$|general\"/>
|
||||
<cluster name="st_parameter" location="$|parameter\"/>
|
||||
</cluster>
|
||||
</cluster>
|
||||
<cluster name="ut_utility" location="${GOBO}\library\utility\">
|
||||
<cluster name="ut_error" location="$|error\"/>
|
||||
<cluster name="ut_formatter" location="$|formatter\"/>
|
||||
<cluster name="ut_command" location="$|command\"/>
|
||||
<cluster name="ut_config" location="$|config\"/>
|
||||
<cluster name="ut_support" location="$|support\"/>
|
||||
<cluster name="ut_transcoder" location="$|transcoder\"/>
|
||||
<cluster name="ut_uri" location="$|uri\"/>
|
||||
</cluster>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
@@ -372,38 +372,30 @@ feature {NONE} -- Implementation
|
||||
is_a_valid_number (a_number: STRING): BOOLEAN is
|
||||
-- is 'a_number' a valid number based on this regular expression
|
||||
-- "-?(?: 0|[1-9]\d+)(?: \.\d+)?(?: [eE][+-]?\d+)?\b"?
|
||||
local
|
||||
word_set: RX_CHARACTER_SET
|
||||
regexp: RX_PCRE_REGULAR_EXPRESSION
|
||||
number_regex: STRING
|
||||
do
|
||||
create regexp.make
|
||||
create word_set.make_empty
|
||||
a_number.right_adjust
|
||||
a_number.left_adjust
|
||||
word_set.add_string ("0123456789.eE+-")
|
||||
regexp.set_word_set (word_set)
|
||||
number_regex := "-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?\b"
|
||||
regexp.compile (number_regex)
|
||||
if regexp.matches (a_number) then
|
||||
Result := a_number.is_equal (regexp.captured_substring (0))
|
||||
end
|
||||
Result := a_number.is_real_sequence
|
||||
end
|
||||
|
||||
is_a_valid_unicode (a_unicode: STRING): BOOLEAN is
|
||||
-- is 'a_unicode' a valid unicode based on this regular expression
|
||||
-- "\\u[0-9a-fA-F]{4}"
|
||||
local
|
||||
regexp: RX_PCRE_REGULAR_EXPRESSION
|
||||
unicode_regex: STRING
|
||||
i: INTEGER
|
||||
do
|
||||
create regexp.make
|
||||
unicode_regex := "\\u[0-9a-fA-F]{4}"
|
||||
regexp.compile (unicode_regex)
|
||||
if regexp.matches (a_unicode) then
|
||||
Result := True
|
||||
check
|
||||
is_valid: a_unicode.is_equal (regexp.captured_substring (0))
|
||||
if a_unicode.count = 6 and then a_unicode [1] = '\' and then a_unicode [2] = 'u' then
|
||||
from
|
||||
Result := True
|
||||
i := 3
|
||||
until
|
||||
i > 6
|
||||
loop
|
||||
inspect a_unicode [i]
|
||||
when '0'..'9', 'a'..'f', 'A'..'F' then
|
||||
else
|
||||
Result := False
|
||||
i := 6
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user