-
-
Notifications
You must be signed in to change notification settings - Fork 149
feat/pattern matching #140
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR integrates pattern matching and variable binding into HQL by extending the AST, parser, analyzer, and grammar.
- Introduces
VariableDeclaration,MatchStep, and related enums/structs in the parser AST. - Updates
GraphStepTypeandStartNodeto carry optional variable declarations. - Extends the grammar (
grammar.pest) withenum_defandmatch_stepconstructs.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| helixdb/src/helixc/parser/helix_parser.rs | Expanded StartNode and GraphStepType, added VariableDeclaration and pattern-matching logic. |
| helixdb/src/helixc/analyzer/analyzer.rs | Updated analyzer pattern matches to use the new GraphStepType variants and variable metadata. |
| helixdb/src/grammar.pest | Added enum_def, match_step, and variable_declaration rules to support pattern matching. |
Comments suppressed due to low confidence (1)
helixdb/src/helixc/analyzer/analyzer.rs:2523
- This error message appears in the
InEbranch but refers to an "outgoing" edge. Update it to mention "incoming" edge to accurately describe the scenario.
format!("Edge of type `{}` exists but it is not a valid outgoing edge type for node of type `{}`", edge_type, node_label),
| variable, | ||
| loc, |
Copilot
AI
Jun 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable (and similarly loc) binding in the OutE { edge_type, variable, loc } match arm is never used. Prefix unused bindings with an underscore to avoid compiler warnings (e.g., _variable).
| variable, | |
| loc, | |
| _variable, | |
| _loc, |
| Rule::variable_declaration => { | ||
| variable = Some(VariableDeclaration { | ||
| loc: p.loc(), | ||
| identifier: p.into_inner().next().unwrap().as_str().to_string(), |
Copilot
AI
Jun 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling .unwrap() after .ok_or_else(...) will panic on error; consider using the ? operator to propagate the ParserError instead of panicking.
| identifier: p.into_inner().next().unwrap().as_str().to_string(), | |
| identifier: p.into_inner().next() | |
| .ok_or_else(|| ParserError::new("Expected identifier"))? | |
| .as_str() | |
| .to_string(), |
Description
Integrate Pattern matching into HQL that allow user to match on enum variants within queries. e.g.
Type of Change
Related Issues
Closes #
Testing
Checklist
Additional Notes