Skip to content

✨ feat: add conversion operators#1320

Merged
harehare merged 39 commits intomainfrom
feat/convert-operator-support
Feb 25, 2026
Merged

✨ feat: add conversion operators#1320
harehare merged 39 commits intomainfrom
feat/convert-operator-support

Conversation

@harehare
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings February 23, 2026 14:12
@harehare
Copy link
Copy Markdown
Owner Author

@copilot
Can you check out the changes and add some document for conversion operators?

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 23, 2026

@harehare I've opened a new pull request, #1321, to work on those changes. Once the pull request is ready, I'll request review from you.

@harehare harehare changed the title ✨ Feat: add conversion operators ✨ feat: add conversion operators Feb 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 convert builtin (and related conversion utilities) including Markdown/HTML/text/URI/base64 conversions.
  • Add url as 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
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Feb 23, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks


Comparing feat/convert-operator-support (98557b8) with main (146a887)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (facbdbc) during the generation of this report, so 146a887 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@harehare
Copy link
Copy Markdown
Owner Author

@copilot
Can you check out the changes and rename Annotate to Conver?

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 23, 2026

@harehare I've opened a new pull request, #1322, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits February 23, 2026 14:40
♻️ refactor: rename `Annotate` to `Convert` in token/operator types
Copilot AI review requested due to automatic review settings February 23, 2026 23:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 24, 2026

@harehare I've opened a new pull request, #1329, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI review requested due to automatic review settings February 24, 2026 12:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 17 changed files in this pull request and generated 8 comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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. Convert is placed between And and Assign, but alphabetically Assign should come before Convert. 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,
}

Copilot AI review requested due to automatic review settings February 24, 2026 14:01
Copilot AI and others added 2 commits February 24, 2026 14:02
Avoid heap allocation in Convert::try_from symbol matching
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.

Copilot AI review requested due to automatic review settings February 24, 2026 14:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings February 25, 2026 12:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 25, 2026

@harehare I've opened a new pull request, #1334, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits February 25, 2026 12:45
Add integration tests for conversion operator (@) and convert()
@harehare harehare merged commit 3eb8bef into main Feb 25, 2026
7 checks passed
@harehare harehare deleted the feat/convert-operator-support branch February 25, 2026 13:03
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