Refactor Parser to separate expression parsing from evaluation. #45
Merged
Phergus merged 1 commit intoRPTools:developfrom Jul 12, 2020
Merged
Refactor Parser to separate expression parsing from evaluation. #45Phergus merged 1 commit intoRPTools:developfrom
Phergus merged 1 commit intoRPTools:developfrom
Conversation
…VariableResolver an evaluation time argument so clients can re-use Expressions, once parsed, multiple times over. Fixes RPTools#44
nmeier
added a commit
to nmeier/dicelib
that referenced
this pull request
Jul 11, 2020
Supports API where VariableResolver is an evaluation time argument so clients can re-use Expressions, once parsed, multiple times over. Changes: * refactor all functions that now get the variable resolver as argument * update unittest * update ExpressionParser with a protected method that allows overriding Parser (will be used in MapTool)
nmeier
added a commit
to nmeier/maptool
that referenced
this pull request
Jul 11, 2020
Changes: * refactor all functions that now get the variable resolver as argument * update/add unittest * New MapToolExpressionParser that adds caching of expression to the Parser. If an expression has been parsed, its soft cached Expression instance is reused. fixes RPTools#1898
This was referenced Jul 11, 2020
cwisniew
approved these changes
Jul 12, 2020
Member
cwisniew
left a comment
There was a problem hiding this comment.
Reviewed 47 of 47 files at r1.
Reviewable status:complete! all files reviewed, all discussions resolved
cwisniew
pushed a commit
to cwisniew/maptool
that referenced
this pull request
Apr 25, 2023
Supports API where VariableResolver is an evaluation time argument so clients can re-use Expressions, once parsed, multiple times over. Changes: * refactor all functions that now get the variable resolver as argument * update unittest * update ExpressionParser with a protected method that allows overriding Parser (will be used in MapTool)
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.
Make VariableResolver an evaluation time argument so clients can re-use Expressions, once parsed, multiple times over.
The key difference is that parser never gets to see the variable resolver and thus doesn't hold on to it, thus the expression doesn't hang on to it transitively either (The expression is bound to the parser). The variableresolver has to be passed in for evaluation. An expression for a given parser can thus be re-used for invocations in loops.
Have a look, I'm creating a caching branch for dicelib and maptool as well. This is not a backwards compatible change.
Fixes #44
This change is