Conversation
|
@copilot |
Co-authored-by: harehare <[email protected]>
There was a problem hiding this comment.
Pull request overview
Adds a new conversion operator (@) to the mq language by introducing an Annotate token / binary op that maps to a new convert builtin, and refactors existing conversion helpers into a dedicated eval::builtin::convert module.
Changes:
- Add
@token support in the lexer and wire it through CST/AST parsing as a binary operator. - Introduce
convertbuiltin (and related conversion utilities) including Markdown/HTML/text/URI/base64 conversions. - Add
urlas a dependency to support URL-based conversions.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/mq-lang/src/lexer/token.rs | Adds TokenKind::Annotate and display rendering for @. |
| crates/mq-lang/src/lexer.rs | Adds lexer parser for @ and includes it in binary_op parsing. |
| crates/mq-lang/src/eval/builtin/convert.rs | New conversion utilities module + Convert / ConvertKind logic and tests. |
| crates/mq-lang/src/eval/builtin.rs | Wires @ to new CONVERT builtin and moves conversion helpers to convert module; adds builtin docs entry. |
| crates/mq-lang/src/cst/parser.rs | Maps TokenKind::Annotate to BinaryOp::Annotate. |
| crates/mq-lang/src/cst/node.rs | Adds BinaryOp::Annotate variant. |
| crates/mq-lang/src/ast/parser.rs | Adds Annotate to binary-op detection, precedence, and builtin function mapping (convert). |
| crates/mq-lang/src/ast/constants.rs | Adds builtins::CONVERT constant. |
| crates/mq-lang/Cargo.toml | Adds url workspace dependency. |
| Cargo.lock | Locks url dependency addition. |
📝 docs: add documentation for the `@` conversion operator
|
@copilot |
Co-authored-by: harehare <[email protected]>
♻️ refactor: rename `Annotate` to `Convert` in token/operator types
Co-authored-by: harehare <[email protected]>
Add CST and AST parser tests for the `@` (convert) operator
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
crates/mq-lang/src/cst/node.rs:155
- The BinaryOp enum variants are not in alphabetical order.
Convertis placed betweenAndandAssign, but alphabeticallyAssignshould come beforeConvert. While the TokenKind enum (token.rs:49-128) explicitly maintains alphabetical order with a comment stating "TokenKind variants are sorted alphabetically for maintainability", the BinaryOp enum should follow the same convention.
The correct alphabetical order should be: And, Assign, Coalesce, Convert, Division, etc.
pub enum BinaryOp {
And,
Convert,
Assign,
Coalesce,
Division,
DivisionEqual,
DoubleDivisionEqual,
PipeEqual,
Equal,
Gt,
Gte,
Lt,
Lte,
Minus,
MinusEqual,
Modulo,
ModuloEqual,
Multiplication,
MultiplicationEqual,
NotEqual,
Or,
Plus,
PlusEqual,
RangeOp,
RegexMatch,
LeftShift,
RightShift,
}
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…Convert::try_from Co-authored-by: harehare <[email protected]>
Avoid heap allocation in Convert::try_from symbol matching
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…d convert() Co-authored-by: harehare <[email protected]>
Add integration tests for conversion operator (@) and convert()
No description provided.