✨feat(lang): support attribute access after selector call (.h(1).level)#1651
Merged
harehare merged 2 commits intoApr 27, 2026
Merged
Conversation
harehare
commented
Apr 27, 2026
Owner
- Add AST/CST parser logic to allow attribute selectors after selector calls (e.g., .h(1).level)
- Add integration and parser tests for selector call attribute access
- Enables queries like .h(2).depth and .code("rust").lang
- Add AST/CST parser logic to allow attribute selectors after selector calls (e.g., .h(1).level)
- Add integration and parser tests for selector call attribute access
- Enables queries like .h(2).depth and .code("rust").lang
Contributor
There was a problem hiding this comment.
Pull request overview
Adds language support for attribute access immediately after selector calls (e.g., .h(1).level), extending existing attribute-suffix behavior that previously worked for plain selectors (e.g., .code.lang).
Changes:
- Extend CST parsing to accept an attribute selector immediately following a selector call.
- Extend AST parsing to lower
.selectorCall(...).attrinto anattr(selectorCall(...), "attr")builtin call. - Add parser unit tests and an integration test covering the new selector-call attribute access syntax.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/mq-lang/tests/integration_tests.rs | Adds an end-to-end evaluation case for .h(2).depth after a selector call. |
| crates/mq-lang/src/cst/parser.rs | Updates CST selector parsing to allow an attribute selector token immediately after selector-call args. |
| crates/mq-lang/src/ast/parser.rs | Refactors attribute lowering and adds handling/tests for attribute suffixes on Expr::SelectorCall. |
- Add integration test for .code("rust").lang to validate full pipeline
- Fix CST error propagation to use map_err(ParseError::UnknownSelector) instead of unwrap_or(false)
- Add CST parser unit test for selector_call_with_attribute (.h(1).depth layout)
Agent-Logs-Url: https://github.com/harehare/mq/sessions/f74c277e-9380-4d9d-a488-0246892fecf6
Co-authored-by: harehare <533078+harehare@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends mq-lang’s parsing pipeline to support attribute access immediately after selector calls (e.g. .h(1).level), enabling more ergonomic selector-call chaining that desugars into the existing attr(...) / set_attr(...) machinery.
Changes:
- Extend CST parsing to recognize an attribute-selector token following a
SelectorCallnode and attach it to the call node. - Extend AST parsing to convert
.selector_call(...).attrinto anattr(selector_call(...), "attr")call (and support|=viaset_attr), mirroring existing.selector.attrbehavior. - Add AST/CST unit tests and integration tests covering
.h(2).depthand.code("rust").langend-to-end evaluation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/mq-lang/tests/integration_tests.rs | Adds end-to-end integration coverage for attribute access after selector calls. |
| crates/mq-lang/src/cst/parser.rs | Parses attribute selectors that directly follow selector-call argument lists and models them in the CST. |
| crates/mq-lang/src/ast/parser.rs | Desugars selector-call attribute access into attr(...) / set_attr(...) calls; adds parser unit tests. |
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
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.