Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Partial parsing #88

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Commits on Jan 6, 2017

  1. Add partial parsing api.

    canatella committed Jan 6, 2017
    Configuration menu
    Copy the full SHA
    166371b View commit details
    Browse the repository at this point in the history
  2. Differenciate end of input failures from other failures.

    For partial input parsing, we need to know when failure is caused by missing
    data so that we can retry parsing later when we have more data.
    
    This commit adds a need_data boolean flag alongs the failed one. It adds a stop
    function to set that flag and propagate the failure. It replaces checks for
    failure with a check on both failed and need_data flags. It also adds a eos
    function to check for end of input. It also replaces the fail calls due to
    end of input by stop calls.
    canatella committed Jan 6, 2017
    Configuration menu
    Copy the full SHA
    55f568f View commit details
    Browse the repository at this point in the history
  3. Make json object stack explicit.

    As of now, the program stack is implicitly used to build the json object
    tree. For partial parsing support, we cannot use the program stack as parsing
    can be called at anytime. This commit adds a values stack and uses it to
    transmit value back along the object tree. All parsing functions now return void
    and instead pushes their result on the stack. The functions needing the result
    of other parsing functions (mostly for arrays and objects) read values from the
    stack and pop them.
    canatella committed Jan 6, 2017
    Configuration menu
    Copy the full SHA
    cd6e3a9 View commit details
    Browse the repository at this point in the history
  4. Use value stack for checking maximum depth.

    As we now have an explicit stack, we don't need the depth variable argument to
    count the recursion levels. We can simply use the value stack size instead.
    canatella committed Jan 6, 2017
    Configuration menu
    Copy the full SHA
    1771606 View commit details
    Browse the repository at this point in the history
  5. Split json value parse function.

    For partial support, when continuing parsing, we need to restart in the same
    state as we left. For that, we need to skip some actions if they were already
    done. Left as is, the code would be littered with ifs so refactor the parse_json
    function into multiple function, one per type of objects.
    canatella committed Jan 6, 2017
    Configuration menu
    Copy the full SHA
    4cbea0b View commit details
    Browse the repository at this point in the history
  6. Add explicit state management.

    For partial parsing support, we need to remember what we were doing so that we
    can continue parsing. This commit adds an enum with all our parsing states and a
    states stack to store the current states.
    canatella committed Jan 6, 2017
    Configuration menu
    Copy the full SHA
    4e0e31c View commit details
    Browse the repository at this point in the history
  7. Store builded object on the stack.

    For partial building, we need to temporary store the object being build as we
    maybe interrupted. This commits change object and array parsing to use the
    values stack has a temporary place for storing the object being build.
    canatella committed Jan 6, 2017
    Configuration menu
    Copy the full SHA
    c9d9436 View commit details
    Browse the repository at this point in the history
  8. Store parser position.

    For parsing partial json, we need to be able to restart parsing from a valid
    position in the input stream. This commit stores the current position when
    switching state and restores it when more data is needed so that when parsing
    again, the parser restarts at the right position.
    canatella committed Jan 6, 2017
    Configuration menu
    Copy the full SHA
    44d93d8 View commit details
    Browse the repository at this point in the history
  9. Implement partial parsing support.

    This commit implements a consume method that takes a chunk of json, append it to
    the current data and parses it.
    canatella committed Jan 6, 2017
    Configuration menu
    Copy the full SHA
    ab45c17 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    e6b1df6 View commit details
    Browse the repository at this point in the history
  11. Add chunk parsing tests.

    canatella committed Jan 6, 2017
    Configuration menu
    Copy the full SHA
    5ea3854 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    7d97cfc View commit details
    Browse the repository at this point in the history