Centralize retrieval of new characters when parsing
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
jsonlib |
New
|
Undecided
|
Unassigned |
Bug Description
Currently, the parser uses recursive functions to build an object representing a given JSON expression. This is bad design, because it makes it more difficult to handle streaming parsing (such as from network or file). The parser should probably be redesigned to use something like the state machine in the pure-Python implementation:
int parse (text)
state = ParserState ()
for char in text:
if char == '{': parse_object_start (state)
elif char == '}': parse_dict_end (state)
etc...
Once that's working, then parse() can be rewritten to accept streams.
Also, parse should allow the called functions to set the current state (IN_STRING, IN_NUMBER, AFTER_VALUE, etc). This will be used to decide which event function to call.