Simples fixes to the parser, add is_valid_start_symbol and updated parse_json.
This commit is contained in:
@@ -63,11 +63,17 @@ feature -- Commands
|
|||||||
|
|
||||||
parse_json: ?JSON_VALUE is
|
parse_json: ?JSON_VALUE is
|
||||||
-- Parse JSON data `representation'
|
-- Parse JSON data `representation'
|
||||||
|
-- start ::= object | array
|
||||||
do
|
do
|
||||||
|
if is_valid_start_symbol then
|
||||||
Result := parse
|
Result := parse
|
||||||
if extra_elements then
|
if extra_elements then
|
||||||
is_parsed := False
|
is_parsed := False
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
is_parsed := False
|
||||||
|
report_error ("Syntax error unexpected token, expecting `{' or `['")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
parse: ?JSON_VALUE is
|
parse: ?JSON_VALUE is
|
||||||
@@ -422,6 +428,12 @@ feature {NONE} -- Implementation
|
|||||||
Result := has_next
|
Result := has_next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
is_valid_start_symbol : BOOLEAN
|
||||||
|
-- expecting `{' or `[' as start symbol
|
||||||
|
do
|
||||||
|
Result := representation.starts_with ("{") or representation.starts_with ("[")
|
||||||
|
end
|
||||||
|
|
||||||
feature {NONE} -- Constants
|
feature {NONE} -- Constants
|
||||||
|
|
||||||
false_id: STRING is "false"
|
false_id: STRING is "false"
|
||||||
|
|||||||
Reference in New Issue
Block a user