-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iterative Parsing (for issue #35) #76
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The build currently fails (due to
You should move the |
miloyip
added a commit
that referenced
this pull request
Jul 18, 2014
Iterative Parsing (for issue #35)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implementation Overview
This pull request provides an iterative(non-recursive) implementation of JSON parsing.
It tries to resolve the issue Research on using custom stack instead of call-stack in Reader #35 by:
Implementation Details
This pull request adds a new flag
kParseIterativeFlag
toParseFlag
.Parsing work with this flag will be directed to
GenericReader::IterativeParse
, which is the entry point of this iterative parser.Then the parser will traverse the given token stream and make transitions on a state machine.
The state transition table is manually encoded in a static array, which is in function
GenericReader::Predict
.And the action code for every transition is in function
GenericReader::Transit
.Performance Report
Performance tests have been taken among:
kParseDefaultFlags
(recursive parser, without in-situ)kParseIterativeFlag
(iterative parser, without in-situ)kParseInsituFlag
(recursive parser, with in-situ)kParseIterativeFlag | kParseInsituFlag
(iterative parser, with in-situ)I expected the parsers with
kParseIterativeFlag
are either slower or quicker than their counterparts.But the iterative parser without in-situ flag runs exceptionally slower than other parsers, while the iterative parser with in-situ being the most quick one.
@pah pointed out this may be compiler-specific in Research on using custom stack instead of call-stack in Reader #35 (comment).