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