Simples fixes to the parser, add is_valid_start_symbol and updated parse_json.

This commit is contained in:
jvelilla
2009-08-14 11:19:54 +00:00
parent aed8d1a516
commit 7a31e80f90

View File

@@ -63,11 +63,17 @@ feature -- Commands
parse_json: ?JSON_VALUE is
-- Parse JSON data `representation'
-- start ::= object | array
do
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"