Add a basic Pratt parser#27
Merged
Merged
Conversation
This initial parser can parse numbers, arithmetic operations and numbers.
IAstFactory needs to know the whole extend of a node, e.g. to replace it. Example: factory gets BinaryNode callback and it should replace a node with a result. The binary node might hav ebeen deeply nested. The range parameter of callbacks is used to know the whole extent of original formula that was used to create the binary node. Thus callback can combine left side, replacement for the binary node, and left side.
This file contains hidden or 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
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.
The PR adds a basic Pratt parser that can parse numbers, arithmetic operations and numbers. In 3.0, it should replace current descent recursive parser.
What is a Pratt parser? A parser uniquely suited to parsing expressions. Instead of mucking around with Expressions, Factors, Terms, Atoms and all that rather ugly stuff in a recursive parser, Pratt parser is a modular and it's core is super simple (=maintainable). Since every formula in Excel is an expression, it's a match made in heaven. Here are some resources
Anyway, here are some other reasons why it's a great fit: