Skip to content

Refactor Parser to separate expression parsing from evaluation. #45

Merged
Phergus merged 1 commit intoRPTools:developfrom
nmeier:caching
Jul 12, 2020
Merged

Refactor Parser to separate expression parsing from evaluation. #45
Phergus merged 1 commit intoRPTools:developfrom
nmeier:caching

Conversation

@nmeier
Copy link
Copy Markdown
Contributor

@nmeier nmeier commented Jul 11, 2020

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 Reviewable

…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
@Phergus Phergus requested a review from cwisniew July 11, 2020 15:21
Copy link
Copy Markdown
Member

@cwisniew cwisniew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 47 of 47 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@Phergus Phergus merged commit 3e1bfd0 into RPTools:develop Jul 12, 2020
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants