Skip to content

Break up Parser and variable resolver to allow clients to cache expressions to optimize performance #44

Description

@nmeier

This is related to RPTools/maptool#1898

Currently Parser is initialized with a variable resolver instance and carried forward (even convenience var access methods are offered on Parser). Everything down stream from parser, the Expression, DeterministicTreeParser, refers back to the parser and its embedded variable resolver in evaluation.

This means that clients cannot cache expressions - a simple expression needs to re-parsed every time (for example in a MapTool macro loop).

This request and PR (coming) suggests to divorce Parser from VariableResolver - the variable resolver has to be passed in on Expression.evaluate(), not before.

I have the appropriate change to update dicelib (mostly the functions and the ExpressionParser to update the contract with Parser).

I also have the appropriate change to update MapTool to introduce Expression caching (with the change above caching the Parser doesn't have to know anything about caching).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions