Skip to content

memoizes creating a parse tree#84

Merged
keith-turner merged 1 commit intoapache:mainfrom
keith-turner:add_parse_instance_method
Feb 11, 2025
Merged

memoizes creating a parse tree#84
keith-turner merged 1 commit intoapache:mainfrom
keith-turner:add_parse_instance_method

Conversation

@keith-turner
Copy link
Contributor

This change offers a new parse() method on AccessExpression that creates a parse tree if one does not exits. This change allows decoupling how access expression are created (w/ or w/o an initial parse tree) from using parse trees.

For example code the like the following that wanted to use a parse tree to validate an access expression would have required the ParsedAccessExpression type to be passed to it. Now it can accept an AccessExpression and call parse() which will do the most efficient thing depending on how the expression was created.

void checkExpression(AccessExpression expression){
    var parsed = expression.parse();
    // use parse tree to validate expression
}

This change offers a new parse() method on AccessExpression that creates
a parse tree if one does not exits.  This change allows decoupling how
access expression are created (w/ or w/o an initial parse tree) from
using parse trees.

For example code the like the following that wanted to use a parse tree
to validate an access expression would have required the
ParsedAccessExpression type to be passed to it.  Now it can accept an
AccessExpression and call parse() which will do the most efficient thing
depending on how the expression was created.

```java

void checkExpression(AccessExpression expression){
    var parsed = expression.parse();
    // use parse tree to validate expression
}

```
Copy link
Contributor

@ddanielr ddanielr left a comment

Choose a reason for hiding this comment

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

Makes sense and I think allowing the users to not have to chose between object types is a great improvement.

@keith-turner keith-turner merged commit 2f68281 into apache:main Feb 11, 2025
6 checks passed
@keith-turner keith-turner deleted the add_parse_instance_method branch February 11, 2025 23:32
@ctubbsii ctubbsii added this to the 1.0.0 milestone Feb 13, 2025
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