-
Notifications
You must be signed in to change notification settings - Fork 55
PATHS/VALUES w/ WHERE & $ + has operator #644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devmanuelli
wants to merge
11
commits into
jolie:master
Choose a base branch
from
devmanuelli:feature/paths
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
Implements PATHS and VALUES expressions for querying data structures: - paths data[*] where $ > 5 → returns matching paths - values data[*] where $ > 5 → returns matching values - $ with composable path navigation: $.*[*], $..field, $[n], $[*] - HAS operator: where $ has "field" checks field existence - Existential semantics: ANY value matches (∃), not all Example: paths tree..field[*].*[4] where $.field2[*].*[*] has "field3" Key components: - PathsExpression/ValuesExpression (runtime evaluation) - CurrentValueExpression ($ with path operations) - WhereEvaluator (existential WHERE clause evaluation) - ValueNavigator (tree traversal with path operations) - PathOperation sealed interface (6 composable operation types) - Candidate record (vector + index + path for navigation)
Added WHERE token and inWhereClause flag to prevent $ usage outside WHERE clauses in PATHS/VALUES expressions. Changes: - Scanner: Added WHERE token type and unreserved keyword - OLParser: Added inWhereClause flag with try-finally for safety - Parser validates $ can only appear in WHERE clauses - Error: "$ can only be used in WHERE clauses"
- primitives/paths_values.ol: basic array and nested field tests - library/paths_values.ol: comprehensive tests with JSON data - founded year filters, city filters, recursive descent - existential checks ($..technologies[*]), has operator - complex AND/OR conditions
1d9f69c to
8c65b90
Compare
- ValuePath: new runtime class representing paths in data structures
- NativeType: add PATH("path") enum value
- Value: add isPath(), pathValue(), setValue(ValuePath), create(ValuePath)
- BasicType: add PATH_PREDICATE for type checking
- PathsExpression: return ValuePath values instead of strings
- Test: verify instanceof path and PathResult type checking
Implements pval(pathExpr) that dereferences a path value to get a reference to the actual value. Supports path navigation suffix: - pval(res.results[0]) → returns link to the value at the path - pval(res.results[0]).child → navigates to child field - pval(res.results[0]).children[n] → supports array indexing - pval(res.results[0]).a.b[n].c → composite paths Returns reference semantics (ValueLink), not deep copy like values. Runtime type check throws TypeMismatch fault if input is not path type. Reuses parsePathOperationsSuffix from PATHS/VALUES for path navigation. Adds VariablePathBuilder.add(String) overload for fields without index.
- Add PvalAssignStatement AST node for pval(path).field = value - Add PvalAssignmentProcess runtime for executing pval assignments - Add PvalHelper utility class to share code between rvalue/lvalue - Refactor PvalExpression to use PvalHelper - Add visitor implementations across all OLVisitor implementers
- Add tryConvertValue helper in Type.check() for fast path optimization - Fix reserved keyword conflict in assertions.ol (values -> valuesService)
This commit combines two related improvements to WHERE clause expressions: 1. Extend # operator to accept general expressions: - Allow #($.field) syntax in WHERE clauses for path-based size checks - Restrict # operator to VariablePath and CurrentValueExpression only - Add binding support for arithmetic expressions (SumExpression, ProductExpression) - Make ProductExpression/SumExpression children package-private for WhereEvaluator access 2. Fix NOT operator precedence bug: - Add parseNotExpression() method at correct precedence level - Update parseAndCondition() to call parseNotExpression() - Fix parser so !$ has "field" correctly parses as !($ has "field") - NOT now binds less tightly than HAS and comparison operators per formal grammar Files modified: - OOITBuilder.java: Restrict # to VariablePath and CurrentValueExpression - ValueVectorSizeExpression.java: Update to use CurrentValueExpression exclusively - WhereEvaluator.java: Add binding for arithmetic expressions - ProductExpression.java, SumExpression.java: Make children package-private - OLParser.java: Add parseNotExpression() and update # parsing
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.
Implements PATHS and VALUES expressions for querying data structures:
Example: paths tree..field[].[4] where $.field2[].[*] has "field3"
Key components: